Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

In this article we will set up a personal site under CentOS7 using HTTPD, the main program of the Apache hypertext transfer protocol (HTTP) server. HTTPD is designed to run as a standalone daemon that sets up a pool of child processes or threads to handle requests.

HTTPD installed

Mysql > install HTTPD;

rpm -qa | grep httpd
Copy the code

Mysql > install HTTPD; mysql > install HTTPD;

yum install httpd
Copy the code

At this point, use the RPM command again to check:This proves that we have installed successfully.

After the installation is complete, you can start the HTTPD service and execute the command:

systemctl start httpd
Copy the code

Note that this directive is from CentOS7. For CentOS6 and earlier versions, you need to use service to start the service:

service start httpd
Copy the code

After the service is enabled, you can run the netstat command to view the port number of the service.

netstat -apn | grep httpd
Copy the code

If the vm IP address is 80, run the ifconfig command to query the VM IP address.You can access it on Windows.http://192.168.190.134/Because the default browser is port 80, you can directly access the VM IP address:This step indicates that the HTTPD installation and service start are no problem.

Set up a personal site

After setting up HTTPD, let’s try to set up a personal site through HTTPD.

View the HTTPD configuration file:

cd /etc/httpd/conf
Copy the code

There is one in this directoryhttpd.confHTTPD configuration file: For the configuration of lines 119 and 124, whereDocumentRootRepresents the data directory for the web site, which defaults to/var/www/htmlAnd theDirectoryData directory is some permission control, if you want to customize it can also be modified.

/var/ WWW/HTML = /var/ WWW/HTML = /var/ WWW/HTML = /var/ WWW/HTML = /var/ WWW/HTML

cd /var/www/html
Copy the code

Now we can write a page:

vim index.html
Copy the code

Write a paragraph like this in the file and restart the HTTPD service:

systemctl restart httpd
Copy the code

Versions prior to CentOS7 require:

service restart httpd
Copy the code

After the restart, we directly access the address on Windows:http://192.168.190.134/index.html:This personal site is completed.