Linux下啟動和停止apache服務


本文使用的Linux系統為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
復制代碼

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM