Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

10.2 Configure the service file parameters


May 24, 2021 That's what Linux should learn



It is important to note that the installation and operation of the httpd service program described earlier is only some fur of the httpd service program, and we still have a long way to go. Configuring services in a Linux system is actually modifying the service's configuration files, so you also need to know where and for what purpose they are, as shown in Table 10-1.

Profiles in Tables 10-1 Linux

Service directory /etc/httpd master profile/etc/httpd/conf/httpd.conf website data directory/var/www/http://access log/var/log/httpd/access_log error log/var/log/httpd/error_log The main profile of the httpd service provider can be startled - there are 353 lines! I t's going to take at least a week to finish, right?! H owever, as long as you look closely, you will find that Miss Liu Wei is naughty here. Because in this configuration file, all lines that start with a hashtag are comment lines that are intended to describe the functionality of the httpd service program or a line of parameters, we don't need to look at them line by line.

In the main profile of the httpd service provider, there are three types of information: comment line information, global configuration, and zone configuration, as shown in Figure 10-4.

10.2 Configure the service file parameters

Figure 10-4 the composition of the main profile of the httpd service program

Readers have been exposed to comment information as they study Chapter 4, so here's a look at the difference between global configuration parameters and zone configuration parameters. A s the name implies, the global configuration parameter is a global configuration parameter, which can be used on all subsites, which not only guarantees normal access to the subsite, but also effectively reduces the amount of work written frequently to duplicate parameters. Z one configuration parameters are set individually for each individual subsite. J ust like in the university canteen to eat, the canteen responsible for cooking aunt first to each student to a bowl of standard-sized white rice (global configuration), and then according to the specific requirements of each student to put their want to eat the dishes (regional configuration). In the httpd service provider master profile, the most commonly used parameters are shown in Table 10-2.

Table 10-2 is the most commonly used parameter and description of its purpose when configuring the httpd service program

ServerRoot Service Directory ServerAdmin Administrator Mailbox User Run Service User Group Run Service User Group ServerName Website Server's domain name DocumentRoot Web Site Data Director Listen listens to the IP address and port number DirectoryIndex default index page Error Log File CustomLog Access Log File Timeout page timeout time, default 300 seconds from table 10-2 The DocumentRoot parameter is used to define the path to save the site data, the default value of which is to store the site data in the /var/www/html directory, while the current site's common first page name is index.html, so you can write a file to the /var/www/html directory to replace the default first page of the httpd service program, which will take effect immediately.

After doing the above, refresh the httpd service program in the Firefox browser and you can see that the content of the program's first page has changed, as shown in Figure 10-5.

[root@linuxprobe ~]# echo "Welcome To LinuxProbe.Com" > /var/www/html/index.html [root@linuxprobe ~]# firefox

10.2 Configure the service file parameters Figure 10-5 The contents of the first page of the httpd service program have been modified

After you finish this experiment, is there a burst of confidence?! B y default, site data is saved in the /var/www/html directory, and what if you want to modify the directory that holds the site data to /home/wwwroot directory? And look below.

Step 1: Create a saved directory of site data and create a home page file.

http root@linuxprobe://wwwroot.com/twitter.com/mkdir/home/wwwroot-root@linuxprobe-echo"The New Web Directory" /home/wwwroot/index.html Step 2: Open the main profile of the httpd service program and modify the parameter DocumentRoot for approximately line 119 to define the data save path for the site to /home/wwwroot, and also modify the path behind the parameterDirectory for approximately line 124 to define directory permissions to /home/wwwroot. Once the profile has been modified, you can save and exit.

[root@linuxprobe ~]# vim /etc/httpd/conf/httpd.conf .................. O mit some of the output information... 1 13 114 # 115 # DocumentRoot: The directory out of which you will serve your 116 # documents. B y default, all requests are taken from this directory, bu t 117 # symbolic links and aliases may be used to point to other locations. 1 18 # 119 DocumentRoot "/home/wwwroot" 120 121 # 122 # Relax access to content within /var/www. 1 23 # 124 <Directory "/home/wwwroot"> 125 AllowOverride None 126 # Allow open access: 127 Require all granted 128 </Directory> .................. O mit some of the output information... S tep root@linuxprobe 3: Restart the httpd service program and verify the effect, as shown in Figure 10-6 when the browser refreshes the page. S trange! W hy do I see the default home page of the httpd service? B y all accounts, the default home page of the httpd service program is displayed only if the site's first page file does not exist or if the user's permissions are insufficient. W hen we tried http://127.0.0.1/index.html the page, we found that it said "Forbidden, You don't have permission to access /index.html on this server." And that's exactly what SELinux is messing with.

[root@linuxprobe ~]# systemctl restart httpd [root@linuxprobe ~]# firefox

10.2 Configure the service file parameters

Figure 10-6 the default home page of the httpd service program