For Apache, you only need to modify the apache configuration file.
For Apache, you only need to modify the apache configuration file/etc/httpd/conf/httpd. conf.
There is an example file in it. you only need to configure it.
#
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot/www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#
You can add at the bottom of httpd. conf by referring to my configuration:
NameVirtualHost *: 80
ServerAdmin admin@example.com
DocumentRoot/var/www/html
ServerName www.phpddt.com
# ErrorLog/var/log/httpd/phpddt/error_log
# Note: Here I set the daily production log
ErrorLog "| rotatelogs/var/log/httpd/phpddt/error_log % Y _ % m _ % d. log 86400 480"
# CustomLog/var/log/httpd/phpddt/access_log common
CustomLog "| rotatelogs/var/log/httpd/phpddt/access_log % Y _ % m _ % d. log 86400 480" common
ServerAdmin admin@example.com
DocumentRoot/var/www/html/blog
ServerName blog.phpddt.com
ErrorLog/var/log/httpd/blog/error_log
CustomLog/var/log/httpd/blog/access_log common
As shown above, I have configured two virtual hosts with the domain names www.phpddt.com blog.phpddt.com respectively.
Note: service httpd restart takes effect only after apache is restarted)
If the reader does not understand anything, I strongly recommend other related articles:
1. you do not need to configure a VM to add a second-level domain name to your website.
2. add a second-level domain name through url Forwarding
3. how does apache generate independent log files every day?