How to change the website folder in Apache2?

Asked

Viewed 2,234 times

-3

I need help setting up the LAMP. Everything is working perfectly. The things I’d like to change are mere whims, but I still find it interesting.

I would like to change the root directory. In case it is in: /var/www/html, i would like a directory in the documents, for example.

I would also like to remove the home screen:

Página padrão do Apache2 no Ubuntu

I need that in place of that home screen of localhost, the folder and files listing appeared. Nothing else. Example:

Listagem de pastas Apache

1 answer

1


To start I would like to change the folder destination, in case it is in: /var/www/html, I would like to put a directory in the documents for example

1) Open the configuration file for Apache:

/etc/apache2/apache2.conf

2) Find the settings DocumentRoot and change to the directory you want:

By default, it should look like this: DocumentRoot "/var/www/html"

3) Browse the directory configuration and change the path as well:

<Directory "/var/www/public_html">
...
</Directory>

I need that instead of this localhost home screen, a simple index would appear with the folders of my projects and nothing more.

4) In the directory configuration, look for the line Options and make sure you have Indexes:

Options Indexes FollowSymLinks

5) In the archive .htaccess there can be no option -Indexes, or will overwrite the directive in step "4)".

6) When you access the directories of Apache, automatically it fetches some default files in order to display to the user. So, you should "take" these files from the root directory since you want to list the contents of the folder. Usually these are the files:

index.php index2.php default.php index.html index.htm

You can configure this in the same file Apache that we changed earlier. Just look up the settings:

<IfModule dir_module>
    DirectoryIndex index.php index2.php default.php index.html index.htm
</IfModule>

I don’t recommend changing that, but if you like, it’s there!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.