1,安装nginx、php、php-fpm
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
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;
}
...
}
# 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
sudo rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
sudo yum -y install nginxsudo 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