Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Jul 3, 2011

Centos Virtual hosting | Enabling multi apache hosting through 1 IP

OK, so now you decided to have one VPS, one IP, and many sites?
Cool, its very easy

First in the root folder, create your website folders, like you have 2 websites, so name them as site1.com and site2.com

So now you'll be having two website folders site1.com and site2.com in your root directory.

Now navigate to /etc/httpd/conf/ and start editing httpd.conf file,

At the end of the page, you will find a line, just like below

#NameVirtualHost *:80

Just uncomment that by removing # from it, So that it becomes like the below one:-

NameVirtualHost *:80

Then below their will be more lines which will be commented so uncomment them also, and make them look something like this

[php]
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/html/site1.com
ServerName site1.com
ErrorLog logs/site1-error_log
CustomLog logs/site1-access_log common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/html/site2.com
ServerName site2.com
ErrorLog logs/site2-error_log
CustomLog logs/site2-access_log common
</VirtualHost>
[/php]

Thats it, after this just restart your apache by the following command

[php]
service httpd restart
[/php]

Done,
You have successfully enabled multi-site or virtual hosting on apache Centos.

How to enable mod_rewrite in centos via SSH

This is a very simple question, but for beginners it is little bit difficult,
Now assuming that everything is installed, open the httpd conf file and start editing it,

You can find this file in

/etc/httpd/conf/httpd.conf

or directly edit it

[php]vi /etc/httpd/conf/httpd.conf[/php]
in this file search for Directory "/var/www/html" this can be on line 290-320

You will find a line of code, just like below

[php]AllowOveride None[/php]

Just change it to

[php]AllowOverideAll[/php]

Save it, and exit, mod_rewrite is enabled on your server.