Ubuntu Server version of apache series common configuration and hidden version number IP, Port build service case

insert image description here

view version

The old one uses httpd -v and
the new one uses apache2 -v
insert image description here

configuration detection

The old httpd -t
new apachectl configtest
window uses apache is httpd -t
apachectl configtest in Linux

main configuration file

The previous version of apache was httpd and now it is changed to
httpd.conf in apache2 /etc/apache2/apache2.conf window

insert image description here

insert image description here
insert image description here

Modify the default website root directory

For security reasons, apache2 only allows the folders under /var/www and /usr/share to be accessed. If you want to specify other directories as the root directory of the website, you need to modify the configuration
file
vim /etc/apache2/apache2.conf
insert image description here

Configure virtual host

/etc/apache2/sites-enabled/000-default.conf.
insert image description here
The Apache virtual host configuration file is stored in the /etc/apache2/sites-available directory, and the standard naming is to use the domain name to name the configuration file

ln soft link

insert image description here
Apache will not read the configuration files in the /etc/apache2/sites-available folder by default, you need to link them to the /etc/apache2/sites-enabled folder, use a2ensite to create a link, and activate the virtual host configuration:

sudo a2ensite custom .conf as above 000-default.conf

Detect apache configuration

The apache used by windows is the opening, closing and restarting of services in
apachectl configtest in httpd -t Linux
insert image description here
insert image description here

1. service service name stop
2. service service name start
3. service service name restart

or

1. systemctl stop service name systemctl stop apache2
2. systemctl restart service name systemctl restart apache2 systemctl reload apache
3. systemctl start service name systemctl start apache2
4 systemctl status apache2
5 systemctl enable service name boot self-start
6. systemctl disable service name shutdown Self-start

Build Apache service

1 Create a project directory mkdir -p /CustZen/www

2 Create zen.html file by redirecting www directory

insert image description here

3 Configure Apache

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
Apache will not read the configuration files in the /etc/apache2/sites-available folder by default, you need to link them to the /etc/apache2/sites-enabled folder, use a2ensite to create a link, and activate the virtual host configuration:

1 Use ln -s soft link
2 a2ensite This apache's own method does not need to consider the directory, it is written in the script
insert image description here

Default page index.html index.php etc.

insert image description here
insert image description here
security.conf
insert image description here
insert image description here

sudo vim /etc/apache2/conf-avalilable/security.conf

insert image description here
insert image description here
insert image description here

Note to restart the Apache service
systemctl reload apache2

insert image description here
insert image description here

modify default page

insert image description here
insert image description here
insert image description here

****
Note that the higher the DirectoryIndex, the higher the priority
insert image description here

insert image description here

Guess you like

Origin blog.csdn.net/u013400314/article/details/131976919