使用源代码包实现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<br>apr-util-1.3.9-3.el6_0.1.x86_64<br>apr-1.3.9-5.el6_2.x86_64<br>[lijun@Test01 source]$<br></span>
编译安装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<br>[lijun@Test01 apr-1.5.0]$sudo make install
[lijun@Test01 apr-1.5.0]$ ls /usr/local/apr<br>bin build-1 include lib<br>[lijun@Test01 apr-1.5.0]$<br></span>
编译安装apr-util:
'Microsoft YaHei';">[lijun@Test01 source]$ tar -xf apr-util-1.5.3.tar.bz2<br>[lijun@Test01 source]$ cd apr-util-1.5.3<br>[lijun@Test01 apr-util-1.5.3]$ ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make<br>[lijun@Test01 apr-util-1.5.3]$ sudo make install<br>[lijun@Test01 apr-util-1.5.3]$ ls /usr/local<br>apr apr-util bin etc games include lib lib64 libexec sbin share src<br>[lijun@Test01 apr-util-1.5.3]$<br></span>
编译安装httpd-2.4.10.tar.bz2
Microsoft YaHei';">[lijun@Test01 source]$ tar -xf httpd-2.4.10.tar.bz2<br>[lijun@Test01 source]$ cd httpd-2.4.10<br>[lijun@Test01 httpd-2.4.10]$ ./configure --prefix=/usr/local/apache2410 \<br>--enable-so --enable-ssl \<br>--enable-cgi --enable-rewrite --with-zlib --with-pcre \<br>--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util \<br>--enable-modules=most --enable-mpms-shared=all --with-mpm=prefork<br>[lijun@Test01 source]$ make<br>[lijun@Test01 source]$ sudo make install<br>[lijun@Test01 httpd-2.4.10]$ ls /usr/local/apache2410/<br>bin build cgi-bin conf error htdocs icons include logs man manual modules<br>[lijun@Test01 httpd-2.4.10]$<br></span>
导出头文件 添加man手册 修改PATH路径,
Microsoft YaHei';">[lijun@Test01 httpd-2.4.10]$ sudo vim /etc/profile.d/httpd.sh<br>export PATH=/usr/local/apache2410/bin:$PATH<br>:wq<br>[lijun@Test01 httpd-2.4.10]$ sudo ln -sv /usr/local/apache2410/include /usr/include/http<br>"/usr/include/http" /usr/local/apache2410/include"<br>[lijun@Test01 httpd-2.4.10]$ sudo vim /etc/man.config<br>MANPATH /usr/local/apache2410/man<br>:wq<br></span>
安装mariadb 二进制程序包
Microsoft YaHei';">[lijun@Test01 source]$ sudo tar -xf mariadb-5.5.43-linux-x86_64.tar.gz -C /usr/local/<br>[lijun@Test01 source]$ ls /usr/local<br>apache2410 apr-util etc include lib64 mariadb-5.5.43-linux-x86_64 share<br>apr bin games lib libexec sbin src<br>[lijun@Test01 source]$ sudo ln -s /usr/local/mariadb-5.5.43-linux-x86_64/ /usr/local/mysql <br>[lijun@Test01 source]$ cd /usr/local/mysql<br>[lijun@Test01 mysql]$sudo groupadd -r mysql<br>[lijun@Test01 mysql]$sudo useradd -g mysql -r mysql<br>[lijun@Test01 mysql]$sudo chown -R root:mysql mariadb-5.5.43-linux-x86_64<br>[lijun@Test01 mysql]$sudo chown -R mysql:mysql mariadb-5.5.43-linux-x86_64/data/<br>[lijun@Test01 mysql]$sudo mkdir /etc/mysql/<br>[lijun@Test01 mysql]$sudo cp /usr/local/mysql/support-files/my-medium.cnf /etc/mysql/my.cnf<br>[lijun@Test01 mysql]$ sudo /usr/local/mysqlscripts/mysql_install_db --user=mysql --defaults-file=/etc/mysql/my.cnf<br>[lijun@Test01 mysql]$sudo cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld<br>[lijun@Test01 mysql]$sudo chmod +x /etc/init.d/mysqld<br>[lijun@Test01 mysql]$ sudo touch /etc/profile.d/mysql.sh<br>[lijun@Test01 mysql]$ sudo vim /etc/profile.d/mysql.sh<br>export PATH=/usr/local/mysql/bin:$PATH<br>:wq<br>[lijun@Test01 mysql]$ sudo ln -s /usr/local/mysql/include /usr/include/mysql<br>[lijun@Test01 mysql]$ sudo vim /etc/man.config<br>MANPATH /usr/local/mysql/man<br>:wq<br></span>
编译安装php
安装依赖的组件:libxml2-devel, bzip2-devel
1Microsoft YaHei';">[lijun@Test01 source]$sudo yum -y install bzip2-devel libxml2-devel<br></span>
编译安装:Microsoft YaHei';">[root@Test01 lamp]# tar -xf php-5.4.40.tar.bz2 <br>[root@Test01 lamp]# cd php-5.4.40<br>[root@Test01 php-5.4.40]# ./configure --prefix=/usr/local/php \<br>--with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config \<br>--with-apxs2=/usr/local/apache2410/bin/apxs --with-freetype-dir \<br>--with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr \<br>--enable-xml --enable-sockets --with-bz2 \<br>--with-config-file-path=/etc/php/php.ini --with-config-file-scan-dir=/etc/php.d/<br>[root@Test01 php-5.4.40]# make && make install<br></span>
添加配置文件Microsoft YaHei';">[root@Test01 php-5.4.40]# cp php.ini-production /etc/php.ini<br></span>
配置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<br>[root@Test01 conf]# vim /usr/local/apache2410/htdocs/index.php<br> 1 <?php<br> 2 phpinfo();<br> 3 ?><br>[root@Test01 conf]#<br></span>
做php同mariadb连通性测试Microsoft YaHei';">[root@Test01 conf]# service mysqld start<br>Starting MySQL [ OK ]<br>[root@Test01 conf]# vim /usr/local/apache2410/htdocs/index.php<br><?php<br> $link = mysql_connect('127.0.0.1','root','');<br> if ($link)<br> echo "Success...";<br> else<br> echo "Failure...";<br> mysql_close();<br>?><br></span>