Centos 6 Webserver

From vpsget wiki
Revision as of 20:33, 31 October 2013 by Ndi (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

In this article we will install some software that is useful on a webserver based on Centos 6.
For the beginning let us install some packages that will be useful later:

yum install nano wget fetchmail zip unzip bzip2 nmap openssl lynx fileutils ncftp gcc gcc-c++ gd-devel
yum update


yum install httpd

Set Apache to start at boot:

chkconfig httpd on

You can print installed httpd modules with the command httpd -l:

[root@webserver]# httpd -l
Compiled in modules:

Conf file /etc/httpd/conf/httpd.conf

How to configure apache virtual host

If you want to point several domains to one IP address, you can use apache virtual host for that. Assuming you are serving the domain www.domain.com and you want to add the virtual host www.domain1.com, which points at the same IP address. Then you simply add the following to httpd.conf:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.domain.com
ServerAlias domain.com *.domain.com
DocumentRoot /www/domain

<VirtualHost *:80>
ServerName www.domain1.com
DocumentRoot /www/domain1

Also you probably need to configure directory properties for each host using next example:

<Directory /www/domain> 
       Options +ExecCGI
       AllowOverride All

How to make redirection to another web server which is listenning on port 8080

<VirtualHost subdomain.domain.com:80>
  ServerName www.subdomain.domain.com
  ProxyRequests Off
  <Proxy *>
  Order deny,allow
  Allow from all
  ProxyPass / http://localhost:8080/
  ProxyPassReverse / http://localhost:8080/

Many servers want to be accessible by more than one name. This is possible with the ServerAlias directive, placed inside the <VirtualHost> section. For example in the first <VirtualHost> block above, the ServerAlias directive indicates that the listed names are other names which people can use to see that same web site:

ServerAlias domain.com *.domain.com

Source: Apache web site

MySQL + php

yum install mysql-server php php-mysql

Postfix, POP3/IMAP server

Note that default MTA in Centos is sendmail, so if you want to use postfix you should remove sendmail first:

yum remove sendmail
yum install postfix dovecot

Conf file /etc/postfix/main.cf


yum install vsftpd

Conf file /etc/vsftpd/vsftpd.conf


yum install webalizer

Conf file is /etc/httpd/conf.d/webalizer.conf
Web interface: http://YourIP/usage