[root@localhost PHP]# cd /usr/local/src/PHP
[root@localhost PHP]# tar -xzvf ./libmcrypt-2.5.8.tar.gz
[root@localhost PHP]# cd ./libmcrypt-2.5.8
[root@localhost PHP]# ./configure --prefix=/usr
[root@localhost PHP]# make && make install
2、安装 mhash
[root@localhost PHP]# cd /usr/local/src/PHP
[root@localhost PHP]# tar -xzvf ./mhash-0.9.9.9.tar.gz
[root@localhost PHP]# cd ./mhash-0.9.9.9
[root@localhost PHP]# ./configure --prefix=/usr
[root@localhost PHP]# make && make install
3、安装 mcrypt
[root@localhost PHP]# /sbin/ldconfig #搜索出可共享的动态链接库
[root@localhost PHP]# cd /usr/local/src/PHP
[root@localhost PHP]# tar -xzvf ./mcrypt-2.6.8.tar.gz
[root@localhost PHP]# cd ./mcrypt-2.6.8
[root@localhost PHP]# ./configure
[root@localhost PHP]# make && make install
4、安装 libiconv
[root@localhost PHP]# cd /usr/local/src/PHP
[root@localhost PHP]# tar -xzvf ./libiconv-1.14.tar.gz
[root@localhost PHP]# cd ./libiconv-1.14
[root@localhost PHP]# ./configure --prefix=/usr/local/libiconv
[root@localhost PHP]# make && make install
安装 PHP
[root@localhost PHP]# tar -xzvf ./php-5.6.13.tar.gz
[root@localhost PHP]# cd php-5.6.13/
[root@localhost php-5.6.13]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-mcrypt --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts
[root@localhost php-5.6.13]# make && make install
编译参数解释:
--prefix=/usr/local/php : 设置安装路径
--with-apxs2=/usr/local/apache2/bin/apxs : 编译共享的 Apache 2.0 模块
--with-config-file-path=/etc : 指定配置文件php.ini地址
--with-config-file-scan-dir=/etc/php.d : 指定额外的ini文件目录
--with-openssl : 编译OpenSSL支持
--with-zlib: 编译zlib支持
--enable-bcmath : 启用BC风格精度数学函数
--with-bz2 : BZip2支持
--with-gd : GD支持
--with-mhash : mhash支持
--enable-mbstring : 启用支持多字节字符串
--with-mcrypt : 编译mcrypt加密支持
--enable-zip : 启用zip 读/写支持
--with-iconv=/usr/local/libiconv : iconv支持
--with-curl : CRUL支持
--with-mysql=/usr/local/mysql : 启用mysql支持
--with-pdo-mysql=/usr/local/mysql : 启用pdo-mysql支持
--without-pear : 不安装PEAR
复制配置文件php.ini
[root@localhost php-5.6.13]# cp /usr/local/src/php-5.6.13/php.ini-production /etc/php.ini
整合Apache
1、在/etc/httpd/conf/httpd.conf文件中加入PHP文件类型解析(加在文件最后即可)
[root@localhost ~]# sed -i '378aAddType application/x-httpd-php .php' /etc/httpd/httpd.conf
[root@localhost ~]# sed -i '379aAddtype application/x-httpd-php-source .phps' /etc/httpd/httpd.conf
[root@localhost ~]# sed -i 's/DirectoryIndex.*index.*/DirectoryIndex index.php index.html/g' /etc/httpd/httpd.conf
2、重启Apache
[root@localhost ~]# service httpd restart # 或 /etc/init.d/httpd restart
3、添加测试页面
[root@localhost php-5.6.13]# cat /usr/local/apache2/htdocs/index.php
<?php
phpinfo()
?>
测试LAMP搭建开源数据web管理程序phpMyadmin
[root@localhost src]# tar xf phpMyAdmin-3.5.8.2-all-languages.tar.gz
[root@localhost src]# ln -s /usr/local/src/phpMyAdmin-3.5.8.2 /usr/local/apache2/htdocs/pma/
[root@localhost htdocs]# chmod 755 pma
[root@localhost htdocs]# cd pma
[root@localhost pma]# cp -f config.sample.inc.php config.inc.php
[root@localhost htdocs]# chown -R apache:apache pma/
下面关于LAMP相关的内容你可能也喜欢: