文章作者:Tyan
博客:noahsnail.com ?|? CSDN ?|? 簡書
本文使用的Linux系統(tǒng)為CentOS 7灭将,下面將介紹apache服務的啟動嫂沉、關閉與設置蹬屹。apache在CentOS 7中一般是默認安裝的驾锰,而且服務名字為httpd
卸留。
1. 安裝apache及查看相關配置
# apache安裝命令
$ sudo yum install httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package httpd-2.4.6-45.el7.centos.4.x86_64 already installed and latest version
Nothing to do
# 查看apache文件的位置
$ sudo find / -name httpd
/run/httpd
/etc/logrotate.d/httpd
/etc/sysconfig/httpd
/etc/httpd
/var/log/httpd
/var/cache/httpd
/usr/sbin/httpd
/usr/lib64/httpd
/usr/share/httpd
/usr/include/httpd
/usr/libexec/initscripts/legacy-actions/httpd
Apache配置文件位于/etc/httpd/conf
,主要的配置文件是/etc/httpd/conf/httpd.conf
, apache相關的配置信息都可以在這個文件中看到椭豫。
2. apache服務的啟動與關閉
# 啟動服務
$ sudo systemctl start httpd.service
# 查看服務
$ ps aux | grep httpd
root * 0.3 0.0 220444 4956 ? Ss 15:46 0:00 /usr/sbin/httpd -DFOREGROUND
apache * 0.0 0.0 220444 2492 ? S 15:46 0:00 /usr/sbin/httpd -DFOREGROUND
apache * 0.0 0.0 220444 2488 ? S 15:46 0:00 /usr/sbin/httpd -DFOREGROUND
apache * 0.0 0.0 220444 2488 ? S 15:46 0:00 /usr/sbin/httpd -DFOREGROUND
apache * 0.0 0.0 220444 2488 ? S 15:46 0:00 /usr/sbin/httpd -DFOREGROUND
apache * 0.0 0.0 220444 2488 ? S 15:46 0:00 /usr/sbin/httpd -DFOREGROUND
# 停止服務
$ sudo systemctl stop httpd.service
# 重啟服務
$ sudo systemctl restart httpd.service
啟動服務后耻瑟,可以在外網通過服務器的IP地址訪問∩退郑可以看到如下界面:
3. 配置自己可以在外部訪問的內容
可以在/var/www/html
下創(chuàng)建一個軟鏈接喳整,鏈接到你想要在外部訪問的內容,同時要修改要訪問目錄的權限裸扶。
$ sudo ln -s images your_directory
$ sudo chmod 755 your_directory