السلام عليكم ورحمة الله وبركاته :
الموضوع مناسب للسرفرات التي تعاني من ضغط شديد أثناء التصفح وتمت تجربته علي أكثر من
سرفر بواسطتي وقمت بكتابة الموضوع من أجل أن تعم الفائدة علي أصحاب السرفرات :
How to install Nginx web server in Cpanel to manage static content using less cpu and
ram, so we just loaded PHP to Apache. Basically it will lower your memory usage and increase the speed of your server.
It is currently running on this server, here is the info so you can see it works with the latest release of WHM\cPanel – cPanel 11.26.16, CentOS 5.5 i686, PHP 5.3.4 and Apache 2.2.17.
- Run SSH console
cd /usr/src
wget http://sysoev.ru/nginx/nginx-0.7.63.tar.gz
wget http://stderr.net/apache/rpaf/downlo...paf-0.6.tar.gz
wget http://autosetup1.googlecode.com/files/pcre-7.9.tar.gz
tar xvzf mod_rpaf-0.6.tar.gz
cd mod_rpaf-0.6
/usr/local/apache/bin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
cd /usr/src
tar xvzf pcre-7.9.tar.gz
cd pcre-7.9
./configure
make
make install
cd /usr/src
tar xvzf nginx-0.7.63.tar.gz
cd nginx-0.7.63
./configure --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module
make
make install
Login to WHM and look for the following route:
Main >> Service Configuration >> Apache Setup > Include Editor > Pre Main Include – Add the following configuration and save, LIST_OF_YOUR_IPS changing the IP to your server ip
LoadModule rpaf_module modules/mod_rpaf-2.0.so
RPAFenable On
# Enable reverse proxy add forward
RPAFproxy_ips 127.0.0.1 LIST_OF_YOUR_IPS
# which ips are forwarding requests to us
RPAFsethostname On
# let rpaf update vhost settings
# allows to have the same hostnames as in the "real"
# configuration for the forwarding Apache
RPAFheader X-Real-IP
# Allows you to change which header mod_rpaf looks
# for when trying to find the ip the that is forwarding
# our requests
Change the apache port to 81 (tweak settings)
Open whm – tweak settings and find 0.0.0.0:80 and change it to 0.0.0.0.:81
Run SSH console
/usr/local/cpanel/whostmgr/bin/whostmgr2 --updatetweaksettings
/scripts/rebuildhttpdconf
httpd restart
wget http://www.stop4host.com/downloads/nginx/nginx.sh
chmod the file and run it
chmod 755 nginx.sh
./nginx.sh
Check the configuration
/usr/local/nginx/sbin/nginx -t
Start nginx
/usr/local/nginx/sbin/nginx
Until now only the managing nginx connections, but is not serving static content. For the latter you must edit the following file:
/usr/local/nginx/conf/vhost.conf
Remove the 3 # signs of the following lines:
#location ~* \.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|js|css)$ {
# root /home/myweb/public_html;
#}
so the final configuration will looks like
location ~* \.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|js|css)$ {
root /home/myweb/public_html;
}
Restart nginx in SSH
/usr/local/nginx/sbin/nginx -s reload
Also add it in /etc/init.d/ to make automatically start when you reboot your server
nano /etc/init.d/nginx
chmod 755 /etc/init.d/nginx
#!/bin/sh
#
# nginx ... this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /opt/nginx/conf/nginx.conf
# pidfile: /opt/nginx/logs/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
start
}
reload() {
configtest || return $?
echo -n $"?eloading $prog: "?
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
Some Commands
/etc/init.d/nginx start
/etc/init.d/nginx stop
/etc/init.d/nginx restart
/etc/init.d/nginx status
/etc/init.d/nginx status
نقلا عن : http://stop4host.com/7/how-to-instal...as-proxy-mode/
من يواجه مشكلة في التنصيب يمكنه الرد بالموضوع وسأتابع معه باذن الرحمن ,
تحياتي كارم ابراهيم البستاني