端口的查询与开启

CentOS 7 默认没有使用iptables,所以通过编辑iptables的配置文件来开启80端口是不可以的
CentOS 7 采用了 firewalld 防火墙

如要查询是否开启80端口则:
[root@www ~]# firewall-cmd --query-port=80/tcp
no
显然80端口没有开启

下面我们开启80端口:

[root@joe-pc ~]# firewall-cmd --add-port=80/tcp
success

[root@joe-pc ~]# ps aux | grep httpd
root 7579 0.0 0.0 3872 656 pts/1 S+ 17:48 0:00 grep httpd
apache 12229 0.0 0.3 32940 7108 ? S 04:03 0:00 /usr/sbin/httpd
apache 12230 0.0 0.3 33076 7680 ? S 04:03 0:00 /usr/sbin/httpd
apache 12231 0.0 0.3 33076 7820 ? S 04:03 0:00 /usr/sbin/httpd
apache 12232 0.0 0.3 33076 7176 ? S 04:03 0:00 /usr/sbin/httpd

[root@joe-pc ~]#netstat -anp | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 12229/httpd 
tcp 0 0 xxx.xxx.xxx.xxx:48500 xxx.xxx.xxx.xxx:80 ESTABLISHED 1827/AliYunDun

服务的开启,关闭,状态

systemctl start httpd.service #启动

systemctl stop httpd.service #停止

systemctl restart httpd.service #重启

第二、设置开机启动/关闭

systemctl enable httpd.service #开机启动

systemctl disable httpd.service #开机不启动

第三、检查httpd状态

systemctl status httpd.service

关于centOS7.2的防火墙

说明:Centos7 下默认的防火墙是 Firewall,替代了之前的 iptables,Firewall 有图形界面管理和命令行管理两种方式,本文简要介绍命令 行Firewall 的使用。

进入系统之后,Centos7 默认是已安装了 Firewall,但是没有启动的,所以需要先启动下 Firewall,同时设置开机自启动

systemctl start firewalld ##启动Firewall

systemctl enable firewalld.service ##设置开机自启动

ln -s '/usr/lib/systemd/system/firewalld.service' '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'
ln -s '/usr/lib/systemd/system/firewalld.service' '/etc/systemd/system/basic.target.wants/firewalld.service'

firewall-cmd --state ##查看防火墙状态,是否是running
firewall-cmd --reload ##重新载入配置,比如添加规则之后,需要执行此命令
firewall-cmd --get-zones ##列出支持的zone
firewall-cmd --get-services ##列出支持的服务,在列表中的服务是放行的
firewall-cmd --query-service ftp ##查看ftp服务是否支持,返回yes或者no
firewall-cmd --add-service=ftp ##临时开放ftp服务
firewall-cmd --add-service=ftp --permanent ##永久开放ftp服务
firewall-cmd --remove-service=ftp --permanent ##永久移除ftp服务
firewall-cmd --add-port=80/tcp --permanent ##永久添加80端口
iptables -L -n ##查看规则,这个命令是和iptables的相同的
man firewall-cmd ##查看帮助

最新文章

  1. 在js中怎么样选择互斥的相邻元素
  2. 用python实现两个文本合并
  3. CBO学习----03--选择率(Selectivity)
  4. Tab页签切换
  5. kinect for windows - 环境搭建
  6. UVA 718 - Skyscraper Floors(数论)
  7. Linux查看端口被哪个进程占用
  8. ELK搭建elasticsearch常见报错
  9. 3.docker基础架构
  10. 关于 ul 嵌套 li 并且再嵌套 a 的 BUG
  11. 手机调试 ---- Node启动服务
  12. codeforces水题100道 第二十一题 Codeforces Beta Round #65 (Div. 2) A. Way Too Long Words (strings)
  13. linux vnc 安装
  14. 可调试Windows服务框架
  15. 下载MySQL的各个历史版本
  16. Review notes
  17. Node.js 向一个文件添加内容
  18. [Python] Send emails to the recepients specified in Message["CC"]
  19. automaticallyAdjustsScrollViewInsets(UITextView文字顶部留有空白)
  20. 在Magento中用MySQL模拟队列发送电子邮件

热门文章

  1. Response乱码时的处理方法
  2. JsonArray和JsonObject遍历方法
  3. fedora20 安装搜狗输入法及各种问题的解决
  4. DOM-----style属性对照表
  5. 有哪些关于 Python 的技术博客?
  6. django框架(Model)
  7. javaScript手记(01)
  8. chrome开发工具指南(一)
  9. ROS学习记录(一)————创建简单的机器人模型smartcar
  10. ASP.NET Excel导入Sql Server数据库(转)