search

Home  >  Q&A  >  body text

Apache2.4+ configuration virtual host cannot access the directory

I originally wanted to configure a virtual host, but found that the apache version was 2.4. I had never used it before, and I didn’t know how to configure a virtual host. I tried a lot of methods on Baidu to no avail.

After I configured the virtual host, I kept accessing the root directory, which was not the result I wanted.

Website root directory:/var/www/html/

The directory I need to access:/var/www/html/web/tp5/public

Every time When I visit demo1.com, I always go to /var/www/html

and I have set up many methods to no avail!

----------My process is as follows-----

Server version: Apache/2.4.25 (Debian)

In When configuring the virtual host, I modified the configuration of /etc/hosts

127.0.0.1 www.demo1.com

and then opened vhost at the bottom of /etc/apache2/apache2.conf .

Finally, a new xx.conf file was created under /etc/apache2/sites-enabled/, with the following content:

<VirtualHost *:80>
ServerName www .demo1.com

ServerAdmin www.demo1.com

DocumentRoot "/var/www/html/web/tp5/public/"
ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>


# #Then visit and restart the apache2 service and open the

www.demo1.com URL.

Still visit /var/www/html/.


Please help! Thanks!

吾王。吾王。1794 days ago1238

reply all(2)I'll reply

  • 吾王。

    吾王。2020-03-02 13:38:18

    21312231kjljkllkj


    a is

    reply
    0
  • 吾王。

    吾王。2020-03-02 00:53:55

    To add, my apache2.4 does not have an httpd.conf file at all!

    reply
    0
  • Cancelreply