当前位置:首页 > 技术文章 > 系统架构 > 系统架构-php安装与配置
系统架构-php安装与配置
文章来源:本站原创  浏览次数:82  发布日期:2013-07-19

#cd /tmp

//需要提前安装的库
#tar xzf libmcrypt-2.5.8.tar.gz
#tar xzf mhash-0.9.9.9.tar.gz
#tar xzf mcrypt-2.6.8.tar.gz
#tar xzf libiconv-1.14.tar.gz

//安装libmcrypt
#cd /tmp/libmcrypt-2.5.8
#./configure --prefix=/usr/web/libmcrypt
#make && make install
//安装mhash
#cd /tmp/mhash-0.9.9.9
#./configure --prefix=/usr/web/mhash
#make && make install
//安装mcrypt
//加入临时变量到内存,重启后消失
#export LD_LIBRARY_PATH=/usr/web/mhash/lib:$LD_LIBRARY_PATH
#export LD_LIBRARY_PATH=/usr/web/libmcrypt/lib:$LD_LIBRARY_PATH
#export LDFLAGS="-L/usr/web/mhash/lib/ -I/usr/web/mhash/include/"
#export CFLAGS="-I/usr/web/mhash/include/"

#ln -s /usr/web/libmcrypt/bin/libmcrypt-config /usr/bin/libmcrypt-config
#cd /tmp/mcrypt-2.6.8
#./configure --prefix=/usr/web/mcrypt
#make && make install

//解决可能出现的libiconv错误
#cd /tmp/libiconv-1.14
#./configure --prefix=/usr/web/libiconv
#make && make install


//开始安装php  在./configure的时候带 --enable-fpm参数即可开启PHP-FPM  如何是apache需要--with-apxs2
#cd /tmp/php-5.4.14
#./configure --prefix=/usr/web/php \
--with-apxs2=/usr/web/apache/bin/apxs \
--with-config-file-path=/usr/web/php/etc \
--with-config-file-scan-dir=/etc/php.d \
--with-openssl \
--with-zlib \
--enable-bcmath \
--with-bz2 \
--with-curl \
--enable-ftp \
--with-gd \
--enable-gd-native-ttf \
--with-gettext \
--with-mhash=/usr/web/mhash \
--enable-mbstring \
--with-mcrypt=/usr/web/libmcrypt \
--enable-soap \
--enable-zip \
--with-iconv=/usr/web/libiconv \
--with-mysql=/usr/web/mysql \
--without-pear \
--enable-fpm

#make && make install
#cp php.ini-development /usr/web/php/etc/php.ini //复制配置文件php.ini  配置相应的参数
#vi /usr/web/php/etc/php.ini
short_open_tag = Off
error_reporting = E_ALL
display_errors = On
extension_dir = "/usr/web/php/lib/php/extensions/no-debug-non-zts-20100525/"
date.timezone=Asia/Shanghai

//以nginx的方式运行php  php-fpm
cp /usr/web/php/etc/php-fpm.conf.default /usr/web/php/etc/php-fpm.conf
vi etc/php-fpm.conf
修改
pid = /usr/web/php/var/run/php-fpm.pid
user = nginx
group = nginx

启动php-fpm
#/usr/web/php/sbin/php-fpm

php-fpm 关闭:
#kill -INT `cat /usr/web/php/var/run/php-fpm.pid`
php-fpm 重启:
#kill -USR2 `cat /usr/web/php/var/run/php-fpm.pid`
查看php-fpm进程数:
#ps aux | grep -c php-fpm


//以apache的方式运行PHP
//在/etc/httpd/conf/httpd.conf文件中加入php文件类型解析:以模块的方式加载
#vi /etc/httpd/conf/httpd.conf
PHPIniDir "/usr/web/php/lib/php.ini"
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
#service httpd restart  //重启httpd:

//以fast-cgi的方式加载
#FASTCGI
LoadModule fcgid_module modules/mod_fcgid.so
<IfModule mod_fcgid.c>
  AddHandler fcgid-script .fcgi .php
  FcgidInitialEnv PHPRC "D:/web/php"
  FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000
  FcgidMaxRequestsPerProcess 1000
  FcgidMaxProcesses 5
  FcgidIOTimeout 1200
  FcgidIdleTimeout 1200
  MaxRequestLen  15728640000
  FcgidWrapper "D:/web/php/php-cgi.exe" .php
  AddType application/x-httpd-php .php .html
</IfModule>







原文来自:系统架构-php安装与配置 http://www.redyun.net/technology/106.html

红云案例Case