*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
:wq #保存退出
#重启防火墙使配置生效
[root@centos ~]# systemctl restart iptables.service
#设置防火墙开机启动
[root@centos ~]# systemctl enable iptables.service
4.9 作为服务,开机后启动
[root@centos ~]# vim /usr/lib/systemd/system/tengine.service
增加以下内容
[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/opt/nginx/logs/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
:wq 保存退出
[root@centos ~]# systemctl stop tengine
[root@centos ~]# systemctl start tengine
[root@centos ~]# systemctl reload tengine
[root@centos ~]# systemctl enable tengine
[root@centos ~]# shutdown -r now
相关阅读:
Tengine动态开启模块试用