Configuration vhost ubuntu/centos

Create a vhost for this directory in Apache configuration directory on vhost normally located in

  • /etc/apache2/sites-available/

In this directory create a file with the name of your domain

  • /etc/apache2/sites-available/YOURDOMAIN.COM.conf

This file must have a content similar to this:
```ServerAdmin webmaster@localhost
ServerName YOURDOMAIN.COM
ServerAlias www.YOURDOMAIN.COM

DocumentRoot /var/www/html/xxxxx-xxxxx-xxxxx-xxxxx-xxxxx/web
DirectoryIndex app.php index.html


<Directory /var/www/html/xxxxx-xxxxx-xxxxx-xxxxx-xxxxx/web>
        AllowOverride None
        Allow from All


        <IfModule mod_rewrite.c>
        Options -MultiViews
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ app.php [QSA,L]
        </IfModule>


</Directory>
ErrorLog ${APACHE_LOG_DIR}/YOURDOMAIN.COM-error.log
CustomLog ${APACHE_LOG_DIR}/YOURDOMAIN.COM-access.log combined

</VirtualHost>```

After you create the file and save you must activate the module rewrite

  • a2enmod rewrite

Restart Apache as root user

Vhost Centos

``` ServerAdmin webmaster@localhost
ServerName YOURDOMAIN.COM
ServerAlias www.YOURDOMAIN.COM

DocumentRoot /var/www/html/xxxxx-xxxxx-xxxxx-xxxxx-xxxxx/web
DirectoryIndex app.php index.html


<Directory /var/www/html/xxxxx-xxxxx-xxxxx-xxxxx-xxxxx/web>
        AllowOverride None
        Allow from All


        <IfModule mod_rewrite.c>
        Options -MultiViews
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ app.php [QSA,L]
        </IfModule>


</Directory>

</VirtualHost>```

To modify the file, you can use tools like vi or nano.

Note: Remember to change “YOURDOMAIN.COM” and "xxxxx-xxxxx-xxxxx-xxxxx-xxxxx" with the corresponding values, your domain and name of the directory that has been unpacked in a previous step. In addition the domain must be pointing to the ip of your VPS, this can be done from your domain administrator, example of domain administrator: godaddy

After you create the file and save you must activate the module rewrite

First, type the following in your ssh terminal:

  • httpd -V

This displays the following lines:

  • -D HTTPD_ROOT="/etc/httpd"

  • -D SERVER_CONFIG_FILE="conf/httpd.conf"

The output of the HTTPD_ROOT and the output of SERVER_CONFIG_FILE together give the location of the Apache2 httpd.conf. In this case is located in:

  • /etc/httpd/conf/httpd.conf

The modules directory is:

  • /etc/httpd/modules

Check if mod_rewrite exists as a module.

  • ls /etc/httpd/modules | grep mod_rewrite

If it exist the following will be displayed, otherwise nothing will be showed:

  • mod_rewrite.so

If mod_rewrite.so is showing, you already have the module and you only need to load it

Now use the following command and confirm if mod_rewrite is loaded and activated:

  • grep -i LoadModule /etc/httpd/conf/httpd.conf | grep rewrite

This will display something like the following:

  • LoadModule rewrite_module modules/mod_rewrite.so

If it shows as above, mod_rewrite has been activated.

If the following is displayed, remove the # of the beginning:

#LoadModule rewrite_module modules/mod_rewrite.so

restart apache

  • apachectl restart or:

  • /sbin/service httpd restart

results matching ""

    No results matching ""