禁用Apache空主机头

[不指定 2013/05/31 11:12 | by Totti ]
编辑配置文件,在你的站点配置之前再增加一个站点
NameVirtualHost *

ServerAdmin yourmail#mail.com
DocumentRoot /error
ServerName abc.com

安卓刷机不能进系统

[不指定 2013/04/12 11:03 | by Totti ]
S-ON 手动刷boot.img

fastboot flash boot boot.img
解决办法 把下面的注册表信息 存成这册表文件 然后导入即可

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\Manage]
@=hex(2):40,00,25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,6f,00,74,\
00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6d,00,\
79,00,63,00,6f,00,6d,00,70,00,75,00,74,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,\
00,34,00,30,00,30,00,00,00
"MUIVerb"=hex(2):40,00,25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,\
6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,\
00,6d,00,79,00,63,00,6f,00,6d,00,70,00,75,00,74,00,2e,00,64,00,6c,00,6c,00,\
2c,00,2d,00,34,00,30,00,30,00,00,00
"SuppressionPolicy"=dword:4000003c
"HasLUAShield"=""
[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\Manage\command]
@=hex(2):25,00,77,00,69,00,6e,00,64,00,69,00,72,00,25,00,5c,00,73,00,79,00,73,\
00,74,00,65,00,6d,00,33,00,32,00,5c,00,6d,00,6d,00,63,00,2e,00,65,00,78,00,\
65,00,20,00,2f,00,73,00,20,00,25,00,77,00,69,00,6e,00,64,00,69,00,72,00,25,\
00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,63,00,6f,00,\
6d,00,70,00,6d,00,67,00,6d,00,74,00,2e,00,6d,00,73,00,63,00,00,00

wget http://www.putdispenserhere.com/wp-content/uploads/pptpinstall.sh
chmod +x pptpinstall.sh
./pptpinstall.sh
#!/bin/bash
# Interactive PoPToP install script on a OpenVZ VPS
# Tested on Debian 5, 6, and Ubuntu 11.04
# 2011 v1.1
# Author: Commander Waffles
# http://www.putdispenserhere.com/pptp-debian-ubuntu-openvz-setup-script/

echo "######################################################"
echo "Interactive PoPToP Install Script for OpenVZ VPS"
echo "by Commander Waffles http://www.putdispenserhere.com"
echo "Should work on various deb-based Linux distos."
echo "Tested on Debian 5, 6, and Ubuntu 11.04"
echo
echo "Make sure to message your provider and have them enable"
echo "IPtables and ppp modules prior to setting up PoPToP."
echo
echo "You need to set up the server before creating more users."
echo "A separate user is required per connection or machine."
echo "######################################################"
echo
echo
echo "######################################################"
echo "Select on option:"
echo "1) Set up new PoPToP server AND create one user"
echo "2) Create additional users"
echo "######################################################"
read x
if test $x -eq 1; then
  echo "Enter username that you want to create (eg. client1 or john):"
  read u
  echo "Specify password that you want the server to use:"
  read p

# get the VPS IP
ip=`ifconfig venet0:0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`

echo
echo "######################################################"
echo "Downloading and Installing PoPToP"
echo "######################################################"
apt-get update
apt-get install pptpd

echo
echo "######################################################"
echo "Creating Server Config"
echo "######################################################"
cat > /etc/ppp/pptpd-options <<END
name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
ms-dns 8.8.8.8
ms-dns 8.8.4.4
proxyarp
nodefaultroute
lock
nobsdcomp
END

# setting up pptpd.conf
echo "option /etc/ppp/pptpd-options" > /etc/pptpd.conf
echo "logwtmp" >> /etc/pptpd.conf
echo "localip $ip" >> /etc/pptpd.conf
echo "remoteip 10.1.0.1-100" >> /etc/pptpd.conf

# adding new user
echo "$u  *  $p  *" >> /etc/ppp/chap-secrets

echo
echo "######################################################"
echo "Forwarding IPv4 and Enabling it on boot"
echo "######################################################"
cat >> /etc/sysctl.conf <<END
net.ipv4.ip_forward=1
END
sysctl -p

echo
echo "######################################################"
echo "Updating IPtables Routing and Enabling it on boot"
echo "######################################################"
iptables -t nat -A POSTROUTING -j SNAT --to $ip
# saves iptables routing rules and enables them on-boot
iptables-save > /etc/iptables.conf

cat > /etc/network/if-pre-up.d/iptables <<END
#!/bin/sh
iptables-restore < /etc/iptables.conf
END

chmod +x /etc/network/if-pre-up.d/iptables
cat >> /etc/ppp/ip-up <<END
ifconfig ppp0 mtu 1400
END

echo
echo "######################################################"
echo "Restarting PoPToP"
echo "######################################################"
/etc/init.d/pptpd restart

echo
echo "######################################################"
echo "Server setup complete!"
echo "Connect to your VPS at $ip with these credentials:"
echo "Username:$u ##### Password: $p"
echo "######################################################"

# runs this if option 2 is selected
elif test $x -eq 2; then
  echo "Enter username that you want to create (eg. client1 or john):"
  read u
  echo "Specify password that you want the server to use:"
  read p

# get the VPS IP
ip=`ifconfig venet0:0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`

# adding new user
echo "$u  *  $p  *" >> /etc/ppp/chap-secrets

echo
echo "######################################################"
echo "Addtional user added!"
echo "Connect to your VPS at $ip with these credentials:"
echo "Username:$u ##### Password: $p"
echo "######################################################"

else
echo "Invalid selection, quitting."
exit
fi

重建directadmin user.list用户

[不指定 2012/11/30 09:32 | by Totti ]
If your users.list files for all of your Resellers/Admins becomes corrupt, you can create and run this script to rebuild them all.
Corruption can happen during any process that writes the users.list file if multiple processes are saving the file at the same time (locking issue).  Things like backup restores in the background could in theory cause it, while browsing in DA.
It assumes that usertype=user, and creator=hiscreator exists in all user.conf files.

Create a fix.sh somewhere and fill it with the following code:
#!/bin/sh

cd /usr/local/directadmin/data/users

for r in `ls */reseller.conf | cut -d/ -f1`; do
{
     echo "fixing Reseller $r ...";

     echo -n '' > $r/users.list

     for u in `grep "^creator=$r$" */user.conf | cut -d/ -f1`; do
     {
         ISUSER=`grep -c usertype=user $u/user.conf`
         if [ "$ISUSER" = "1" ]; then
             echo $u >> $r/users.list
         fi
     };
     done;
};
done;


chmod the fix.sh to 755 and run it.
It can be run repeatedly as the users.list files are emptied before the run starts.

da用户数据目录

[不指定 2012/11/30 09:20 | by Totti ]
/usr/local/directadmin/data

给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中自行添加命令.
分页: 3/51 第一页 上页 1 2 3 4 5 6 7 8 9 10 下页 最后页 [ 显示模式: 摘要 | 列表 ]