This article will describe how to install Apache on Centos 6.5 and set it up for basic web services, insluding php (with apc), perl, cgi and ruby scripting.

Let’s install the pacgages first:

yum -y install httpd perl-CGI perl php php-mbstring php-pear php-pecl-apc ruby mod_ssl

Edit the /etc/httpd/conf.d/httpd.conf file, find the following lines nad change the parameters as suggested:

ServerTokens Prod
KeepAlive On
ServerAdmin [your email here]
Options FollowSymLinks ExecCGI
AllowOverride All
ServerName www.[]:80
DirectoryIndex index.html index.htm index.php index.cgi
ServerSignature Off
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
AddHandler cgi-script .cgi .pl .rb

Please keep in mind to replace the words in the [brackets] with proper paramets according to Your services.
Basically, this is it. Now we only need to restart the server and it’s good to go!

service httpd restart

I guess you will want the server to start on bootup:

chkconfig httpd on

 Seting up SSL for the server

There’s a little bit more tweaking as well as creating proper SSL certificates if we want Apache to serve https pages to. Since this also counts as basic functionality, let’s see how to work it out:

Edit /etc/httpd/conf.d/ssl.conf, look for the following lines and adjust them accordingly:

DocumentRoot "/var/www/html"
ServerName www.[]:443
SSLCertificateFile /etc/pki/tls/certs/server.crt
SSLCertificateKeyFile /etc/pki/tls/certs/server.key

Creating server certificates

cd /etc/pki/tls/certs
make server.key

and follow the questions.

openssl rsa -in server.key -out server.key 
make server.csr

At this point, be sure to enter Your server’s FQDN (www.[]) on the Common Name (CN) field!

openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 3650
chmod 400 server.*

And restart apache again:

service httpd restart

The server should be able to serve http as well as https pages.

One thought on “Apache – install a complete web server with SSL

  1. Hi! This is my first visit to your blog! We are a group of volunteers and starting a new project in a community in the same niche.
    Your blog provided us valuable information to work on. You have done a marvellous job!

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.