基于CentOS 5.5 搭建nginx +php +php-fpm+mysql高性能php平台
1.3.系统初始化
#vi init_network.sh
#welcome cat << EOF +--------------------------------------------------------------+ | === Welcome to Centos System init === | +--------------------------------------------------------------+ +----------------------Author:NetSeek--------------------------+ EOF #disable ipv6 cat << EOF +--------------------------------------------------------------+ | === Welcome to Disable IPV6 === | +--------------------------------------------------------------+ EOF echo "alias net-pf-10 off" >> /etc/modprobe.conf echo "alias ipv6 off" >> /etc/modprobe.conf /sbin/chkconfig --level 35 ip6tables off echo "ipv6 is disabled!" #disable selinux sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config echo "selinux is disabled,you must reboot!" #vim sed -i "8 s/^/alias vi='vim'/" /root/.bashrc echo 'syntax on' > /root/.vimrc #zh_cn sed -i -e 's/^LANG=.*/LANG="en"/' /etc/sysconfig/i18n #init_ssh ssh_cf="/etc/ssh/sshd_config" sed -i -e '74 s/^/#/' -i -e '76 s/^/#/' $ssh_cf sed -i "s/#UseDNS yes/UseDNS no/" $ssh_cf #client sed -i -e '44 s/^/#/' -i -e '48 s/^/#/' $ssh_cf echo "ssh is init is ok.............." #chkser #tunoff services #-------------------------------------------------------------------------------- cat << EOF +--------------------------------------------------------------+ | === Welcome to Tunoff services === | +--------------------------------------------------------------+ EOF #--------------------------------------------------------------------------------- for i in `ls /etc/rc3.d/S*` do CURSRV=`echo $i|cut -c 15-` echo $CURSRV case $CURSRV in crond | irqbalance | microcode_ctl | network | random | sendmail | sshd | syslog | local | mysqld ) echo "Base services, Skip!" ;; *) echo "change $CURSRV to off" chkconfig --level 235 $CURSRV off service $CURSRV stop ;; esac done
1.4 系统环境部署及调整
检查系统是否正常
# tail -n100 /var/log/messages (检查有无系统级错误信息)
# dmesg (检查硬件设备是否有错误信息)
# ifconfig (检查网卡设置是否正确)
# ping (检查网络是否正常)
1.5使用 yum 程序安装所需开发包
1.5.1 更换快源
#cd /etc/yum.repos.d/
#mv CentOS-Base.repo CentOS-Base.repo.linuxtone
#wget http:///soft/lemp/CentOS-Base.repo
1.5.2 yum安装相关软件包:
#yum -y install ntp vim-enhanced gcc gcc-c++ gcc-g77 flex bison autoconf automake glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel libtool* zlib-devel libxml2-devel libjpeg-devel libpng-devel libtiff-devel fontconfig-devel freetype-devel libXpm-devel gettext-devel curl curl-devel pam-devel e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
1.6 定时校正服务
器时钟,定时与中国国家授时中心授时服务器同步
# crontab -e
加入一行:
15 3 * * * /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1
1.7下载相关软件包
#cd /usr/local/src
wget http://download.suhosin.org/suhosin-patch-5.3.2-0.9.9.1.patch.gz wget http://monkey.org/~provos/libevent-1.4.13-stable.tar.gz wget http://sysoev.ru/nginx/nginx-1.0.4.tar.gz wget http://www.php.net/get/php-5.3.2.tar.gz/from/this/mirror wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.3-m3.tar.gz/from/http:/// wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.tar.gz wget "http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0" wget "http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0" wget http://pecl.php.net/get/memcache-2.2.5.tgz wget "http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0" wget ftp:///pub/software/programming/pcre/pcre-8.21.tar.gz wget http:///source/0.9.6/eaccelerator-0.9.6.tar.bz2 wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz wget http://pecl.php.net/get/imagick-2.3.0.tgz
1.8.添加nginx 运行账户:
#vim add_nginxuser.sh
/usr/sbin/groupadd www /usr/sbin/useradd www -s /sbin/nologin -g www mkdir -p /home/wwwroot chmod +w /home/wwwroot chown -R www.www /home/wwwroot
sh add_nginxuser.sh
二.编译安装
2.1 编译安装pcre
#tar zxvf pcre-8.21.tar.gz #cd pcre-8.21 #./configure && make && make install
2.2 编译安装nginx
#tar zxvf nginx-1.0.4.tar.gz #cd nginx-1.0.4./configure "--user=www" "--group=www" "--prefix=/usr/local/nginx/" "--with-http_stub_status_module" "--with-file-aio"make
make installvi /etc/rc.localulimit -SHn 51200
/usr/local/nginx/sbin/nginx