CentOS 安裝 apache

來源:互聯網
上載者:User

標籤: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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.