![Smile :)](./images/smilies/icon_e_smile.gif)
At first, we will make Apache default port changed to a non-standard port. We will edit httpd-vhosts.conf file. Just enter the following command and change port 80 to port 8081.
โค้ด: เลือกทั้งหมด
vi /etc/zpanel/configs/apache/httpd-vhosts.conf
We have to add NginX yum repository. Enter following command:
โค้ด: เลือกทั้งหมด
vi /etc/yum.repos.d/nginx.repo
โค้ด: เลือกทั้งหมด
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
โค้ด: เลือกทั้งหมด
yum install nginx
โค้ด: เลือกทั้งหมด
vi /etc/nginx/nginx.conf
โค้ด: เลือกทั้งหมด
user nginx;
worker_processes 3; #this number should be as same as your CPU core
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024; #this number indicates the connections, may be larger for large server
}
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;
keepalive_timeout 65;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/plain application/x-javascript text/xml text/css;
gzip_vary on;
server {
listen 8083 default_server;
location / {
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
location ~ /\.ht {
deny all;
}
}
}
โค้ด: เลือกทั้งหมด
server {
listen 8083 default server;
Let’s try to set up Varnish Cache now. But before setting up it, I like to tell you something about Varnish Cache. Personally I don’t like Apache+NginX+Varnish combination at all because of high RAM usage of Varnish Cache. Actually Varnish Ccahe is a web application accelerator also known as a caching HTTP reverse proxy. It uses RAM for caching as RAM is faster than our hard-disk. So I don’t like it all when NginX alone is showing a better performance. But still if you want to set it, you can at your own risk. Just joking dear!
To install Varnish cache, enter these commands:
โค้ด: เลือกทั้งหมด
rpm --nosignature -i https://repo.varnish-cache.org/redhat/varnish-4.0.el6.rpm
โค้ด: เลือกทั้งหมด
yum install varnish
โค้ด: เลือกทั้งหมด
vi /etc/varnish/default.vcl
Then we have to edit /etc/sysconfig/varnish file and change VARNISH_LISTEN_PORT to 80. Have you done this? It’s time we should restart Apache and start NginX & Varnish (if you use) for working together. Enter following commands:
โค้ด: เลือกทั้งหมด
service httpd restart
โค้ด: เลือกทั้งหมด
service nginx start
โค้ด: เลือกทั้งหมด
service varnish start
ที่มา http://www.ugcoder.com/server-administr ... in-zpanel/