1. Install Webserver Apache

yum install httpd httpd-devel

edit httpd.conf

Search and edit :

Listen 80

change it to be:

Listen 81

and then, paste this code at the end of the file

 NameVirtualHost 127.0.0.1:81  
    
 # Define Server document root  
   DocumentRoot /var/www/html/  
    
 # Define the virtual host  
 <VirtualHost 127.0.0.1:81>  
   ServerName www.domain.com 
   ServerAlias domain.com
   DocumentRoot /var/www/domain.com/public_html  
     <Directory "/var/www/doamin.com/public_html">  
         Options FollowSymLinks -Includes  
         AllowOverride All  
         Order allow,deny  
         Allow from all  
     </Directory>  
     RewriteEngine on  
 </VirtualHost>  

www.domain.com, domain.com  =>> domain name

/var/www/domain.com/public_html  =>>  root directory

Restart httpd / apache

service httpd restart

2. Install Nginx

rpm -Uvh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

yum install nginx

Edit the nginx configuration file (/etc/nginx/nginx.conf)
sample config:

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    gzip  on;
    gzip_comp_level 2;
    gzip_proxied any;
    gzip_types      text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    server_tokens off;

    include /etc/nginx/conf.d/*.conf;
}

Edit vhost ( /etc/nginx/conf.d/domain.com.conf)

add/paste this config:

client_max_body_size  10m;  
   client_body_buffer_size 128k;  
   proxy_send_timeout  90;  
   proxy_read_timeout  90;  
   proxy_buffer_size  128k;  
   proxy_buffers   4 256k;  
   proxy_busy_buffers_size 256k;  
   proxy_temp_file_write_size 256k;  
   proxy_connect_timeout 30s;  
   proxy_redirect http://www.domain.com:81  http://www.domain.com;     proxy_redirect http://domain.com:81  http://domain.com;     proxy_pass  http://127.0.0.1:81/;  
   proxy_set_header  Host  $host;  
   proxy_set_header  X-Real-IP $remote_addr;  
   proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;  

Restart Nginx

service nginx restart

Đăng nhận xét Blogger

 
Top