Created
August 20, 2018 19:46
-
-
Save erandirjunior/646ed74b979890e893bc8f1d2766d086 to your computer and use it in GitHub Desktop.
Criando um virtualhost no apache2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1º Crie a pasta do projeto. | |
ex: mkdir -p /var/www/html/example.com/public_html | |
1º Adicione permissão ao projeto | |
sudo chown -R $USER:$USER /var/www/example.com/public_html | |
3º Copie as configuraçes default para um arquivo com o nome do projeto | |
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf | |
4º Adicione essa configuração no arquivo .conf criado | |
<VirtualHost *:80> | |
ServerAdmin admin@example.com | |
ServerName example.com | |
ServerAlias www.example.com | |
DocumentRoot /var/www/example.com/public_html | |
ErrorLog ${APACHE_LOG_DIR}/error.log | |
CustomLog ${APACHE_LOG_DIR}/access.log combined | |
</VirtualHost> | |
5º Registre o virtualhost criado | |
sudo a2ensite example.com.conf | |
6º Recarregue o apache | |
sudo service apache2 reload | |
7º Desabilite o arquivo padrão | |
sudo a2dissite 000-default.conf | |
8º Reinicie o apache | |
sudo systemctl restart apache2 | |
9º Abra o arquivo /etc/hosts e adicione | |
127.0.1.1 erandir www.example.local www.plenus.local | |
10º Ative a opção AllowOverride em /etc/apache2/apache2.conf | |
<Directory /var/www/> | |
Options Indexes FollowSymLinks | |
AllowOverride All | |
Require all granted | |
</Directory> | |
11º Instale o modo de reescrita de url | |
sudo a2enmod rewrite && sudo service apache2 restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment