Apache Ubuntu Vhost
Apache
Install Apache in Ubuntu
- Apache 2.4
- Ubuntu 15.10
sudo apt-get install apache2
Start Apache as service
Stop Apache
Restart Apache
vhost
Let’s make vhost
- Host kiririn.com
- DocumentRoot /var/www/html/kiririn.com/public_html
1. Create vhost directory and change directory
sudo mkdir -p /var/www/html/kirirn.com/public_html sudo chown -R $USER:$USER /var/www/html/kirirn.com/public_html
create index.html for test
2. Copy configuration template file for new configuration file and edit
We have nice example for configuration file, we can copy this and edit for our customization
sudo cp /etc/apache2/site-available/000-default.com.conf /etc/apache2/site-available/kiririn.com.conf
We can create
Edit following(kiririn.com.conf)
<VirtualHost *:80> ServerAdmin webmaster@kiririn.com ServerName kiririn.com ServerAlias www.kiririn.com DocumentRoot /var/www/html/kirirn.com/public_html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APCHE_lOG_DIR}/access.log combined </VirtualHost>
vhost configuration file location is /etc/apache2/site-available/
Actual file directory is site-enabled, apache2.conf reads this directory
We create symlink to use a2ensite. By making symlink, apache2.conf reads site-available
3. Deactivaete default, and Activate new
cd /etc/apache2/site-available sudo a2dissite 000-default.conf sudo a2ensite kiririn.com.conf
If you change apache configuration, we can check configuration file style
apache2ctl -t
4. Restart apache
sudo service apache restart
We can access http://kiririn.com