Sep
24
Apache virtual hosts
September 24, 2010 | Leave a Comment
A single computer using apache web server can serve as multiple websites as if they are on separate hosts using the same concept. There are two ways to do it.
1. Creating an ip-based virtual host
2. Creating a name-based virtual host
For hosting multiple sites using ip addresses.
NameVirtualHost *
<VirtualHost *>
ServerAdmin mail@navindutta.com
DocumentRoot /home/navindutta/public_html
</VirtualHost>
<VirtualHost XXX.XXX.XXX.102>
ServerAdmin mail@navin.com
DocumentRoot /home/navin/public_html
</VirtualHost>
<VirtualHost XXX.XXX.XXX.103>
ServerAdmin mail@nave.com
DocumentRoot /home/nave/public_html
</VirtualHost>
For multiple web domains on the same computer
NameVirtualHost *
<VirtualHost *>
ServerName www.navindutta.com
ServerAlias navindutta.com
ServerAdmin mail@navindutta.com
DocumentRoot /home/navindutta/public_html
</VirtualHost>
<VirtualHost XXX.XXX.XXX.102>
ServerName www.navin.com
ServerAlias navin.com
ServerAdmin mail@navin.com
DocumentRoot /home/navin/public_html
</VirtualHost>
<VirtualHost XXX.XXX.XXX.103>
ServerName www.nave.com
ServerAlias nave.com
ServerAdmin mail@nave.com
DocumentRoot /home/nave/public_html
</VirtualHost>
May
23
Moodle mod rewrite
May 23, 2010 | 2 Comments
# Turn on rewrites.
RewriteEngine on
# Only apply to URLs on this domain
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
# Only apply to URLs that aren’t already under folder.
RewriteCond %{REQUEST_URI} !^/moodledir/
# Don’t apply to URLs that go to existing files or folders.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all those to insert /folder.
RewriteRule ^(.*)$ /moodledir/$1
# Also redirect the root folder.
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule ^(/)?$ moodledir/index.php [L]
Please note that this would work for all file url requests like view.php or index.php but not file.php requests. Another rule needs to be written for that.
May
23
Moodle migration in 3 steps
May 23, 2010 | Leave a Comment
1. Copy all files from the root of your Moodle installation and the moodle data directory.
#rsync -av -e ssh sourse/ username@newserver.com:/path/to/destination/
2. Dump your Moodle database and import it it new server
#mysqldump –allow-keywords –opt -uMySQL_USERNAME -pPASSWORD DATABASE | ssh username@newserver.com “mysql -uMySQL_USERNAME -pPASSWORD DATABASE”
3. Edit config.php to update all database access details, file paths and web location
Finally test everything and fix any link errors using http://newserver.com/moodle/admin/replace.php Thats all