- 筆者環(huán)境:CentOS6.9
1、切換root用戶
#su

image.png
2、Centos里面已經(jīng)封裝了apache的軟件,直接可以進(jìn)行安裝
#yum install httpd

image.png
3、接下來會出現(xiàn)Is this ok ?當(dāng)然是y,回車,繼續(xù)等待。

image.png
接下來會出現(xiàn)完成安裝的標(biāo)志:

image.png
4、配置開機啟動
#chkconfig –levels 235 httpd on

image.png
5、重啟apache
#/etc/init.d/httpd start

image.png
6、測試
切記一定要關(guān)閉防火墻,防火墻,防火墻?。?!
1) 即時生效,重啟后復(fù)原
開啟: service iptables start
關(guān)閉: service iptables stop
2) 永久性生效,需要重啟后才能生效
開啟: chkconfig iptables on
關(guān)閉: chkconfig iptables off
#service iptables stop

image.png
在瀏覽器中輸入:ip地址+端口號(默認(rèn)為80)

image.png
出現(xiàn)上面這個界面則安裝成功。
備注:在CentOS 中 Apache 的默認(rèn)根目錄是 /var/www/html,配置文件 /etc/httpd/conf/httpd.conf。其他配置存儲在 /etc/httpd/conf.d/ 目錄