- install the dependent package
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
- get nginx package
- create user id for nginx
useradd -M -s /sbin/nologin nginx
- install nginx
tar xvzf nginx.1.8.1.tar.gz
cd nginx.1.8.1
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_module
make
make install
ln -s /usr/local/nginx/sbin/* /usr/local/sbin
- test nginx‘s configure file
将nginx.conf的user nobody 改为user nginx
nginx -t
- start nginx server
nginx
- configure firewall
iptables -F
iptables -p INPUT DROP
iptables -p FORWARD DROP
iptables -p OUTPUT ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT (注:这个规则,如果你把OUTPUT 设置成DROP的就要写上这一部,好多人都是在这里被坑了。)
若要永久生效,将changes写入/etc/sysconfig/iptables文件:
/etc/rc.d/init.d/iptables save
/etc/rc.d/init.d/iptables restart
- access to nginx from web client
时间: 2024-10-12 22:35:47