Showing posts with label apache. Show all posts
Showing posts with label apache. Show all posts

Friday, July 15, 2011

Make current directory DocumentRoot in apache

Create the following bash file and put it in the directory you want to use as apache root directory

#!/bin/sh
sed 's!\DocumentRoot .*!DocumentRoot '"`pwd`"'!' /etc/apache2/sites-available/default > default
sudo mv default  /etc/apache2/sites-available/
sudo /etc/init.d/apache2 restart

Thursday, December 2, 2010

Configure apache to host domain and subdomain - ubuntu

1. Copy default configuration file

cd /etc/apache2/sites-available/
cp default mydomain.co.il [or mysubdomain.mydomain.co.il]

2. Disable default site

sudo a2dissite default
sudo /etc/init.d/apache2 reload
sudo rm /etc/apache2/sites-available/default

3. Edit mysubdomain.mydomain.co.il the to look like this:
<VirtualHost *:80>
ServerAdmin siteadmin@mydomain
ServerName mysubdomain.mydomain.co.il
DocumentRoot /var/www/mysubdomain/
<directory>
   Options Indexes FollowSymLinks MultiViews
   AllowOverride All
   Order allow,deny
   allow from all
</directory>

...
...
</VirtualHost>






4. Create link in site-enabled folder and reload apache configuration file

sudo a2ensite mysubdomain.mydomain.co.il
sudo /etc/init.d/apache2 reload

5. Repeat for every domain/subdomain.

Based on http://phobienbuon.com/archives/202
Tested on Ubuntu 10.4