Announcement

Collapse
No announcement yet.

apache2 root directory confusion [LAMP]

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    apache2 root directory confusion [LAMP]

    Hi,

    Before 14.04 the root directory for apache web server was /var/www

    From 14.04 this changed to /var/www/html - I believe the change was made for security reasons.

    So you should now place your files in /var/www/html - for example for your local website.

    To confirm this I can see that the configuration file on my system (/etc/apache2/sites-available/000-default.conf) has the following entry to set the root directory:

    DocumentRoot /var/www/html

    I use a standard script to display information on my PHP installation which according to online guides should now be placed in /var/www/html but when I run the script with http://localhost/info.php it doesn't work. Instead I have to use http://localhost/html/info.php.

    So it seems there is a legacy setting on my system which is overriding the apache configuration file mentioned above.

    Does anyone know what or where this file is located so I can update it so that my system is configured correctly? And just in case anyone asks, I have tried re-starting the apache server.

    Thanks in advance,

    Nick
    Kubuntu 20.04(AMD64)/KDE 5

    #2
    My localhost apache configuration matches yours, and phpinfo.php in /var/www/html does work as expected when called by:

    http://localhost/phpinfo.php

    Do you have a website installed yet?
    If so, can I assume that your website code in /var/www/html does work?
    If not then check these:

    Check your /etc/hosts file. The first line in my version is:
    Code:
    127.0.0.1  localhost
    ...
    next, check for the linked file:

    /etc/apache2/sites-enabled/000-default.conf

    which points at the real file in ../sites-available

    Are you using any virtual hosts? I have several, all working and located in sub-directories of /var/www/html
    Kubuntu 24.11 64bit under Kernel 6.12.1, Hp Pavilion, 6MB ram. Stay away from all things Google...

    Comment


      #3
      Hi,

      Thanks for the reply.

      Firstly yes, website code in /var/www/html does work and my hosts file is configured correctly.

      However there is no linked file in:

      /etc/apache2/sites-enabled/000-default.conf

      Is this important - should I create one?

      I'm not using virtual hosts.

      Thanks again.
      Kubuntu 20.04(AMD64)/KDE 5

      Comment


        #4
        I don't know if it will help, but you can create the linked (symlink) file "000-default.conf" in /etc/apache2/sites-enabled/

        This is the manpage doc on how to do this. Alternatively, I use Dolphin to simply create (drag, drop) a link to the real file and then restart xserver (or reboot the computer).

        http://manpages.ubuntu.com/manpages/...2ensite.8.html

        Try creating just the linked file to 000-default.conf, restart and test your site.

        My preference is to use virtual hosts, to support multiple sites, but that is NOT strictly necessary. I do think the default file should be linked in sites-enabled.
        Kubuntu 24.11 64bit under Kernel 6.12.1, Hp Pavilion, 6MB ram. Stay away from all things Google...

        Comment

        Working...
        X