CentOS上yum安装Nginx服务
admin 发布于:2017-3-15 16:34 分类:系统架构 有 2182 人浏览,获得评论 0 条 标签: nginx yum CentOS
原因:由于centos没有默认的nginx软件包,需要启用REHL的附件包
rpm -Uvh http://download.Fedora.RedHat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
yum -y install nginx
设置开机启动
chkconfig nginx on
安装spawn-fcgi来运行php-cgi
yum install spawn-fcgi
下载spawn-fcgi 的启动脚本
wget http://bash.cyberciti.biz/dl/419.sh.zip
unzip 419.sh.zip
mv 419.sh /etc/init.d/php_cgi
chmod +x /etc/init.d/php_cgi
启动php_cgi
/etc/init.d/php_cgi start
查看进程
netstat -tulpn | grep :9000
若出现如下代表一切正常
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 4352/php-cgi
配置nginx(详细配置见nginx.conf详细说明)
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
查看phpinfo
phpinfo();
安装phpmyadmin
修改/var/lib/php/session的权限和nginx和php_cgi一致
chown -R www.www /var/lib/php/session