Skip to content

Instantly share code, notes, and snippets.

@oimtrust
Last active June 20, 2020 00:03
Show Gist options
  • Save oimtrust/d9aabc8df1067256aef1afa5533d8d67 to your computer and use it in GitHub Desktop.
Save oimtrust/d9aabc8df1067256aef1afa5533d8d67 to your computer and use it in GitHub Desktop.
For create domain on apache2 ubuntu
## Set domain on site-available
`sudo nano /etc/apache2/sites-available/domain-name.test.conf`
and then, following this script like this (Laravel Project):
```
<VirtualHost *:80>
ServerName domain-name.test
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/domain-name/public
<Directory /var/www/html/domain-name>
Options FollowSymlinks Indexes
AllowOverride All
Allow from all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/pmanager-error.log
CustomLog ${APACHE_LOG_DIR}/pmanager-access.log combined
</VirtualHost>
```
next,
on windows : don't forget to set the domain.test like this :
update file : C:\Windows\System32\drivers\etc\hosts
`127.0.0.1 domain-name.test`
on linux :
`sudo nano /etc/hosts`
`sudo a2ensite domain-name.test` // for enabling domain
`sudo a2enmod rewrite` // for open access apache2 to folder project
don't forget to restart the apache2 :
`sudo service apache2 restart`
yay... Now, you can access the domain-name.test on your browser. swallaaa.....
1. sudo nano /etc/apache2/httpd.conf
2. Uncomment
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
3. sudo nano /etc/apache2/extra/httpd-vhosts.conf
Setup :
<VirtualHost *:80>
ServerName apple.com
ServerAlias www.apple.com
DocumentRoot "/Users/USERNAME/Sites/apple"
ErrorLog "/private/var/log/apache2/apple.com-error_log"
CustomLog "/private/var/log/apache2/apple.com-access_log" common
ServerAdmin [email protected]
</VirtualHost>
4. sudo nano /etc/hosts
127.0.0.1 apple.com www.apple.com
5. Resrtart apache : sudo apachectl restart
## Setup localhost
1. sudo nano /etc/apache2/extra/httpd-vhosts.conf
2. <VirtualHost *:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents/
</VirtualHost>
3. Restart apache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment