欢迎来到本站,下面是搭建Nginx0.5.33+PHP5.2.5(FastCGI)的完整攻略:
yum install -y gcc automake autoconf libtool gcc-c++ pcre-devel zlib-devel openssl-devel
wget http://nginx.org/download/nginx-0.5.33.tar.gz
tar -zxvf nginx-0.5.33.tar.gz
cd nginx-0.5.33
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
/usr/local/nginx/sbin/nginx -t
如果输出信息中没有错误提示,则说明Nginx已经安装成功。
wget https://www.php.net/distributions/php-5.2.5.tar.gz
tar -zxvf php-5.2.5.tar.gz
cd php-5.2.5
./configure --prefix=/usr/local/php --with-mysql --with-pdo-mysql --with-mysqli --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-magic-quotes --enable-safe-mode --enable-sockets --enable-bcmath --enable-mbstring --with-mcrypt --with-curl --with-gd --with-openssl --with-mhash --enable-pcntl --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-maintainer-zts --enable-ctype --with-pcre-dir=/usr/local/pcre --with-gettext --with-fastcgi --with-fpm
make && make install
/usr/local/php/bin/php -v
如果输出PHP的版本信息,则说明PHP已经安装成功。
vim /usr/local/nginx/conf/nginx.conf
在http块内部添加如下代码:
server {
listen 80;
server_name localhost;
root /usr/local/nginx/html;
index index.php index.html index.htm;
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
}
vim /usr/local/php/etc/php.ini
修改如下配置:
cgi.fix_pathinfo = 0
最后重启Nginx和PHP,使配置生效:
/usr/local/nginx/sbin/nginx -s reload
killall php-cgi
/usr/local/php/sbin/php-fpm start
以下分别是两个使用Nginx0.5.33+PHP5.2.5(FastCGI)搭建的网站实例:
以上就是使用Nginx0.5.33+PHP5.2.5(FastCGI)搭建胜过Apache10倍的Web服务器的完整攻略,如果您有疑问,欢迎随时联系我。
本文链接:http://task.lmcjl.com/news/18955.html