Centos6.5 安装 Nginx + PHP

1,安装nginx、php、php-fpm

sudo rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm  

sudo yum -y install nginx  
sudo yum -y install php php-fpm  
sudo service php-fpm restart  
sudo service nginx restart  
sudo chkconfig --level 235 php-fpm on  
sudo chkconfig --level 235 nginx on

2.配置nginx和php-fpm的委托关系

sudo vim /etc/nginx/conf.d/default.conf

server {  
    listen       80;  
    server_name  localhost;  
  
    location / {  
        root   /usr/share/nginx/html;  
        index  index.html index.htm index.php;#遮脸添加index.php
    }  
  
    location ~ \.php$ {  
        root           /usr/share/nginx/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;  
    }
    ...
}

3. 配置iptables防火墙

sudo /etc/sysconfig/iptables

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT       #允许ssh
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT       #允许nginx
-A INPUT -m state --state NEW -m tcp -p tcp --dport 9000 -j ACCEPT  #允许php-fpm,切记,这个地方耽误了一个晚上
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值