给DirectAdmin面板增加nginx前端
[ 2012/11/30 00:24 | by Totti ]
装好Directadmin面板之后,如果高并发流量进来,apache跑起来还是很吃力的.因此在前面装个nginx是很有必要的.但是由于我对 directadmin的api还不熟悉.对它绑定域名这块没有较好的方法.不能实现动静分离. 装上nginx也只是起到一个缓存和keepalive的作用.nginx监听80端口.apache监听81端口.
安装还是很简单的.我只在CentOS环境中测试.在Debian平台上没有测试.大家自己测试一下呗.OK.step by step...
第一步,安装nginx.这里我没有安装pcre库.伪静态 还是沿用apache的.htaccess.
cd /usr/local/src/
wget http://nginx.org/download/nginx-0.7.65.tar.gz
tar -zxf nginx-0.7.65.tar.gz
cd nginx-0.7.65
./configure --user=apache --group=apache --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/conf/nginx.conf --pid-path=/var/log/nginx/nginx.pid --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/tmp/nginx_client --http-proxy-temp-path=/tmp/nginx_proxy --http-fastcgi-temp-path=/tmp/nginx_fastcgi --with-http_stub_status_module
make
make install
添加启动脚本
#! /bin/sh
ulimit -n 65535
# Description: Startup script for nginx
# chkconfig: 2345 55 25
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/sbin/$NAME
CONFIGFILE=/etc/nginx/conf/nginx.conf
PIDFILE=/var/log/nginx/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
set -e
[ -x "$DAEMON" ] || exit 0
do_start() {
$DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}
do_stop() {
kill -INT `cat $PIDFILE` || echo -n "nginx not running"
}
do_reload() {
kill -HUP `cat $PIDFILE` || echo -n "nginx can't reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
do_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
do_stop
echo "."
;;
reload)
echo -n "Reloading $DESC configuration..."
do_reload
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
do_stop
sleep 1
do_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac
exit 0
嗯嗯.这个脚本很熟悉吧,呵呵.记得赋予执行权限,chmod 755 /etc/init.d/nginx 接着设置nginx.conf.
mv /etc/nginx/conf/nginx.conf /etc/nginx/conf/nginx.conf.bak
mkdir /etc/nginx/conf/ips
vim /etc/nginx/conf/nginx.conf
输入以下内容
worker_processes 2;
worker_rlimit_nofile 65535;
events {
worker_connections 65535;
use epoll;
}
error_log /var/log/nginx/error.log info;
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
gzip on;
gzip_http_version 1.0;
gzip_min_length 1100;
gzip_comp_level 3;
gzip_buffers 4 32k;
gzip_types text/plain text/xml text/css application/x-javascript application/xml application/xml+rss text/javascript application/atom+xml;
ignore_invalid_headers on;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
connection_pool_size 256;
server_names_hash_max_size 2048;
server_names_hash_bucket_size 256;
client_header_buffer_size 256k;
large_client_header_buffers 4 256k;
request_pool_size 32k;
output_buffers 4 64k;
postpone_output 1460;
open_file_cache max=1000 inactive=300s;
open_file_cache_valid 600s;
open_file_cache_min_uses 2;
open_file_cache_errors off;
include "/etc/nginx/conf/ips/*.conf";
}
在/etc/nginx/conf/ips路径下.添加监听的IP地址的虚拟主机配置,有多个IP.就添加多几个主机配置,以 192.168.2.1为例:
server {
listen 192.168.2.1:80;
server_name _;
access_log off;
error_page 400 401 402 403 404 405 406 407 408 409 500 501 502 503 504 @backend;
location @backend {
internal;
client_max_body_size 100m;
client_body_buffer_size 128k;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffer_size 32k;
proxy_buffers 256 32k;
proxy_busy_buffers_size 512k;
proxy_temp_file_write_size 64k;
proxy_connect_timeout 30s;
proxy_pass http://192.168.2.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;
}
location / {
client_max_body_size 100m;
client_body_buffer_size 128k;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffer_size 32k;
proxy_buffers 256 32k;
proxy_busy_buffers_size 512k;
proxy_temp_file_write_size 64k;
proxy_connect_timeout 30s;
proxy_pass http://192.168.2.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;
}
}
上例中的error_page都转发到后端.
第二步,给apache安装rpaf模块
cd /usr/local/src/
wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
tar -zxf mod_rpaf-0.6.tar.gz
cd mod_rpaf-0.6
/usr/sbin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
安装完了之后.编辑/etc/httpd/conf/httpd.conf文件.添加以下内容:
LoadModule rpaf_module /usr/lib/apache/mod_rpaf-2.0.so
#Mod_rpaf settings
RPAFenable On
RPAFproxy_ips 127.0.0.1 [your_ips]
RPAFsethostname On
RPAFheader X-Forwarded-For
[your_ips]改成你自己的监听IP
第三步,修改DirectAdmin设置
这一步要做的是修改默认apache的监听端口.需要对apache的配置有一定的认识.进入/usr/local/directadmin/data /templates目录.可以看到很多设置文件.这些文件都是默认建立账户或绑定域名时.directadmin会根据这些模板生成相关程序的参数配置 文件.
主要要修改的文件包括: ips_virtual_host.conf virtual_host2_sub.conf virtual_host.conf virtual_host_sub.conf httpd.conf redirect_virtual_host.conf virtual_host2.conf 在这些文件中,搜索"80",改成"81".这一步没什么好说的了.细心一点改.
此外还要修改已绑定域名的配置文件.位于/etc/httpd/conf /usr/local/directadmin/data/users/ 两处目录.进入以上路径后可以使用以下命令查找端口.
grep 80 . -r
端口还是改成"81".然后还是细心一点.最后重启一下nginx和httpd.完事了...
tip:1.建议关闭apache的Deflate模块.直 接在/etc/httpd/conf/httpd.conf中注释掉Deflate模块那一段.在第165行.
2.如果想要在httpd重启的时候一并重启nginx.可以在/etc/init.d/httpd中自行添加命令.
安装还是很简单的.我只在CentOS环境中测试.在Debian平台上没有测试.大家自己测试一下呗.OK.step by step...
第一步,安装nginx.这里我没有安装pcre库.伪静态 还是沿用apache的.htaccess.
cd /usr/local/src/
wget http://nginx.org/download/nginx-0.7.65.tar.gz
tar -zxf nginx-0.7.65.tar.gz
cd nginx-0.7.65
./configure --user=apache --group=apache --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/conf/nginx.conf --pid-path=/var/log/nginx/nginx.pid --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/tmp/nginx_client --http-proxy-temp-path=/tmp/nginx_proxy --http-fastcgi-temp-path=/tmp/nginx_fastcgi --with-http_stub_status_module
make
make install
添加启动脚本
#! /bin/sh
ulimit -n 65535
# Description: Startup script for nginx
# chkconfig: 2345 55 25
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/sbin/$NAME
CONFIGFILE=/etc/nginx/conf/nginx.conf
PIDFILE=/var/log/nginx/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
set -e
[ -x "$DAEMON" ] || exit 0
do_start() {
$DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}
do_stop() {
kill -INT `cat $PIDFILE` || echo -n "nginx not running"
}
do_reload() {
kill -HUP `cat $PIDFILE` || echo -n "nginx can't reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
do_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
do_stop
echo "."
;;
reload)
echo -n "Reloading $DESC configuration..."
do_reload
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
do_stop
sleep 1
do_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac
exit 0
嗯嗯.这个脚本很熟悉吧,呵呵.记得赋予执行权限,chmod 755 /etc/init.d/nginx 接着设置nginx.conf.
mv /etc/nginx/conf/nginx.conf /etc/nginx/conf/nginx.conf.bak
mkdir /etc/nginx/conf/ips
vim /etc/nginx/conf/nginx.conf
输入以下内容
worker_processes 2;
worker_rlimit_nofile 65535;
events {
worker_connections 65535;
use epoll;
}
error_log /var/log/nginx/error.log info;
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
gzip on;
gzip_http_version 1.0;
gzip_min_length 1100;
gzip_comp_level 3;
gzip_buffers 4 32k;
gzip_types text/plain text/xml text/css application/x-javascript application/xml application/xml+rss text/javascript application/atom+xml;
ignore_invalid_headers on;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
connection_pool_size 256;
server_names_hash_max_size 2048;
server_names_hash_bucket_size 256;
client_header_buffer_size 256k;
large_client_header_buffers 4 256k;
request_pool_size 32k;
output_buffers 4 64k;
postpone_output 1460;
open_file_cache max=1000 inactive=300s;
open_file_cache_valid 600s;
open_file_cache_min_uses 2;
open_file_cache_errors off;
include "/etc/nginx/conf/ips/*.conf";
}
在/etc/nginx/conf/ips路径下.添加监听的IP地址的虚拟主机配置,有多个IP.就添加多几个主机配置,以 192.168.2.1为例:
server {
listen 192.168.2.1:80;
server_name _;
access_log off;
error_page 400 401 402 403 404 405 406 407 408 409 500 501 502 503 504 @backend;
location @backend {
internal;
client_max_body_size 100m;
client_body_buffer_size 128k;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffer_size 32k;
proxy_buffers 256 32k;
proxy_busy_buffers_size 512k;
proxy_temp_file_write_size 64k;
proxy_connect_timeout 30s;
proxy_pass http://192.168.2.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;
}
location / {
client_max_body_size 100m;
client_body_buffer_size 128k;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffer_size 32k;
proxy_buffers 256 32k;
proxy_busy_buffers_size 512k;
proxy_temp_file_write_size 64k;
proxy_connect_timeout 30s;
proxy_pass http://192.168.2.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;
}
}
上例中的error_page都转发到后端.
第二步,给apache安装rpaf模块
cd /usr/local/src/
wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
tar -zxf mod_rpaf-0.6.tar.gz
cd mod_rpaf-0.6
/usr/sbin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
安装完了之后.编辑/etc/httpd/conf/httpd.conf文件.添加以下内容:
LoadModule rpaf_module /usr/lib/apache/mod_rpaf-2.0.so
#Mod_rpaf settings
RPAFenable On
RPAFproxy_ips 127.0.0.1 [your_ips]
RPAFsethostname On
RPAFheader X-Forwarded-For
[your_ips]改成你自己的监听IP
第三步,修改DirectAdmin设置
这一步要做的是修改默认apache的监听端口.需要对apache的配置有一定的认识.进入/usr/local/directadmin/data /templates目录.可以看到很多设置文件.这些文件都是默认建立账户或绑定域名时.directadmin会根据这些模板生成相关程序的参数配置 文件.
主要要修改的文件包括: ips_virtual_host.conf virtual_host2_sub.conf virtual_host.conf virtual_host_sub.conf httpd.conf redirect_virtual_host.conf virtual_host2.conf 在这些文件中,搜索"80",改成"81".这一步没什么好说的了.细心一点改.
此外还要修改已绑定域名的配置文件.位于/etc/httpd/conf /usr/local/directadmin/data/users/ 两处目录.进入以上路径后可以使用以下命令查找端口.
grep 80 . -r
端口还是改成"81".然后还是细心一点.最后重启一下nginx和httpd.完事了...
tip:1.建议关闭apache的Deflate模块.直 接在/etc/httpd/conf/httpd.conf中注释掉Deflate模块那一段.在第165行.
2.如果想要在httpd重启的时候一并重启nginx.可以在/etc/init.d/httpd中自行添加命令.
DirectAdmin 一键安装Capri模版
[ 2012/11/26 01:24 | by Totti ]
很多采用DirectAdmin作为控制面板的IDC,都为DA安装了商业模版-Capri 。有句话说的好:“上有政策、下有对策”,这套模版是收费的,但总有高人能够解决这个问题。
这款模版自带了中文语言,不需要二次汉化,安装过程只需几步。
1
wget http://www.hndzz.cn/attachment/capri/capri.sh
二、执行一键包安装
1、运行该包
1
sh capri.sh
2、根据提示操作
1)Please choose a skin name or enter to use default[capri]
翻译:请输入皮肤名称,默认:Capri。
无需填写,直接回车即可。
2)Please choose a color set(1:blue,2:grey)[1]:1
翻译:请选择颜色,1:蓝色,2:灰色,默认:蓝色
请根据自己需要选择。
3)Would you like to install the login page skin?(y/n)[y]
翻译:你需要在登陆页安装皮肤吗?默认:要
根据实际情况选择。
4)Capri skin also have a email-only version for users who have a email services.Would you like to install a secondemail-only sky(will be called Capri-mail)?
翻译:是否安装Capri邮件系统皮肤?默认不安装。
建议不安装。
这款模版自带了中文语言,不需要二次汉化,安装过程只需几步。
1
wget http://www.hndzz.cn/attachment/capri/capri.sh
二、执行一键包安装
1、运行该包
1
sh capri.sh
2、根据提示操作
1)Please choose a skin name or enter to use default[capri]
翻译:请输入皮肤名称,默认:Capri。
无需填写,直接回车即可。
2)Please choose a color set(1:blue,2:grey)[1]:1
翻译:请选择颜色,1:蓝色,2:灰色,默认:蓝色
请根据自己需要选择。
3)Would you like to install the login page skin?(y/n)[y]
翻译:你需要在登陆页安装皮肤吗?默认:要
根据实际情况选择。
4)Capri skin also have a email-only version for users who have a email services.Would you like to install a secondemail-only sky(will be called Capri-mail)?
翻译:是否安装Capri邮件系统皮肤?默认不安装。
建议不安装。
Centos 6.0 安装桌面
[ 2012/11/22 10:35 | by Totti ]
[root@localhost ~]# yum groupinstall "X Window System"
[root@localhost ~]# yum groupinstall "Desktop"
[root@xen ~]# yum install tigervnc tigervnc-server
添加启动项
[root@xen ~]# chkconfig --add vncserver
[root@xen ~]# chkconfig vncserver on
[root@localhost ~]# yum groupinstall "Desktop"
[root@xen ~]# yum install tigervnc tigervnc-server
添加启动项
[root@xen ~]# chkconfig --add vncserver
[root@xen ~]# chkconfig vncserver on
proftpd 更换成 pureftpd
[ 2012/06/24 01:24 | by Totti ]
Apache两种工作模式区别及配置切换
[ 2012/06/11 22:11 | by Totti ]