配置apache
搭建LAMP环境
首先,配置好LAMP环境.我一般图方便都是这么配置的.
sudo apt-get install tasksel
sudo tasksel
输入上面命令后就可以直接选择LAMP了.安装过程中会让你输入mysql的root用户密码.
修改apache配置
编辑apache的配置文件,修改成下面的样子.
root@lylinux:~# cat /etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz
NameVirtualHost *:8080
Listen 8080
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
Listen 443
同时修改/etc/apache2/sites-enabled/000-default文件.只修改端口号
root@lylinux:~# cat /etc/apache2/sites-enabled/000-default
ServerAdmin webmaster@localhost
......
......
既然我们要使用nginx作为前端,所以apache配置文件中的KeepAlive 就可以关闭了,修改/etc/apache2/apache2.conf,将KeepAlive设置为Off.
KeepAlive Off
同时,禁用掉无用的模块
a2dismod deflate
a2dismod cgi
a2dismod autoindex
a2dismod negotiation
a2dismod ssl
安装rpaf模块,要不然apache日志文件中记录的来源地址都是127.0.0.1
apt-get install libapache2-mod-rpaf
重启apache
service apache2 restart
安装nginx
apt-get install nginx
配置nginx
删除掉以前无用的配置
rm -rf /etc/nginx/sites-enabled/*
创建新的默认虚拟主机配置
cat >/etc/nginx/sites-available/000-default <
access_log off;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
}
EOF
ln -s /etc/nginx/sites-available/000-default /etc/nginx/sites-enabled/000-default
创建虚拟主机,使用apache作为后端.
cat >/etc/nginx/sites-available/domain.com <
server_name www.domain.com domain.com;
root /var/www/domain.com/;
access_log off;
# Static contents
location ~* ^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ {
expires max;
}
# Dynamic content, forward to Apache
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
}
EOF
ln -s /etc/nginx/sites-available/domain.com /etc/nginx/sites-enabled/domain.com
重启nginx
/etc/init.d/nginx restart
优化
最后,在简单对apache和mysql做一下优化
apache优化
sed -i -e "s/^[[:blank:]]*StartServers[[:blank:]]*.*/StartServers 5/" /etc/apache2/apache2.conf
sed -i -e "s/^[[:blank:]]*MinSpareServers[[:blank:]]*.*/MinSpareServers 5/" /etc/apache2/apache2.conf
sed -i -e "s/^[[:blank:]]*MaxSpareServers[[:blank:]]*.*/MaxSpareServers 10/" /etc/apache2/apache2.conf
sed -i -e "s/^[[:blank:]]*ServerLimit[[:blank:]]*.*/ServerLimit 10/" /etc/apache2/apache2.conf
sed -i -e "s/^[[:blank:]]*MaxClients[[:blank:]]*.*/MaxClients 10/" /etc/apache2/apache2.conf
sed -i -e "s/^[[:blank:]]*MinSpareThreads[[:blank:]]*.*/MinSpareThreads 5/" /etc/apache2/apache2.conf
sed -i -e "s/^[[:blank:]]*MaxSpareThreads[[:blank:]]*.*/MaxSpareThreads 10/" /etc/apache2/apache2.conf
mysql优化
cp /etc/mysql/my.cnf /etc/mysql/my.cnf.`date +%s`
find /usr/share/doc/mysql* -name my-small.cnf -exec cp {} /etc/mysql/my.cnf ;
sed -i 's/[mysqld]/&nuser = mysqln/' /etc/mysql/my.cnf
茶杯头甜蜜终章dlc 官方手机版v1.0.0.3
下载火柴人传说暗影格斗内置菜单 最新版v3.0.1
下载荒野乱斗测试服 安卓版v61.10.3
下载荒野乱斗彩虹服 安卓版v61.10.3
下载寒霜启示录 安卓版v1.25.10
寒霜启示录是一款生存模拟游戏,不少玩家可能对于末日都有着自己
末日城堡免广告版 安卓最新版v0.7.1
末日城堡免广告版是一款非常好玩的模拟经营类游戏,内部可以不看
甜蜜人生模拟器 最新版v1.4.5
甜蜜人生模拟器是一款非常好玩的模拟恋爱手游,玩家在这里能够对
武器锻造师内置功能菜单 v10.4
武器锻造师内置菜单版是游戏的破解版本,在该版本中为玩家提供了
开放空间overfield 安卓版v1.0.5
开放空间Overfield是一款箱庭养成经营手游,让你在广阔