centos下lamp源码安装

LAMP指的Linux(操作系统)、ApacheHTTP 服务器,MySQL(有时也指MariaDB,数据库软件) 和PHP(有时也是指Perl或Python) 的第一个字母,一般用来建立web 服务器。


安装mysql这里我们用的是mysql-5.6.15-linux-glibc2.5-x86_64.tar.gz的绿色软件包

解压mysql绿色软件包

[root@station111 lamp]# tar -zxvf mysql-5.6.15-linux-glibc2.5-x86_64.tar.gz -C /usr/local

[root@station111 lamp]# groupadd mysql

[root@station111 lamp]# useradd -r -g mysql mysql

[root@station111 lamp]# cd /usr/local

[root@station111 src]# cd mysql

[root@station111 mysql]# chown -R mysql:mysql .

[root@station111 mysql]# ./scripts/mysql_install_db

[root@station111 mysql]# scripts/mysql_install_db --user=mysql

[root@station111 mysql]# chown -R root .

[root@station111 mysql]# chown -R mysql data

[root@station111 mysql]# bin/mysqld_safe --user=mysql

[root@station111 mysql]# cp my.cnf  /etc

生成启动脚本

[root@station111 mysql]# cp support-files/mysqld_multi.server  /etc/init.d/mysqld

[root@station111 mysql]# chmod   a+x  /etc/init.d/mysqld

重启mysql服务

[root@station111 mysql]# service mysqld start

给mysql设置管理账号和密码

[root@station111 mysql]# mysqladmin -u root -p password '111'



安装Apache,这里我们用的是httpd-2.4.9.tar.bz2,安装Apache需要先安装apr和apr-util

安装apr到/usr/local/apr

解压apr文件包

[root@station111 lamp]# tar -jxvf apr-1.5.1.tar.bz2 -C /usr/local/src

进入解压后的apr目录

[root@station111 lamp]# /usr/local/src/apr-1.5.1/

安装apr到/usr/local/apr

[root@station111 apr-1.5.1/]# ./configure --prefix=/usr/local/apr

[root@station111 apr-1.5.1/]# make && make install

安装apr-util到/usr/local/apr-util

[root@station111 lamp]# tar -jxvf apr-util-1.5.3.tar.bz2 -C /usr/local/src

[root@station111 lamp]# /usr/local/src/apr-util-1.5.3/

[root@station111 apr-util-1.5.3]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin

[root@station111 apr-util-1.5.3]# make &&make install

安装http到/usr/local/apache

[root@station111 lamp]# tar -jxvf httpd-2.4.9.tar.bz2 -C /usr/local/src

[root@station111 lamp]# cd /usr/local/src/httpd-2.4.9

[root@station111 /httpd-2.4.9]# ./configure  \

--prefix=/usr/local/apache  \

--sysconfdir=/etc/httpd \

--enable-so \

--enable-ssl  \

--enable-rewrite  \

--with-apr=/usr/local/apr/bin/apr-1-config \

--with-apr-util=/usr/local/apr-utils/bin/apu-1-config \

--with-pcre  \

-with-z  \

--enable-mpms-shared=all

[root@station111 /httpd-2.4.9]# make && make install

编写启动脚本文件

[root@station111 /httpd-2.4.9]# touch /etc/init.d/httpd

[root@station111 /httpd-2.4.9]# chmod a+x /etc/init.d/httpd

[root@station111 /httpd-2.4.9]# vim /etc/init.d/httpd


 1 #!/bin/bash

 2 prog=/usr/local/apache/bin/httpd

 3 lockfile=/var/lock/subsys/httpd

 4 . /etc/init.d/functions

 5

 6 start ()  {

 7         if [ -e $lockfile ]; then

 8         echo -e -n "\033[31m    the httpd server is started \033[0m"

 9         else

10         echo -e -n  "\033[32m   the httpd server is starting...\033[0m"  

11         sleep 1

12         $prog -k start  &

13         if [ $? ]; then

14         echo -e "\033[32m        "[STSRT]" \033[0m" && touch $lockfile >/dev/null

15         else  echo -e "\033[31m fail \033[0m"

16         fi

17         fi

18 }

19

20

21 stop ()  {

22

23         if [ ! -e $lockfile ]; then

24         echo -e "\033[31m       the httpd server is stoped \033[0m"

25         else

26         $prog -k stop  &

27         if [ $? ]; then

28         echo -e -n "\033[32m "the httpd server is stopping..."\033[0m" >/dev/null

29         sleep 1

30         echo -e  "\033[31m      "[STOP]" \033[0m" && rm -rf $lockfile

31         else  echo -e "\033[31m         "[fail]" \033[0m"

32         fi

33         fi

34 }

35

36

37 status () {

38         if [ -e $lockfile ] ;then

39         echo -e "\033[32m       the httpd server is started \033[0m"

40         else  echo -e "\033[31m         the httpd server is stoped \033[0m"

41         fi

42 }

43

44 case "$1" in

45 start)

46         start

47         ;;

48 stop)

49         stop

50         ;;

51 restart)

52         stop

53         start

54         ;;

55 status)

56         status

57         ;;

58 *)

59 echo -e "\033[31m USAGE: start|stop|restart|status \033[0m"

60 esac

wKioL1N5rLvTDfr5AAKq1mwy490504.jpg

wKiom1N5rOegYT_OAACX4s4Z48Q620.jpg

重启HTTP协议

[root@station111 /httpd-2.4.9]# service httpd restart

测试Apache,在浏览器输入你的apache 服务器地址

wKioL1N5rWLSDFnbAACU4JcZv94880.jpg

安装php

[root@station111 lamp]# tar -jxvf php-5.5.8.tar.bz2 -C /usr/local/src

[root@station111 lamp]# cd /usr/local/src php-5.5.8

[root@station111 php-5.5.8]# ./configure  \

--prefix=/usr/local/php \

--with-config-file-path=/etc/php  \

--with-config-file-scan-dir=/etc/php5.d  \

--with-apxs2=/usr/local/apache/bin/apxs  \

--with-mysql=/usr/local/mysql \

--with-mysqli=/usr/local/mysql/bin/mysql_config \

--enable-mbstring=all \

--disable-fileinfo     /////内存小于1G必须加这个

[root@station111 php-5.5.8]# make && make install

[root@station111 php-5.5.8]# mkdir -pv /etc/php /etc/php5.d

[root@station111 php-5.5.8]# cp .libs/libphp5.so /usr/local/apache/modules/libphp5.so

[root@station111 php-5.5.8]# cp .libs/libphp5.lai /usr/local/apache/modules/libphp5.la

在httpd.conf  加入  AddType application/x-httpd-php .php

[root@station111 php-5.5.8]# echo "AddType application/x-httpd-php .php"  >>/etc/httpd/httpd.conf

编写一个php主页放到web服务器

[root@station111 php-5.5.8]# vim ../../apache/htdocs/index.php

wKiom1N5rQLD01a3AAATJ4qPhZY262.jpg


重启httpd服务

[root@station111 php-5.5.8]# service httpd restart


打开浏览器进入http://你的web服务器的IP地址/index.php


wKiom1N5rRLiSViYAANLcjojhpo514.jpg











你可能感兴趣的:(http,PHP,mysql,lamp)