標籤:centos 安裝 apache
apache在centos7中是Apache HTTP server。如下對httpd的解釋就是Apache HTTP Server。所以想安裝apache其實是要安裝httpd。
[[email protected] ~]# yum install httpd #安裝
[[email protected] ~]# chkconfig httpd on #設定開機啟動
Note: Forwarding request to ‘systemctl enable httpd.service‘.
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[[email protected] ~]#
[[email protected] ~]# service httpd start #啟動服務
Redirecting to /bin/systemctl start httpd.service
[[email protected] ~]#
[[email protected] ~]# netstat -ntlp #查看 80 連接埠是否啟動
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 958/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1456/master
tcp6 0 0 :::80 :::* LISTEN 2363/httpd
tcp6 0 0 :::22 :::* LISTEN 958/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1456/master
[[email protected] ~]#
到這裡時,在本機是可以訪問 web 的,但其他區域網路電腦不可以訪問 web,此原因是防火牆導致:
[[email protected] ~]# curl 127.0.0.1
開啟防火牆:centos的防火牆改成了firewall,不再叫iptables,開放連接埠的方法如下
[[email protected] ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent
success
[[email protected] ~]#
命令含義:
--zone #範圍
--add-port=80/tcp #添加連接埠,格式為:連接埠/通訊協議
--permanent #永久生效,沒有此參數重啟後失效
重啟防火牆命令:
[[email protected] ~]# systemctl restart firewalld.service
[[email protected] ~]# systemctl stop firewalld.service
[[email protected] ~]# systemctl start firewalld.service
到這裡,區域網路電腦就可以訪問 web了
本文出自 “春去春來” 部落格,請務必保留此出處http://yaoshixian.blog.51cto.com/754237/1959021
CentOS 安裝 apache