I constantly forget how to do this. I decided to ask a question here so that I could find it later.
How do i do:
sudo gedit / etc / hosts
I add a line in the opened file
127.0.0.1 test.loc www.test.loc
we save, further:
sudo gedit /etc/apache2/conf.d/custom/vhosts
add the following
<VirtualHost *:80>ServerName test.locServerAlias test.locDocumentRoot "/home/www-data/www/test/www"ScriptAlias /cgi/ "/home/www-data/www/test/cgi-bin/"ErrorLog /home/www-data/www/test/error.logCustomLog /home/www-data/www/test/access.log common</VirtualHost> I create in "/ home / www-data / www" "/ home / www-data / www / test / www" with 777 rights as a result of typing in the browser http: //www.test.loc/ I have to go to the page
/home/www-data/www/test/www/index.php
but apparently I'm missing something, because another page opens.
Here is what I had in vhosts:
<VirtualHost *:80>ServerName test.locServerAlias test.locDocumentRoot "/home/www-data/www/test/www"ScriptAlias /cgi/ "/home/www-data/www/test/cgi-bin/"ErrorLog /home/www-data/www/test/error.logCustomLog /home/www-data/www/test/access.log common</VirtualHost> and hosts:
127.0.0.1 localhost127.0.1.1 alexander-A17127.0.0.1 test.loc www.test.loc Everything that does not work is redirected to skaz-gorod.loc (the address does not change in the address bar), what am I doing wrong?
of the www-data user added a user to the group (which is not safe but I'm not afraid :)) I finished the file with:
That's what I got in vhosts:
<VirtualHost 127.0.0.5>ServerName test.locServerAlias test.locDocumentRoot "/home/www-data/www/test/www"ScriptAlias /cgi/ "/home/www-data/www/test/cgi-bin/"ErrorLog /home/www-data/www/test/error.logCustomLog /home/www-data/www/test/access.log common</VirtualHost> and hosts:
127.0.0.1 localhost127.0.1.1 alexander-A17127.0.0.5 test.loc www.test.loc after the site opened with an error:
Internal Server ErrorThe server encountered an internal error or misconfiguration and wasunable to complete your request.
Please contact the server administrator, [no address given] andYou couldn’t have caused any error.
More information about this error may be available in the server errorlog.
Apache/2.2.22 (Ubuntu) Server at 127.0.0.5 Port 80
and in the logs wrote:
[alert] [client 127.0.0.1] /home/www-data/www/test/www/.htaccess:Invalid command 'RewriteEngine', perhaps misspelled or not defined in the serverconfiguration
The error says that the Apache rewrite module is not enabled.
It is solved simply:
sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart
URA EARNED!