Showing posts with label APACHE. Show all posts
Showing posts with label APACHE. Show all posts

Sunday, October 14, 2012

Hosting multiple sites with Apache and Cent OS

Hosting multiple sites with Apache and Cent OS

Assuming you have the setup Apache Web Server& CentOS installed by default

DNS Settings
Make sure your domain name pointing to the VPS/Dedicated Hosting server IP.To check login to your domain control panel check the name server and A record (probably under DNS Settings/Manage DNS menu) entries are correct.

Server Settings
Open up your vps/dedicated server console using putty login to your server as root, find your httpd.conf file under /etc/httpd/conf folder, make a backup of httpd.conf before going to make any changes using cp command
  • Change your directory as shown in figure cd /etc/httpd/conf
  • Make backup of your httpd.conf by issuing command cp httpd.conf httpd.conf.bkup
  • Make sure backup done using list file commsnd ls

Two host multiple sites with apache we can use Name based virtual hosts, or IP based virtual hosts. Here i am going to use Name based virtual hosts

To enable multiple host support you must add, or uncomment, the following line in /etc/httpd/conf/httpd.conf:

NameVirtualHost *
This sets up Apache to accept the hosts.

If  i am going to host two sites named & then i have to create two directories under /var/www


then i have to change/add my httpd.conf should have the following lines 

<VirtualHost *:80>
    ServerAdmin root@localhost
    DocumentRoot "/var/www/"
    ServerName    ServerAlias
    ErrorLog logs/error_log
    CustomLog logs/sitea_access_log combined

<VirtualHost *:80>
    ServerAdmin root@localhost
    DocumentRoot "/var/www/"
    ErrorLog logs/in_error_log
    CustomLog logs/siteb_access_log combined

Restart the Apache HTTP Server daemon
service httpd restart

And you are done!.

Saturday, August 6, 2011

Enable HTTPS in Apache localhost using WAMP Server 2.1

Step 1

Download and install WAMP Server 2.1 from this link

Step 2
Generate a SSL certificate
Generate Key
Go to command prompt (Start Menu->Accessories->Command Prompt) type
Then type
Type C:\wamp\bin\apache\Apache2.2.17\bin
Go to C:\wamp\bin\apache\Apache2.2.17\bin and run the following command:

openssl req -new > webserver.csr

The command runs and prompts you to enter a PEM pass phrase and verify it. Write down the phrase because you will need it later.

It will then ask you to enter information that will be incorporated into your certificate request. When the command finishes, it has created several files, including privkey.pem, in


Remove Passphrase

Run the following command:
openssl rsa -in privkey.pem -out webserver.key

You will be prompted for the pass phrase from the previous step. The RSA key is written and the file webserver.key is now available in the folder.

Convert Into Signed Certificate

Run the following command to create a certificate which expires after one year:
openssl x509 -in webserver.csr -out webserver.cert -req -signkey webserver.key -days 365

Store Certificate Files
Create a folder ssl in  C:\wamp\bin\apache\Apache2.2.17\conf\  copy all generated files to ssl

Step 3

Modify conf/extra/httpd-ssl.conf
Change the following lines, adjusting the email address and the paths to your settings:

# General setup for the virtual host
SSLSessionCache "shmcb:C:/wamp/Apache/logs/ssl_scache(512000)"
SSLMutex default
# General setup for the virtual host

DocumentRoot "C:/wamp/www/"
ServerName localhost:443
ErrorLog "C:/wamp/logs/sslerror.log"
TransferLog "C:/wamp/logs/sslaccess.log"
SSLCertificateFile "conf/ssl/webserver.cert" 
SSLCertificateKeyFile "conf/ssl/webserver.key" 
CustomLog "C:/wamp/logs/sslrequest.log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

Modify httpd.Conf
Make sure your secure site is part of the virtual hosts in Apache:

# Secure (SSL/TLS) connections

#Include conf/extra/httpd-ssl.conf

Include conf/extra/httpd-ssl.conf

Step 4

Test https

Run httpd –t and make sure the syntax is OK.

Restart Apache.

Check that port 443 is open by running the following in the command prompt:

netstat -an | more
Test the https connection from your browser and hopefully it works

I found the article some where in WAMP forum and i made some changes to meet my requirement and fully functional, your feedback is welcome

The above method tested using WAMP Server 2.1 in windows 7, does not applies to wamp1.7