Difference between revisions of "Centos 6 Webserver"

From vpsget wiki
Jump to: navigation, search
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
In this article we will install some software that is useful on a webserver based on Centos 6.<br/>
 
In this article we will install some software that is useful on a webserver based on Centos 6.<br/>
 
For the beginning let us install some packages that will be useful later:
 
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++
+
  yum install nano wget fetchmail zip unzip bzip2 nmap openssl lynx fileutils ncftp gcc gcc-c++ gd-devel
 
  yum update
 
  yum update
MySQL + php
+
<h3>Apache</h3>
 +
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:
 +
  core.c
 +
  prefork.c
 +
  http_core.c
 +
  mod_so.c
 +
Conf file ''/etc/httpd/conf/httpd.conf''
 +
<h3>How to configure apache virtual host</h3>
 +
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>
 +
 +
<VirtualHost *:80>
 +
ServerName www.domain1.com
 +
DocumentRoot /www/domain1
 +
</VirtualHost>
 +
 
 +
Also you probably need to configure directory properties for each host using next example:
 +
<Directory /www/domain>
 +
        Options +ExecCGI
 +
        AllowOverride All
 +
</Directory>
 +
 
 +
 
 +
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
 +
  </Proxy>
 +
  ProxyPass / http://localhost:8080/
 +
  ProxyPassReverse / http://localhost:8080/
 +
  </VirtualHost>
 +
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: [http://httpd.apache.org/docs/2.2/vhosts/name-based.html Apache web site]
 +
<h3>MySQL + php</h3>
 
  yum install mysql-server php php-mysql
 
  yum install mysql-server php php-mysql
 
+
<h3>Postfix, POP3/IMAP server</h3>
 +
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''
 +
<h3>Ftp</h3>
 +
yum install vsftpd
 +
Conf file ''/etc/vsftpd/vsftpd.conf''
 +
<h3>Webalizer</h3>
 +
yum install webalizer
 +
Conf file is  ''/etc/httpd/conf.d/webalizer.conf''<br/>
 +
Web interface: http://YourIP/usage
  
 
[[Category:Linux]]
 
[[Category:Linux]]

Latest revision as of 20:33, 31 October 2013

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

Apache

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:
  core.c
  prefork.c
  http_core.c
  mod_so.c

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>

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

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

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


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
  </Proxy>
  ProxyPass / http://localhost:8080/
  ProxyPassReverse / http://localhost:8080/
  </VirtualHost>

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

Ftp

yum install vsftpd

Conf file /etc/vsftpd/vsftpd.conf

Webalizer

yum install webalizer

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