下载解压

wget http://cn2.php.net/distributions/php-5.6.28.tar.gz
tar -xvzf php-5.6.28.tar.gz 
cd php-5.6.28

编译安装

服务器上的配置参数

./configure --prefix=/opt/php --with-config-file-path=/opt/php/lib --enable-mbstring --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl-dir=/usr --with-openssl --with-pdo-mysql=mysqlnd --with-pear --enable-sockets --with-freetype-dir=/usr --enable-gd-native-ttf --with-zlib --with-libxml-dir=/usr --with-xmlrpc --enable-zip --enable-xml --enable-sockets --with-gd --with-zlib --with-iconv --enable-zip --with-freetype-dir=/usr/lib/ --enable-soap --enable-pcntl --enable-cli  --with-apxs2=/usr/local/httpd/bin/apxs 

加上 --with-apxs2=/usr/local/httpd/bin/apxs 参数后,PHP 编译后会自动根据 Apache 把编译好的 libphp5.so 文件放入 Apache 的 Modules 目录 /usr/local/httpd/modules/

教程里的配置

./configure --prefix=/opt/php --with-config-file-path=/opt/php/lib --enable-mbstring --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl-dir=/usr --with-openssl --with-pdo-mysql=mysqlnd --with-pear --enable-sockets --with-freetype-dir=/usr --enable-gd-native-ttf --with-zlib --with-libxml-dir=/usr --with-xmlrpc --enable-zip --enable-fpm --enable-fpm --enable-xml --enable-sockets --with-gd --with-zlib --with-iconv --enable-zip --with-freetype-dir=/usr/lib/ --enable-soap --enable-pcntl --enable-cli --with-apxs2=/usr/local/httpd/bin/apxs  --with-curl 

安装

make && make install
cp php.ini-production /opt/php/lib/php.ini

替换当前的 PHP

ln -s /opt/php/bin/php /usr/bin/php
ln -s /opt/php/bin/php-config /usr/bin/php-config
ln -s /opt/php/bin/php-cgi /usr/bin/php-cgi
ln -s /opt/php/bin/pecl /usr/bin/pecl
ln -s /opt/php/bin/phpize /usr/bin/phpize
ln -s /opt/php/bin/pear /usr/bin/pear

安装扩展

pecl install xhprof-beta
pecl install memcache
pecl install redis

更新配置文件

vim /opt/php/lib/php.ini

# 添加以下几行
extension=xhprof.so
extension=memcache.so
extension=redis.so

配置 Apache

发现 Apache 的配置也极其遭乱,遂重新编译安装 Apache。 为了保证现有的配置能用,采用 2.2 版本,安装到 /usr/local/apache2 目录是为了防止与以前的目录冲突。

wget http://mirrors.cnnic.cn/apache//httpd/httpd-2.2.31.tar.gz
tar -zxvf httpd-2.2.31.tar.gz
cd httpd-2.2.31

./configure  --prefix=/usr/local/apache2 --enable-mods-shared=most --enable-rewirte --enable-so --enable-ssl=static --with-ssl=/usr/local/ssl  --enable-proxy=shared --enable-proxy-balancer=shared --enable-proxy-http=shared --enable-proxy-ajp --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-suexec

# 下面这个配置备用

./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all --enable-cache  --enable-disk-cache --enable-mem-cache  --enable-file-cache --enable-proxy --enable-http-proxy --enable-ftp-proxy

make && make install

重新编译安装一下 PHP,主要是修正 --with-apxs2=/usr/local/apache2/bin/apxs 参数

./configure --prefix=/opt/php --with-config-file-path=/opt/php/lib --enable-mbstring --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl-dir=/usr --with-openssl --with-pdo-mysql=mysqlnd --with-pear --enable-sockets --with-freetype-dir=/usr --enable-gd-native-ttf --with-zlib --with-libxml-dir=/usr --with-xmlrpc --enable-zip --enable-xml --enable-sockets --with-gd --with-zlib --with-iconv --enable-zip --with-freetype-dir=/usr/lib/ --enable-soap --enable-pcntl --enable-cli --with-curl --with-apxs2=/usr/local/apache2/bin/apxs 

make && make install

配置

先备份 apache2 的默认配置,将老的配置 copy 过来

cd /usr/local/apache2
mv conf conf_old
cp -R /etc/httpd/conf /usr/local/apache2/

配置 PHP

vim /usr/local/apache2/conf/httpd.conf
LoadModule php5_module  /usr/local/apache2/modules/libphp5.so
AddType application/x-httpd-php .php

启动

/usr/local/apache2/bin/apachectl start

发现缺失一些模块,使用 apxs 激活相应模块(后来发现太麻烦了,还是重新编译安装吧)

/usr/local/apache2/bin/apachectl -t
cd ~/source/httpd-2.2.31
cd modules/proxy
/usr/local/apache2/bin/apxs -c -i -a mod_proxy.c proxy_util.c
/usr/local/apache2/bin/apxs -c -i -a mod_proxy_ftp.c 
/usr/local/apache2/bin/apxs -c -i -a mod_proxy_http.c 
/usr/local/apache2/bin/apxs -c -i -a mod_proxy_balancer.c 
/usr/local/apache2/bin/apxs -c -i -a mod_proxy_connect.c
/usr/local/apache2/bin/apxs -c -i -a mod_proxy_ajp.c
/usr/local/apache2/bin/apxs -c -i -a mod_proxy_ajp.c ajp*.c
/usr/local/apache2/bin/apxs -c -i -a mod_proxy_balancer.c mod_proxy_connect.c  mod_proxy_http.c

cd modules/cache
/usr/local/apache2/bin/apxs -c -i -a mod_cache.c mod_file_cache.c mod_disk_cache.c mod_mem_cache.c

cd modules/ldap

/usr/local/apache2/bin/apachectl start

PHP5.6 的安装目录是 /opt/php Apache2.2 的配置路径 /etc/httpd/conf/httpd.conf

更新 Apache 配置

服务器上有两个版本的 httpd,重置为一个版本

mv /usr/sbin/httpd /usr/sbin/httpd.bak ln -s /usr/local/httpd/bin/httpd /usr/sbin/httpd /usr/sbin/apachectl restart /usr/local/httpd/bin/httpd start

vim /etc/httpd/conf/httpd.conf

LoadModule php5_module /usr/local/httpd/modules/libphp5.so AddType application/x-httpd-php .php

重启 Apache


/usr/sbin/apachectl restart

WEBADMIN 项目配置

vim /etc/httpd/conf/extra/webadmin-kit-vhosts.conf

错误日志 /etc/httpd/logs/admin.st.xxx.org.error.log

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

LoadModule rewrite_module modules/mod_rewrite.so #开启rewrite

标签: none

添加新评论