3

I have lost web browser access to my local PHP files. Fortunately phpmyadmin continues to work nicely.

When I type my server ip in Firefox I get:

Index of /
[ICO]   Name    Last modified   Size    Description
Apache/2.4.7 (Ubuntu) Server at localhost Port 80

as if /var/www was empty, which is not the case. I guess that Apache now has some other folder (or none at all) defined as root directory location, but I do not know how to fix it.

4 Answers 4

2

Your html or php files have to be moved to the new root:

/var/www/html/
1
  • 1
    Warning: In case of sites built with CVS like e.g. Wordpress, many information are saved inside the related databases. (Info not only of the web pages but even of the plugins). They should use relative path, but not always it is so. If you abruptly move them from a path to another I don't know how they can react after. (I find e.g. _wp_attachment_backup_sizes , recently_edited , latex_cache_path keys with absolute paths).
    – Hastur
    May 27, 2014 at 11:55
0

The new Apache default server location is /var/www/html. You can move all your files to the new directory or you can do the following on a terminal (as root):

    # cd /etc/apache2/sites-available
    # nano site1

Now, on nano paste the following:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName site1

    DocumentRoot /var/www/
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
</VirtualHost>

Save the file and run these commands (again as root):

    # a2ensite site
    # nano /etc/hosts

Now add this on the first line: 127.0.0.1 localhost site1

Save the file and reload Apache with this command (again as root):

    # /etc/init.d/apache2 reload

You should get a message telling you site1 is enabled. Now you can safely remove /var/www/html so you don't have an empty directory on your server:

    # rm /var/www/html/

Hope it helps, greetings.

1
  • Thank you so much. I have moved my files to /var/www/html, not only because it's much simpler but also because I thint it's better to do things in the default way unless you have a good reason for doing a different way. Unfortunately today I have a different problem, I cannot even start Apache, but I will post the issue as a new question.
    – Kolingua
    May 12, 2014 at 4:18
0

If you have virtual hosts defined in sites-available, probably hosted in distinct directories outside of /var/www/html, then you may have stumbled into the new configuration file naming convention.

Make sure your virtual host configuration files end in .conf.

Full explanation here: https://askubuntu.com/a/525120/1183

-1

Copy all the html files under /var/www/html. Now open the terminal and change the permission with sudo chmod -R 777 /var/www, now you wont get such errors when you run in firefox.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .