linux下安装nginx+php

参考:http://blog.csdn.net/ihelloworld/article/details/7029796

http://blog.chinaunix.net/uid-21374062-id-2951960.html
http://www.cnblogs.com/mchina/archive/2012/05/17/2507102.html
http://blog.sina.com.cn/s/blog_505bf9af010137gf.html

安装php:
yum install libxml2
yum install libxml2-devel -y
yum -y install freetype freetype-devel
yum -y install pcre*

 

1. 下载 php-5.2.13.tar.gz 和 php-5.2.13-fpm-0.5.13.diff.gz
2. 安装
# tar zxvf php-5.2.13.tar.gz
# gzip -cd php-5.2.13-fpm-0.5.13.diff.gz | patch -d php-5.2.13 -p1
# cd php-5.2.13
# ./configure --prefix=/usr/local/php --enable-fastcgi --enable-fpm --with-mysql=/usr/local/mysql
# make
# make install
# cp php.ini-dist /usr/local/lib/php.ini
启动php-cgi:
/usr/local/php/sbin/php-fpm start

1 安装nginx
#tar -zxvf nginx-0.8.33.tar.gz
#cd nginx-0.8.33
#./configure --prefix=/usr/local/nginx

(安装Nginx时报错
./configure: error: the HTTP rewrite module requires the PCRE library.
执行安装下面的yum
)

#yum -y install openssl openssl-devel
#yum -y install pcre-devel openssl openssl-devel

#./configure --prefix=/usr/local/nginx
#make
#make install

修改nginx.conf配置文件:
server {
listen 80;
server_name testlink.conversant.com.cn;
location / {
root /usr/local/nginx/html;
index index.php index.html index.htm;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/local/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
}

3
启动php-cgi:/usr/local/php/sbin/php-fpm start

(报错: (没有分组什么的...)
修改php-fpm.conf, 放开注释
<!-- <value name="user">nobody</value> -->
<!-- <value name="group">nobody</value> -->
)
4 启动nginx
/usr/local/nginx/sbin/nginx start
或者
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

5 关闭防火墙
1)永久性生效,重启后不会复原
开启: chkconfig iptables on 关闭: chkconfig iptables off
2)即时生效,重启后复原
开启: service iptables start 关闭: service iptables stop
3)查看防火墙状态
chkconfig iptables --list
[@more@]

 

posted on 2016-11-07 20:27  溪圆圆  阅读(470)  评论(0编辑  收藏  举报

导航