web优化
转载先对脚本的内容做一下说明:
1. 对系统进行判断,如果是Cent OS 64位,继续运行。
2. 设置为每天凌晨四点进行时间同步(跟国家授时中心的服务器进行时间同步)注释:已调.
3. 禁用 atime 日志记录特性。
4. 将系统同时打开的文件个数增大
5. 将ctrl ALT delete键进行屏蔽,防止误操作的时候服务器重启
6. 关闭SELinux
7. 禁用GSSAPI来认证,也禁用DNS反向解析,加快SSH登陆速度
8. 优化一些内核参数
9. 调整删除字符的按键为backspace(某些系统默认是delete)
10. 打开vim的语法高亮
11. 取消生成whatis数据库和locate数据库
12. 关闭没用的服务
13. 关闭IPv6
下面是sh脚本文件详细内容.
#!/bin/bash
#check the OS
platform=`uname -i`
if [ $platform != "x86_64" ];then
echo "this script is only for 64bit Operating System !"
exit 1
fi
echo "the platform is ok"
version=`lsb_release -r |awk '{print substr($2,1,1)}'`
if [ $version != 6 ];then
echo "this script is only for CentOS 6 !"
exit 1
fi
cat << EOF
+---------------------------------------------+
| Winenice system is CentOS 6 x86_64 |
| start optimizing........ |
+---------------------------------------------+
EOF
yum -y install ntp
echo "* 4 * * * /usr/sbin/ntpdate 203.117.180.36 > /dev/null 2>&1" >> /var/spool/cron/root
service crond restart 设置为每天凌晨四点进行时间同步(跟国家授时中心的服务器进行时间同步.)
#set the file limit
echo "ulimit -SHn 102400" >> /etc/rc.local 指定最大打开文件数.
cat >> /etc/security/limits.conf << EOF
* soft nofile 65536
* hard nofile 65536
EOF
#set the control-alt-delete to guard against the misuse
sed -i 's#exec /sbin/shutdown -r now#\#exec /sbin/shutdown -r now#' /etc/init/control-alt-delete.conf 禁用control-alt-delete,防止误操作.
#disable selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config 禁用SELINUX
#set ssh
sed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_config 禁用GSSAPI来认证,也禁用DNS反向解析,加快SSH登陆速度.
sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config
service sshd restart
磁盘在我们 LEMP平台架构中扮演着重要的角色。静态文件、模板和代码都来自磁盘,因为磁盘访问的延迟相当高。因此,花一些时间对磁盘硬件进行优化是有意义的。禁用 atime 日志记录特性。atime 是最近访问文件的时间,每当访问文件时,底层文件系统必须记录这个时间戳。现在我们很少使用 atime,禁用它可以减少磁盘访问时间。
#tune kernel parametres 优化内核,需重启!
cat >> /etc/sysctl.conf << EOF
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 1200 ----------------长连接会话保持,与DBA沟通.
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 262144
net.core.somaxconn = 262144
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_max_syn_backlog = 262144
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
EOF
/sbin/sysctl -p IP碎片去除,从指定的文件加载系统参数.
#define the backspace button can erase the last character typed
echo 'stty erase ^H' >> /etc/profile 退格键设定为backspace
echo "syntax on" >> /root/.vimrc 开启vim色彩.
#stop some crontab whatis和mlocate都是查询whatis数据库的工具,对于WEB服务器作用不大.
mkdir /etc/cron.daily.bak
mv /etc/cron.daily/makewhatis.cron /etc/cron.daily.bak
mv /etc/cron.daily/mlocate.cron /etc/cron.daily.bak
chkconfig bluetooth off 蓝牙功能,无用,可关闭.
chkconfig cups off 打印功能,无用,可关闭.
chkconfig ip6tables off IPV6 可关闭.
#disable the ipv6
cat > /etc/modprobe.d/ipv6.conf << EOFI
alias net-pf-10 off
options ipv6 disable=1
EOFI
echo "NETWORKING_IPV6=off" >> /etc/sysconfig/network
cat << EOF
+-------------------------------------------------+
| Winenice Web Server Optimization end! |
| Please restart! |
+-------------------------------------------------+
EOF
上一篇:虚拟机的时间调整问题
下一篇:mysql
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Web API编程
Web API编程
Web API编程 JavaScript -
WEB图像优化
图像是网站或者WEB应用重要的组成部分,随着现在终端设备及5G的普及,用户对于图像的要求越来越高,为了提供更加速度体验,可以对图像进行优化。
HTML 性能优化 前端 加载 页面布局 -
Web 前端优化
1. 内容篇 Yahoo! 的 Exceptional Perform
前端 javascript 运维 ViewUI CSS -
web性能优化 页面性能优化小结
总览HTML缩减资源的大小缩减首屏内容的大小启用压缩功能按视口调整内容尺寸压缩
性能优化 web前端 缓存 html css