Nginx配置手册(64)_第1页
Nginx配置手册(64)_第2页
Nginx配置手册(64)_第3页
Nginx配置手册(64)_第4页
已阅读5页,还剩44页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Nginx 配置手册目录Nginx 配置手册11前言.21.1配置说明 .21.2所需软件及文件 .22搭建 nginx 服务器 .32.1安装环境 .32.2安装 Mysql .42.3安装 Oracle .82.4安装依赖库 .82.5安装 PHP .102.6安装扩展 .112.7安装 Nginx .153编译参数说明 .163.1Yum 配置的环境参数详解 .173.2Mysql 编译参数详解 .183.3Php 编译参数详解 .183.4Nginx 编译参数详解 .183.5扩展库详解 .221 前言1.1配置说明本配置手册仅限于 Nginx-0.8.54 , Oracle11 ,

2、Mysql5.1.49 , PHP-5.3.2 以及 32 位操作系统 Cent0S_5.5 。1.1.1有关文件目录安装程序源代码存放目录:/usr/local/src软件安装目录:1) Nginx 安装目录: /usr/local/webserver/nginx2) PHP 安装目录: /usr/local/webserver/php3) Mysql 安装目录 : /usr/local/webserver/mysql网站程序存放目录:/data/htdocs/htmlMysql 数据库存放目录:/data/mysql/3306/data/Nginx 日志存放目录: /data/logs扩展

3、文件存放目录: /usr/lib64/extensions/no-debug-non-zts-20090626/1.1.2 文件拥有者,拥有组Mysql用户/data/mysql/usr/local/webserver/mysqlwww 用户1) /data/logs2) /data/htdocs/html3) /data/php/session4) /data/php/upload1.2所需软件及文件1) eaccelerator-.tar.bz22) fpm.gz3) ImagMagick.tar.gz4) Imagick-2.3.0.tgz5) oracle-instant

4、client11.2-sdk-.0-1.x86_64.ziplibevent-1.4.14b-stable6) libiconv-1.13.1.tar.gz7) libmcrypt-2.5.88) mcrypt-2.6.8.tar.gz9) memcached-1.4.5.tar.gz10) memcache-2.2.5.tgz11) mhash-.tar.gz12) mysql-5.1.49.tar.gz13) nginx-0.8.54.tar.gz14) oracle-instantclient11.2-basic-.0-1.x86_64.rp

5、m15) oracle-instantclient11.2-devel-.0-1.x86_64.rpm16) pcre-8.10.tar.gz17) PDO_MYSQL-1.0.2.tgz18) php-5.3.2.tar.gz19) suhosin-.tar.gz20) suhosin-patch-5.3.2-.patch.gz21) libxls.so.0.0.022) bise.so23) libpdf_php.so24) ZendGuardLoader.so以下为文档25) nginx.conf26) php-fpm.conf27) my.

6、cnf28) mysql2 搭建 nginx 服务器2.1安装环境#建立所需目录rootlocalhost src# mkdir -p /usr/local/webserverrootlocalhost src# chmod 755 /usr/local/webserver#升级所需的程序库rootlocalhost src# yum -y install gcc gcc-c+ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-de

7、vel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers patch autoconf213.noarch unzip gzip libtool-ltdl libt

8、ool-ltdl-devel libaio#这个文件记录了编译时使用的动态链接库的路径。#默认情况下,编译器只会使用/lib 和 /usr/lib这两个目录下的库文件rootlocalhost src# vi /etc/ld.so.confinclude ld.so.conf.d/*.conf/usr/lib/usr/local/lib/usr/lib64“ /etc/ld.so.conf 3L, ”52C#将/etc/ld.so.conf列出的路径下的库文件缓存到/etc/ld.so.cache以供使用#修改ld.so.conf增加新的库路径后,需要运行一下/sbin/ldconfig#在任

9、何目录下运行都可以rootlocalhost src# /sbin/ldconfig2.2安装 Mysql#安装 MySql rootlocalhost src# yum install -y libtoolrootlocalhost src# mkdir /usr/local/webserver/mysqlrootlocalhost src# tar zxvf mysql-5.1.49.tar.gzrootlocalhost src# cd /usr/local/src/mysql-5.1.49#优化执行MySql 时间#如果是Inter 处理器,使用pgcc 提高 1% 性能rootloc

10、alhost /usr/local/src/mysql-5.1.49# CFLAGS=-O3 CXX=gcc CXXFLAGS=-O3 -felide-constructors -fno-exceptions -fno-rtti -fomit-frame-pointer -ffixed-ebprootlocalhost /usr/local/src/mysql-5.1.49# ./configure -prefix=/usr/local/webserver/mysql - enable-assembler -with-extra-charsets=complex -enable-thread-

11、safe-client -with-big-tables-with-readline -with-embedded-server -with-collation=utf8_general_ci-enable-local-infile-with-charset=utf8 -with-extra-charsets=all-with-ssl -with-unix-socket-path=/tmp/mysql.sock-with-client-ldflags=-all-static-with-mysqld-user=mysql-with-mysqld-ldflags=-all-static-with-

12、innodb#编译时出现以下提示,表示编译成功Thank you for choosing MySQL!rootlocalhost /usr/local/src/mysql-5.1.49#makerootlocalhost /usr/local/src/mysql-5.1.49#make installrootlocalhost /usr/local/src/mysql-5.1.49#cd ./#增加用户组,超级用户mysqlrootlocalhost /usr/local/src/mysql-5.1.49# groupadd mysqlrootlocalhost /usr/local/src

13、/mysql-5.1.49# useradd -g mysql mysql#mysql 增加可写权限 并将用户改成 mysql 拥有 rootlocalhost src# chmod +w /usr/local/webserver/mysql rootlocalhost src# chown -R mysql:mysql /usr/local/webserver/mysql#创建 MySQL 数据库存放目录rootlocalhost src# mkdir -p /data/mysql/3306/data/rootlocalhost src# chown -R mysql:mysql /data

14、/mysql/#以 mysql 用户账户的身份建立数据表rootlocalhost src# /usr/local/webserver/mysql/bin/mysql_install_db - basedir=/usr/local/webserver/mysql -datadir=/data/mysql/3306/data -user=mysql#复制 my.conf 配置文件rootlocalhost src# cp -f f /data/mysql/3306/fmy.conf 文件代码如下clientdefault-character-set = utf8port =

15、3306socket = /tmp/mysql.sockmysqlno-auto-rehashmysqlddefault-character-set = utf8user = mysqlport = 3306socket = /tmp/mysql.sockbasedir = /usr/local/webserver/mysqldatadir = /data/mysql/3306/dataopen_files_limit = 10240back_log = 600max_connections = 3000max_connect_errors = 6000table_cache = 614ext

16、ernal-locking = FALSEmax_allowed_packet = 32Msort_buffer_size = 2Mjoin_buffer_size = 2Mthread_cache_size = 300thread_concurrency = 8query_cache_size = 32Mquery_cache_limit = 2Mquery_cache_min_res_unit = 2kdefault-storage-engine = MyISAMdefault_table_type = MyISAMthread_stack = 192Ktransaction_isolat

17、ion = READ-COMMITTEDtmp_table_size = 246Mmax_heap_table_size = 246Mlong_query_time = 1log_long_formatlog-bin = /data/mysql/3306/binlogbinlog_cache_size = 4Mbinlog_format = MIXEDmax_binlog_cache_size = 8Mmax_binlog_size = 512Mexpire_logs_days = 7key_buffer_size = 256Mread_buffer_size = 1Mread_rnd_buf

18、fer_size = 16Mbulk_insert_buffer_size = 64Mmyisam_sort_buffer_size = 128Mmyisam_max_sort_file_size = 10Gmyisam_max_extra_sort_file_size = 10Gmyisam_repair_threads = 1myisam_recoverskip-name-resolvemaster-connect-retry = 10slave-skip-errors = 1032,1062,126,1114,1146,1048,1396server-id = 1innodb_addit

19、ional_mem_pool_size = 16Minnodb_buffer_pool_size = 32Minnodb_data_file_path = ibdata1:1024M:autoextendinnodb_file_io_threads = 4innodb_thread_concurrency = 8innodb_flush_log_at_trx_commit = 2innodb_log_buffer_size = 16Minnodb_log_file_size = 128Minnodb_log_files_in_group = 3innodb_max_dirty_pages_pc

20、t = 90innodb_lock_wait_timeout = 120innodb_file_per_table = 0mysqldumpquickmax_allowed_packet = 32M#复制管理MySQL 数据库的shell 脚本rootlocalhost src# cp -f mysql /data/mysql/3306/mysqlMysql 文件代码如下#!/bin/shmysql_port=3306mysql_username=adminmysql_password=123456function_start_mysql()printf Starting MySQL.n/bi

21、n/sh /usr/local/webserver/mysql/bin/mysqld_safe -defaults-file=/data/mysql/$mysql_port/f 2&1 /dev/null &function_stop_mysql()printf Stoping MySQL.n/usr/local/webserver/mysql/bin/mysqladmin-u$mysql_username-p$mysql_password-S/tmp/mysql.sock shutdownfunction_restart_mysql()printf Restarting MySQL

22、.nfunction_stop_mysqlsleep 5function_start_mysqlfunction_kill_mysql()kill -9 $(ps -ef | grep bin/mysqld_safe | grep $mysql_port | awk printf $2)kill -9 $(ps -ef | grep libexec/mysqld | grep $mysql_port | awk printf $2)if $1 = start ; thenfunction_start_mysqlelif $1 = stop ; thenfunction_stop_mysqlel

23、if $1 = restart ; thenfunction_restart_mysqlelif $1 = kill ; thenfunction_kill_mysqlelseprintf Usage: /data/mysql/$mysql_port/mysql start|stop|restart|killnfi#赋予 shell 脚本可执行权限:rootlocalhost src# chmod +x /data/mysql/3306/mysql#启动 MySQL:rootlocalhost src# /data/mysql/3306/mysql start2.3安装 Oracle#安装 o

24、racle 客户端rootlocalhost src# rpm -ivh oracle-instantclient11.2-basic-.0-1.x86_64.rpm rootlocalhost src# rpm -ivh oracle-instantclient11.2-devel-.0-1.x86_64.rpm rootlocalhost src# unzip oracle-instantclient11.2-sdk-.0-1.x86_64.zip rootlocalhost src# cp -rf instantclient_11_2/sd

25、k/ /usr/include/#在 shell 中执行程序时,shell 会提供一组环境变量。供后续执行的程序使用。export 的效力仅及于该此登陆操作export 可新增,修改或删除环境变量,rootlocalhostsrc# export ORACLE_HOME=/usr/lib/oracle/11.2/client64/rootlocalhost src# exportLD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64:$LD_LIBRARY_PATH#在当前bash 环境下读取并执行FileName中的命令rootlocalhost src#

26、 source /etc/profilerootlocalhost src# echo /usr/lib/oracle/11.2/client/lib64 /etc/ld.so.conf.d/oracle.conf rootlocalhost src# /sbin/ldconfig#查看 oracle 是否安装成功#cd /etc#vi ld.so.conf.d#vi oracle.conf#cd ./2.4安装依赖库#安装 libevent1.4.14b-stablerootlocalhost src#tar zxvf libevent-1.4.14b-stable.tar.gzrootlo

27、calhost src#cd libevent-1.4.14b-stablerootlocalhost libevent-1.4.14b-stable#./configure -prefix=/usr/localrootlocalhost libevent-1.4.14b-stable#makerootlocalhost libevent-1.4.14b-stable#make installrootlocalhost libevent-1.4.14b-stable#cd ./#安装 libiconv-1.13.1rootlocalhost src#tar zxvf libiconv-1.13

28、.1.tar.gzrootlocalhost src#cd libiconv-1.13.1rootlocalhost libiconv-1.13.1#./configure -prefix=/usrrootlocalhost libiconv-1.13.1#makerootlocalhost libiconv-1.13.1#make installrootlocalhost libiconv-1.13.1#cd ./#安装 libmcrypt-2.5.8rootlocalhost src#tar zxvf libmcrypt-2.5.8.tar.gzrootlocalhost src#cd l

29、ibmcrypt-2.5.8/rootlocalhost libmcrypt-2.5.8#./configure -prefix=/usrrootlocalhost libmcrypt-2.5.8#makerootlocalhost libmcrypt-2.5.8#make installrootlocalhost libmcrypt-2.5.8#/sbin/ldconfigrootlocalhost libmcrypt-2.5.8#cd libltdl/rootlocalhost libltdl#./configure -prefix=/usr -enable-ltdl-installroo

30、tlocalhost libltdl#makerootlocalhost libltdl#make installrootlocalhost libltdl#cd ././#安装 mhash-rootlocalhost src#tar zxvf mhash-.tar.gzrootlocalhost src#cd mhash-/rootlocalhost mhash-#./configure -prefix=/usrrootlocalhost mhash-#makerootlocalhost mhash-#mak

31、e installrootlocalhost mhash-#cd ./#安装 mcrypt-2.6.8rootlocalhost src# tar zxvf mcrypt-2.6.8.tar.gzrootlocalhost src# cd mcrypt-2.6.8/rootlocalhost mcrypt-2.6.8#/sbin/ldconfigrootlocalhost mcrypt-2.6.8#./configure -prefix=/usrcd ./make installmake./configurerootlocalhost mcrypt-2.6.8#makerootl

32、ocalhost mcrypt-2.6.8# rootlocalhost mcrypt-2.6.8#make installcd ./#安装 ImageMagickrootlocalhost src# tar zxvf ImageMagick.tar.gzrootlocalhost src# cd ImageMagick-6.5.1-2/rootlocalhost ImageMagick-6.5.1-2# rootlocalhost ImageMagick-6.5.1-2# rootlocalhost ImageMagick-6.5.1-2# rootlocalhost ImageMagick

33、-6.5.1-2# rootlocalhost src# /sbin/ldconfig2.5安装PHP#正式安装phprootlocalhost src# mkdir /usr/local/webserver/phprootlocalhost src# tar zxvf php-5.3.2.tar.gz#suhosin 针对 php进行安全加固的补丁程序rootlocalhost src# gzip -cd suhosin-patch-5.3.2-.patch.gz | patch -d php-5.3.2 -p1 rootlocalhost src# cp -f fpm.gz

34、php-5.3.2/sapi/fpm.gzrootlocalhost src# cd php-5.3.2/sapi/rootlocalhost sapi# tar -zxvf fpm.gzrootlocalhost sapi# cd ././rootlocalhost src# cd php-5.3.2rootlocalhost php-5.3.2# export PHP_AUTOCONF=/usr/bin/autoconf-2.13 rootlocalhost php-5.3.2# export PHP_AUTOHEADER=/usr/bin/autoheader-2.13 rootloca

35、lhost php-5.3.2# ./buildconf -forcerootlocalhostphp-5.3.2#./configure-prefix=/usr/local/webserver/php-with-config-file-path=/usr/local/webserver/php/etc -with-mysql=/usr/local/webserver/mysql -with-mysqli=/usr/local/webserver/mysql/bin/mysql_config -enable-pdo -with-pdo-mysql=/usr/local/webserver/my

36、sql -with-iconv-dir -with-freetype-dir -with-jpeg-dir -with-png-dir - with-zlib -with-libxml-dir -enable-xml -disable-rpath -enable-discard-path -enable-safe-mode - enable-bcmath -enable-shmop -enable-sysvsem -enable-sysvshm -enable-inline-optimization - with-curl -with-curlwrappers -enable-mbregex

37、-enable-fastcgi-enable-fpm-enable-force-cgi-redirect-enable-mbstring-with-mcrypt-with-gd-enable-gd-native-ttf-with-openssl-with-mhash-enable-sockets-with-xmlrpc-enable-zip-enable-soap-with-pear -disable-debug -enable-pcntl -disable-ipv6 -enable-ftp -with-zend-vm=GOTO -enable-json -with-bz2 -with-pcr

38、e-regex -enable-calendar -with-gettext-enable-dba-enable-exif-with-mime-magic-enable-dom-libdir=/usr/lib64-with-libevent-dir=/usr/local/lib#出现以下提示表示编译成功Thank you for using PHProotlocalhost php-5.3.2# make ZEND_EXTRA_LIBS=-liconvrootlocalhost php-5.3.2# make installrootlocalhost php-5.3.2# cp php.ini

39、-production /usr/local/webserver/php/etc/php.ini rootlocalhost php-5.3.2# cd ./2.6 安装扩展#安装 suhosin 扩展rootlocalhost src#tar zxvf suhosin-.tar.gzrootlocalhost src#cd suhosin-rootlocalhost suhosin-#/usr/local/webserver/php/bin/phpizerootlocalhostsuhosin-#./configure-with

40、-php-config=/usr/local/webserver/php/bin/php-configrootlocalhost suhosin-#makerootlocalhost suhosin-#make installrootlocalhost suhosin-#cd ./#memcache基于 libevent 构建,在装 memcache 之前需要安装 libevent#用于缓存sql 查询,对于降低数据库压力,提升查询速度有很大好处#安装 memcache 扩展rootlocalhost src#mkdir /usr/local/w

41、ebserver/memcacherootlocalhost src#tar zxvf memcache-2.2.5.tgzrootlocalhost src#cd memcache-2.2.5rootlocalhost memcache-2.2.5#/usr/local/webserver/php/bin/phpizerootlocalhostmemcache-2.2.5#./configure-with-php-config=/usr/local/webserver/php/bin/php-config -enable-memcache -with-zlib-dirrootlocalhos

42、t memcache-2.2.5#makerootlocalhost memcache-2.2.5#make installrootlocalhost memcache-2.2.5#cd ./#安装 memcached扩展性能上比 memcache优越rootlocalhost src#tar -zxvfmemcached-1.4.5.tar.gzrootlocalhost src#cd memcached-1.4.5rootlocalhostmemcached-1.4.5#./configure-prefix=/usr/local/webserver/memcached-with-libev

43、ent=/usr/localrootlocalhost memcached-1.4.5#makerootlocalhost memcached-1.4.5#make installrootlocalhost memcached-1.4.5#cd ./#PHP scripts的缓存,对于提高PHP 程序执行速度很有帮助#安装 eaccelerator扩展rootlocalhost src#tar jxvf eaccelerator-.tar.bz2rootlocalhost src#cd eaccelerator-rootlocalhost eaccelerator-#/usr/local/webserver/php/bin/phpizerootlocalhosteaccelerator-#./configure-enable-eaccelerator=shared-with-php-config=/usr/local/webserver/php/bin/php-configro

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论