nginx+php+mysql配置整理.docx

上传人:b****3 文档编号:24692821 上传时间:2023-05-31 格式:DOCX 页数:17 大小:21.31KB
下载 相关 举报
nginx+php+mysql配置整理.docx_第1页
第1页 / 共17页
nginx+php+mysql配置整理.docx_第2页
第2页 / 共17页
nginx+php+mysql配置整理.docx_第3页
第3页 / 共17页
nginx+php+mysql配置整理.docx_第4页
第4页 / 共17页
nginx+php+mysql配置整理.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

nginx+php+mysql配置整理.docx

《nginx+php+mysql配置整理.docx》由会员分享,可在线阅读,更多相关《nginx+php+mysql配置整理.docx(17页珍藏版)》请在冰豆网上搜索。

nginx+php+mysql配置整理.docx

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[]=

"


"NGINX_VER"
"CRLF

""CRLF

""CRLF

;

staticu_charngx_http_error_tail[]=

"


nginx
"CRLF

""CRLF

""CRLF

;

修改为:

staticu_charngx_http_error_full_tail[]=

"


"NGINX_VER"
"CRLF

"


"CRLF

""CRLF

""CRLF

;

staticu_charngx_http_error_tail[]=

"


HMGWS
"CRLF

""CRLF

""CRLF

;

2.2.2nginx编译安装

./configure\

    "--user=www"\

    "--group=www"\

    "--prefix=/usr/local/nginx/"\

    "--with-http_stub_status_module"\

    "--with-http_ssl_module"\

    "--with-md5=/usr/lib"\

    "--with-sha1=/usr/lib"

make

makeinstall

2.3编译安装配置mysql

./configure\

    "--prefix=/usr/local/mysql"\

    "--localstatedir=/data/mysql/data"\

    "--with-comment=Source"\

    "--with-server-suffix=-Linuxtone.Org"\

    "--enable-assembler"\

    "--with-charset=gbk"\

    "--with-collation=gbk_chinese_ci"\

    "--with-collation=gbk_chinese_ci"\

    "--with-extra-charsets=complex"\

    "--enable-thread-safe-client"\

    "--with-big-tables"\

    "--with-readline"\

    "--with-ssl"\

    "--with-embedded-server"\

    "--enable-local-infile"\

    "--with-plugins=innobase"

make

makeinstall

useraddmysql-d/data/mysql-s/sbin/nologin

/usr/local/mysql/bin/mysql_install_db--user=mysql

cd/usr/local/mysql

chown-Rroot:

mysql.

mkdir-p/data/mysql/data

chown-Rmysql/data/mysql/data

cpshare/mysql/my-f/etc/f.bak

wget

sed-i'50s/^/#/'/etc/f

cpshare/mysql/mysql.server/etc/rc.d/init.d/mysqld

chmod755/etc/rc.d/init.d/mysqld

chkconfig--addmysqld

/etc/rc.d/init.d/mysqldstart

cd/usr/local/mysql/bin

foriin*;doln-s/usr/local/mysql/bin/$i/usr/bin/$i;done

2.4编译安装php

2.4.1安装php相应的lib

  2.4.1.1libiconv-1.13

#tarzxvflibiconv-1.13.tar.gz

#cdlibiconv-1.13

#./configure--prefix=/usr&&make&&makeinstall

2.4.1.2libmcrypt-2.5.8

#tarzxvflibmcrypt-2.5.8.tar.gz

#cdlibmcrypt-2.5.8/

#./configure--prefix=/usr&&make&&makeinstall

#echo"/usr/lib">>/etc/ld.so.conf

#ldconfig

#cdlibltdl/

#./configure--enable-ltdl-install

#make&&makeinstall

2.4.1.3mhash-0.9.9.9

#tarzxvfmhash-0.9.9.9.tar.gz

#cdmhash-0.9.9.9

#./configure--prefix=/usr&&make&&makeinstall

#ldconfig

2.4.1.4mcrypt-2.6.8

#tarzxvfmcrypt-2.6.8.tar.gz

#cdmcrypt-2.6.8

#./configure--prefix=/usr&&make&&makeinstall

2.4.2安装spawn-fcgi

#tarzvxfspawn-fcgi-1.6.3.tar.gz

#cdspawn-fcgi-1.6.3

#./configure&&make&&makeinstall

2.4.3安装php

#tarjvxfphp-5.2.9.tar.bz2

#viinstall_php.sh

./configure  \

    "--prefix=/usr/local/php"\

    "--enable-fastcgi"\

    "--enable-fpm"\

    "--enable-discard-path"\

    "--enable-force-cgi-redirect"\

    "--with-config-file-path=/usr/local/php/etc"\

    "--with-mysql=/usr/local/mysql"\

    "--with-mysqli=/usr/local/mysql/bin/mysql_config"\

    "--with-iconv-dir"\

    "--with-freetype-dir"\

    "--with-jpeg-dir"\

    "--with-png-dir"\

    "--with-gd"\

    "--with-zlib"\

    "--with-libxml-dir"\

    "--with-curl"\

    "--with-curlwrappers"\

    "--with-openssl"\

    "--with-mhash"\

    "--with-xmlrpc"\

    "--with-mcrypt"\

    "--with-ldap"\

    "--with-ldap-sasl"\

    "--enable-xml"\

    "--disable-rpath"\

    "--enable-discard-path"\

    "--enable-safe-mode"\

    "--enable-bcmath"\

    "--enable-shmop"\

    "--enable-sysvsem"\

    "--enable-inline-optimization"\

    "--enable-mbregex"\

    "--enable-mbstring"\

    "--enable-gd-native-ttf"\

    "--enable-ftp"\

    "--enable-pcntl"\

    "--enable-sockets"\

    "--enable-zip"\

    "--disable-debug"\

    "--disable-ipv6"

makeZEND_EXTRA_LIBS='-liconv'

makeinstall

cpphp.ini-dist/usr/local/php/etc/php.ini

#shinstall_php.sh

2.4.4安装PHP扩展模块

  2.4.4.1memc

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 其它

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1