使用源代码包实现LAMP构架模型



安装httpd

   解决依赖关系:httpd-2.4.x 需要的apr和apr-util均在1.4.0之上,但是centos 6.6 自带的apr和apr-util 均为1.3.9,

因此需要事先对其进行升级。

Microsoft YaHei';[lijun@Test01 source]$ rpm -qa | grep apr
apr-util-1.3.9-3.el6_0.1.x86_64
apr-1.3.9-5.el6_2.x86_64
[lijun@Test01 source]$

   编译安装apr和apr-util:

Microsoft YaHei';">[lijun@Test01 source]$ tar -xf apr-1.5.0.tar.bz2                          

[lijun@Test01 source]$ cd apr-1.5.0                                        

[lijun@Test01 apr-1.5.0]$ ./configure --prefix=/usr/local/apr && make
[lijun@Test01 apr-1.5.0]$sudo make install

[lijun@Test01 apr-1.5.0]$ ls /usr/local/apr
bin  build-1  include  lib
[lijun@Test01 apr-1.5.0]$

  编译安装apr-util:

'Microsoft YaHei';">[lijun@Test01 source]$ tar -xf apr-util-1.5.3.tar.bz2
[lijun@Test01 source]$ cd apr-util-1.5.3
[lijun@Test01 apr-util-1.5.3]$ ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make
[lijun@Test01 apr-util-1.5.3]$ sudo make install
[lijun@Test01 apr-util-1.5.3]$ ls /usr/local
apr  apr-util  bin  etc  games  include  lib  lib64  libexec  sbin  share  src
[lijun@Test01 apr-util-1.5.3]$

      

   编译安装httpd-2.4.10.tar.bz2

Microsoft YaHei';">[lijun@Test01 source]$ tar -xf httpd-2.4.10.tar.bz2
[lijun@Test01 source]$ cd httpd-2.4.10
[lijun@Test01 httpd-2.4.10]$ ./configure --prefix=/usr/local/apache2410 \
--enable-so --enable-ssl \
--enable-cgi --enable-rewrite --with-zlib --with-pcre \
--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util \
--enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
[lijun@Test01 source]$ make
[lijun@Test01 source]$ sudo make install
[lijun@Test01 httpd-2.4.10]$ ls /usr/local/apache2410/
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules
[lijun@Test01 httpd-2.4.10]$

   

 导出头文件   添加man手册  修改PATH路径,

Microsoft YaHei';">[lijun@Test01 httpd-2.4.10]$ sudo vim /etc/profile.d/httpd.sh
export PATH=/usr/local/apache2410/bin:$PATH
:wq
[lijun@Test01 httpd-2.4.10]$ sudo ln -sv /usr/local/apache2410/include /usr/include/http
"/usr/include/http" /usr/local/apache2410/include"
[lijun@Test01 httpd-2.4.10]$ sudo vim /etc/man.config
MANPATH /usr/local/apache2410/man
:wq

 安装mariadb 二进制程序包

Microsoft YaHei';">[lijun@Test01 source]$ sudo tar -xf mariadb-5.5.43-linux-x86_64.tar.gz -C /usr/local/
[lijun@Test01 source]$ ls /usr/local
apache2410  apr-util  etc    include  lib64    mariadb-5.5.43-linux-x86_64  share
apr         bin       games  lib      libexec  sbin                         src
[lijun@Test01 source]$ sudo ln -s /usr/local/mariadb-5.5.43-linux-x86_64/  /usr/local/mysql
[lijun@Test01 source]$ cd /usr/local/mysql
[lijun@Test01 mysql]$sudo groupadd -r mysql
[lijun@Test01 mysql]$sudo useradd -g mysql -r mysql
[lijun@Test01 mysql]$sudo chown -R root:mysql mariadb-5.5.43-linux-x86_64
[lijun@Test01 mysql]$sudo chown -R mysql:mysql mariadb-5.5.43-linux-x86_64/data/
[lijun@Test01 mysql]$sudo mkdir /etc/mysql/
[lijun@Test01 mysql]$sudo cp /usr/local/mysql/support-files/my-medium.cnf /etc/mysql/my.cnf
[lijun@Test01 mysql]$ sudo /usr/local/mysqlscripts/mysql_install_db --user=mysql --defaults-file=/etc/mysql/my.cnf
[lijun@Test01 mysql]$sudo cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[lijun@Test01 mysql]$sudo chmod +x /etc/init.d/mysqld
[lijun@Test01 mysql]$ sudo touch /etc/profile.d/mysql.sh
[lijun@Test01 mysql]$ sudo vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH
:wq
[lijun@Test01 mysql]$ sudo ln -s /usr/local/mysql/include /usr/include/mysql
[lijun@Test01 mysql]$ sudo vim /etc/man.config
MANPATH /usr/local/mysql/man
:wq


  

编译安装php

  安装依赖的组件:libxml2-devel,  bzip2-devel

1Microsoft YaHei';">[lijun@Test01 source]$sudo yum -y install bzip2-devel  libxml2-devel

  编译安装:Microsoft YaHei';">[root@Test01 lamp]# tar -xf php-5.4.40.tar.bz2
[root@Test01 lamp]# cd php-5.4.40
[root@Test01 php-5.4.40]# ./configure --prefix=/usr/local/php \
--with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-apxs2=/usr/local/apache2410/bin/apxs --with-freetype-dir \
--with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr \
--enable-xml --enable-sockets --with-bz2 \
--with-config-file-path=/etc/php/php.ini --with-config-file-scan-dir=/etc/php.d/
[root@Test01 php-5.4.40]# make && make install

   添加配置文件Microsoft YaHei';">[root@Test01 php-5.4.40]# cp php.ini-production  /etc/php.ini

    配置httpd支持php

#vim /usr/local/apache2410/conf/httpd.conf

添加如下二行

   AddType application/x-httpd-php  .php

   AddType application/x-httpd-php-source  .phps


定位至DirectoryIndex index.html 

   修改为:

    DirectoryIndex  index.php  index.html


    做php同httpd的结合测试:Microsoft YaHei';">[root@Test01 conf]# touch /usr/local/apache2410/htdocs/index.php
[root@Test01 conf]# vim /usr/local/apache2410/htdocs/index.php
 1  2 phpinfo();
 3 ?>
[root@Test01 conf]#

 做php同mariadb连通性测试Microsoft YaHei';">[root@Test01 conf]# service mysqld start
Starting MySQL                                             [  OK  ]
[root@Test01 conf]# vim /usr/local/apache2410/htdocs/index.php
     $link = mysql_connect('127.0.0.1','root','');
     if ($link)
     echo "Success...";
     else
         echo "Failure...";
     mysql_close();
?>