Nginx 0.7.x + PHP5.2.9 + FastCGI配置过程

如今Nginx这款WEB服务器是相当火呀.据说是可以并发3万连接数以上,性能是apache的十倍,但各有各的好处,apache在各种功能上还是比较全的,下面开始讲解Nginx的安装配置:  (本安装是在Centos 5.2系统中安装的)
下载软件,直接到我们的张宴大师博客中去下载吧!
引用
wget http://blog.s135.com/soft/linux/nginx_php/nginx/nginx-0.7.59.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/php/php-5.2.9.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/phpfpm/php-5.2.9-fpm-0.5.10.diff.gz
wget http://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.1.35.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/libiconv/libiconv-1.13.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/memcache/memcache-2.2.5.tgz
wget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/pcre/pcre-7.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/eaccelerator/eaccelerator-0.9.5.3.tar.bz2
wget http://blog.s135.com/soft/linux/nginx_php/pdo/PDO_MYSQL-1.0.2.tgz
wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/imagick/imagick-2.2.2.tgz

1:首先得安装软件安装的依懒库,直接用YUM在线安装
引用
yum install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
 
引用
tar zxvf libiconv-1.13.tar.gz
cd libiconv-1.13/
./configure --prefix=/usr/local
make
make install
 
引用
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
 
引用
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
 
引用
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
./configure
make
make install
 
引用
添加系统自动搜索的库路径:
vi /etc/ld.so.conf
添加以下两个路径:
/usr/lib
/usr/local/lib
保存退出!
使之立即生效
/sbin/ldconfig

下面MYSQL数据库我就不讲解安装了,网上一搜一大把的方法

引用
tar zxvf php-5.2.9.tar.gz
gzip -cd php-5.2.9-fpm-0.5.10.diff.gz | patch -d php-5.2.9 -p1   
cd php-5.2.9/
./configure --prefix=/usr/loca/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip
make
make install
cp php.ini-dist /usr/local/php/etc/php.ini
tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
 
引用
tar jxvf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3/
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make
make install
 
引用
tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
make
make install
 
引用
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make
make install
 
引用
tar zxvf imagick-2.2.2.tgz
cd imagick-2.2.2/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install

配置eAccelerator加速器
引用
mkdir /tmp/eaccelerator   创建临时文件夹
vi /usr/local/php/etc/php.ini
在[Zend]下面加入:
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="300"
eaccelerator.shm_prune_period="120"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

配置php-fpm文件,php-fpm文件是PHP的一个FastCGI管理补丁,安装完PHP后,会在/usr/local/php/sbin下会有个php-fpm文件,启动php-fpm的命令如下:
引用
/usr/local/php/sbin/php-fpm start
修改php-fpm的配置文件
vi /usr/local/php/etc/php-fpm.conf 找到Unix user of processes这行,把下面用户和组的注释都去掉.
下面开始安装Nginx
引用
tar zxvf pcre-7.8.tar.gz   这是个正规表达式的软件
cd pcre-7.8/
./configure
make && make install
 
 
引用
tar zxvf nginx-0.7.59.tar.gz
cd nginx-0.7.59/
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install

vi /usr/local/nginx/conf/nginx.conf
找到location ~ \.php$ { 这行把下面几行的注释都行掉,再把scripts这个参数改成你的网站文档存放目录,比如我这是/www目录
保存退出
启动Nginx
/usr/local/nginx/sbin/nginx
重启的命令是:kill -HUP `cat /usr/local/nginx/nginx.pid`

本文出自 “木泉知识库” 博客,转载请与作者联系!

你可能感兴趣的:(PHP,nginx,mysql,Zend,休闲)