Difference between revisions of "Centos 6 Webserver"

From vpsget wiki
Jump to: navigation, search
Line 30: Line 30:
 
  DocumentRoot /www/domain1
 
  DocumentRoot /www/domain1
 
  </VirtualHost>
 
  </VirtualHost>
 +
 +
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:
 
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
 
  ServerAlias domain.com *.domain.com

Revision as of 13:02, 24 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>

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