nginx+php+mysql配置整理.docx
- 文档编号:24692821
- 上传时间:2023-05-31
- 格式:DOCX
- 页数:17
- 大小:21.31KB
nginx+php+mysql配置整理.docx
《nginx+php+mysql配置整理.docx》由会员分享,可在线阅读,更多相关《nginx+php+mysql配置整理.docx(17页珍藏版)》请在冰豆网上搜索。
nginx+php+mysql配置整理
一、安装准备
1.1平台环境:
CentOS5.4x86_64GNU/Linux
nginx-0.8.21
php-5.2.9
spawn-fcgi-1.6.3
mysql-5.1.34
1.2系统安装及分区:
1.2.1操作系统安装:
安装过程中选择最少的包,采用文本模式安装,不安装图形。
1.2.3系统分区:
/boot 100M (大约100左右)
SWAP 4G 物理内存的2倍(如果你的物理内存大于4G,分配4G即可)
/ 50G
/data 剩余所有空间.
注:
具体分区请根据相关业务划分
1.2.4系统软件包安装规范
系统约定:
软件源代码包存放位置 /usr/local/src
源码包编译安装位置(prefix) /usr/local/software_name
脚本以及维护程序存放位置 /usr/local/sbin
MySQL数据库位置 /data/mysql/data(可按情况设置)
网站根目录 /data/www/wwwroot(可按情况设置)
虚拟主机日志根目录 /data/logs(可按情况设置)
Nginx运行账户 www:
www
install_software_name.sh //存放编译参数脚本习惯将所有编译脚本存放在install_software_name.sh便于升级和更新软件.
1.3.系统初始化
#viinit_network.sh
#welcome
cat< +--------------------------------------------------------------+ | ===WelcometoCentosSysteminit=== | +--------------------------------------------------------------+ +----------------------Author: NetSeek--------------------------+ EOF #disableipv6 cat< +--------------------------------------------------------------+ | ===WelcometoDisableIPV6=== | +--------------------------------------------------------------+ EOF echo"aliasnet-pf-10off">>/etc/modprobe.conf echo"aliasipv6off">>/etc/modprobe.conf /sbin/chkconfig--level35ip6tablesoff echo"ipv6isdisabled! " #disableselinux sed-i'/SELINUX/s/enforcing/disabled/'/etc/selinux/config echo"selinuxisdisabled,youmustreboot! " #vim sed-i"8s/^/aliasvi='vim'/"/root/.bashrc echo'syntaxon'>/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'74s/^/#/'-i-e'76s/^/#/'$ssh_cf sed-i"s/#UseDNSyes/UseDNSno/"$ssh_cf #client sed-i-e'44s/^/#/'-i-e'48s/^/#/'$ssh_cf echo"sshisinitisok.............." #chkser #tunoffservices #-------------------------------------------------------------------------------- cat< +--------------------------------------------------------------+ | ===WelcometoTunoffservices=== | +--------------------------------------------------------------+ EOF #--------------------------------------------------------------------------------- foriin`ls/etc/rc3.d/S*` do CURSRV=`echo$i|cut-c15-` echo$CURSRV case$CURSRVin crond|irqbalance|microcode_ctl|network|random|sendmail|sshd|syslog|local|mysqld) echo"Baseservices,Skip! " ;; *) echo"change$CURSRVtooff" chkconfig--level235$CURSRVoff service$CURSRVstop ;; esac done 1.4系统环境部署及调整 检查系统是否正常 #tail-n100/var/log/messages (检查有无系统级错误信息) #dmesg (检查硬件设备是否有错误信息) #ifconfig (检查网卡设置是否正确) #pingwww.linuxtone.org (检查网络是否正常) 1.5使用yum程序安装所需开发包 1.5.1更换快源 #cd/etc/yum.repos.d/ #mvCentOS-Base.repoCentOS-Base.repo.linuxtone #wgethttp: //docs.linuxtone.org/soft/lemp/CentOS-Base.repo 1.5.2yum安装相关软件包: #yum-yinstallntpvim-enhancedgccgcc-c++gcc-g77flexbisonautoconfautomakeglibcglibc-develglib2glib2-develbzip2bzip2-develncursesncurses-devellibtool*zlib-devellibxml2-devellibjpeg-devellibpng-devellibtiff-develfontconfig-develfreetype-devellibXpm-develgettext-develcurlcurl-develpam-devele2fsprogs-develkrb5-devellibidnlibidn-developensslopenssl-developenldapopenldap-develnss_ldapopenldap-clientsopenldap-servers 1.6定时校正服务器时钟,定时与中国国家授时中心授时服务器同步 #crontab-e 加入一行: 153***/usr/sbin/ntpdate210.72.145.44>/dev/null2>&1 1.7下载相关软件包 #cd/usr/local/src #vilist_tar.list http: //docs.linuxtone.org/soft/lemp/ImageMagick.tar.gz http: //docs.linuxtone.org/soft/lemp/PDO_MYSQL-1.0.2.tgz http: //docs.linuxtone.org/soft/lemp/eaccelerator-0.9.5.3.tar.bz2 http: //docs.linuxtone.org/soft/lemp/imagick-2.2.2.tgz http: //docs.linuxtone.org/soft/lemp/libiconv-1.13.tar.gz http: //docs.linuxtone.org/soft/lemp/libmcrypt-2.5.8.tar.gz http: //docs.linuxtone.org/soft/lemp/mcrypt-2.6.8.tar.gz http: //docs.linuxtone.org/soft/lemp/memcache-2.2.5.tgz http: //docs.linuxtone.org/soft/lemp/mhash-0.9.9.9.tar.gz http: //docs.linuxtone.org/soft/lemp/mysql-5.1.34.tar.gz http: //docs.linuxtone.org/soft/lemp/pcre-7.8.tar.gz http: //docs.linuxtone.org/soft/lemp/php-5.2.9.tar.bz2 http: //sysoev.ru/nginx/nginx-0.8.21.tar.gz http: //docs.linuxtone.org/soft/lemp/ZendOptimizer-3.3.3-linux-glibc23-x86_64.tar.gz #wget-ilist_tar.list 1.8.添加nginx运维账户: #viadd_webuser.sh /usr/sbin/groupaddwww /usr/sbin/useradd-gwwwwww mkdir-p/data/www/wwwroot chmod+w/data/www/wwwroot chownwww: www/data/www/wwwroot-R #shadd_webuser.sh 二.编译安装 2.1编译安装pcre #tarzxvfpcre-7.8.tar.gz #cdpcre-7.8 #./configure&&make&&makeinstall 2.2编译安装nginx #tarzxvfnginx-0.8.21.tar.gz #cdnginx-0.8.21 2.2.1附加: 修改nginx源代码,伪装nginx服务器(仅供参考,安全还得认真做起^.^): (1).修改gcc #viauto/cc/gcc NGX_GCC_OPT="-O" 修改为: NGX_GCC_OPT="-O3" (2).修改nginx.h #vinginx-0.8.21/src/core/nginx.h #defineNGINX_VERSION "0.7.58" #defineNGINX_VER "nginx/"NGINX_VERSION 修改为: #defineNGINX_VERSION "1.0" #defineNGINX_VER "LTWS/"NGINX_VERSION (3).修改nginx_http_header_filter_module #vinginx-0.8.21/src/http/ngx_http_header_filter_module.c staticcharngx_http_server_string[]="Server: nginx"CRLF; 修改为: staticcharngx_http_server_string[]="Server: LTWS"CRLF; (4).修改ngx_http_special_response.c #vinginx-0.8.21/src/http/ngx_http_special_response.c 将如下 staticu_charngx_http_error_full_tail[]= " "