Red Hat 7 Apache installation and configuration

Apache service installation and configuration

Check whether Apache is installed in the host

rpm -qa | grep httpd

Install Apache command

yum -y install httpd

If installation error, please refer to Yum configuration installation https://blog.csdn.net/qq_39906884/article/details/84139028

View Apache status

systemctl status httpd.service

Before apache is opened
Start Apache
to check the status of Apache again

systemctl start httpd.service
systemctl status httpd.service

After apache is opened
Set Apache to start on boot

systemctl enable httpd.service

View the IP address of the machine

ifconfig 

Open the browser, enter the local ip address or localhost for the URL , and the following content shows that the Apache service is opened correctly
Insert picture description here

Open the firewall
Insert picture description here
http service and tick it
Insert picture description here
. Open the browser URL on another host and fill in the server ip address , you can view the same content as the server
Insert picture description here

File introduction

Apache server configuration file: /etc/httpd/conf/httpd.conf
Web site related file directory: /var/www
Web site root directory: /var/www/html
Web site log file directory: /var/log/httpd

Put the written index.html file in the root directory of the Web site: /var/www/html , and then enter the server IP in the browser to display the content of index.html

Set up personal website configuration

Modify the /etc/httpd/conf.d/userdir.conf file
to comment UserDir disabled on line 17, uncomment UserDir public_html on line 24, and
Insert picture description here
set SELinux to open access to the home directory (adding **-P** option represents permanent open)

setsebool -P httpd_enable_homedirs on

Switch users (using the dou user as an example),
create a public_html directory in the
home directory , and modify the permissions of the home directory

su - dou
chmod 755 -R /home/dou

Then restart the Apache service

systemctl restart httpd.service 

Enter the browser server IP / ~ dou , displayed in the web content index.html
Personal web site

Guess you like

Origin blog.csdn.net/qq_39906884/article/details/84138217