Start and Stop the apache service in Linux.
Author: Tyan
Blog: noahsnil.com | CSDN | short book
The Linux system used in this article is CentOS 7. The following describes how to start, disable, and set the apache service. Apache is generally installed by default in CentOS 7, and the service name ishttpd
.
1. install apache and view related configuration
# Apache installation command $ sudo yum install httpdLoaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfilePackage httpd-2.4.6-45.el7.centos.4.x86_64 already installed and latest versionNothing to do # view apache File Location $ 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
The Apache configuration file is located/etc/httpd/conf
The main configuration file is/etc/httpd/conf/httpd.conf
, Apache-related configuration information can be seen in this file.
2. Start and close the apache service
# Start the service $ sudo systemctl start httpd. service # view the service $ ps aux | grep httpdroot * 0.3 0.0 220444 4956? Ss/usr/sbin/httpd-DFOREGROUNDapache * 0.0 0.0 220444 2492? S/usr/sbin/httpd-DFOREGROUNDapache * 0.0 0.0 220444 2488? S/usr/sbin/httpd-DFOREGROUNDapache * 0.0 0.0 220444 2488? S/usr/sbin/httpd-DFOREGROUNDapache * 0.0 0.0 220444 2488? S/usr/sbin/httpd-DFOREGROUNDapache * 0.0 0.0 220444 2488? S/usr/sbin/httpd-DFOREGROUND # stop the service $ sudo systemctl stop httpd. service # restart the service $ sudo systemctl restart httpd. service
After starting the service, you can access the service through the IP address of the server on the Internet. You can see the following interface:
3. Configure the content that you can access externally
You can/var/www/html
Create a soft link, link to the content you want to access externally, and modify the permission to access the directory.
$ sudo ln -s your_path/images /var/www/html$ sudo chmod 755 images
Note:Make sure that all parent directories of images have permissions, and the path of images should be full path.
-
Top
-
0
-
Step on
-
0
View comments