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

下载本文档

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

文档简介

Nginx配置手册目录Nginx配置手册11前言21.1配置说明21.2所需软件及文件22搭建nginx服务器32.1安装环境32.2安装Mysql32.3安装Oracle72.4安装依赖库82.5安装PHP102.6安装扩展112.7安装Nginx143编译参数说明153.1Yum 配置的环境参数详解153.2Mysql编译参数详解163.3Php编译参数详解163.4Nginx编译参数详解163.5扩展库详解201 前言1.1 配置说明本配置手册仅限于Nginx-0.8.54,Oracle11,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扩展文件存放目录: /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-instantclient11.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.rpm15) 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.conf 26) php-fpm.conf27) f28) 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-devel 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 libtool-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#在任何目录下运行都可以rootlocalhost src# /sbin/ldconfig2.2 安装Mysql#安装MySqlrootlocalhost 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%性能rootlocalhost /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-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-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/mysql-5.1.49# useradd -g mysql mysql#mysql 增加可写权限 并将用户改成mysql拥有rootlocalhost src# chmod +w /usr/local/webserver/mysqlrootlocalhost 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/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文件代码如下client default-character-set = utf8port = 3306 socket = /tmp/mysql.sock mysql no-auto-rehash mysqld default-character-set = utf8user = mysql port = 3306 socket = /tmp/mysql.sockbasedir = /usr/local/webserver/mysql datadir = /data/mysql/3306/data open_files_limit = 10240back_log = 600max_connections = 3000 max_connect_errors = 6000 table_cache = 614external-locking = FALSEmax_allowed_packet = 32M sort_buffer_size = 2Mjoin_buffer_size = 2Mthread_cache_size = 300thread_concurrency = 8 query_cache_size = 32M query_cache_limit = 2M query_cache_min_res_unit = 2kdefault-storage-engine = MyISAM default_table_type = MyISAMthread_stack = 192K transaction_isolation = READ-COMMITTEDtmp_table_size = 246Mmax_heap_table_size = 246M long_query_time = 1 log_long_format log-bin = /data/mysql/3306/binlog binlog_cache_size = 4M binlog_format = MIXED max_binlog_cache_size = 8Mmax_binlog_size = 512Mexpire_logs_days = 7key_buffer_size = 256Mread_buffer_size = 1Mread_rnd_buffer_size = 16Mbulk_insert_buffer_size = 64Mmyisam_sort_buffer_size = 128M myisam_max_sort_file_size = 10G myisam_max_extra_sort_file_size = 10Gmyisam_repair_threads = 1myisam_recoverskip-name-resolvemaster-connect-retry = 10slave-skip-errors = 1032,1062,126,1114,1146,1048,1396 server-id = 1innodb_additional_mem_pool_size = 16Minnodb_buffer_pool_size = 32Minnodb_data_file_path = ibdata1:1024M:autoextend innodb_file_io_threads = 4innodb_thread_concurrency = 8innodb_flush_log_at_trx_commit = 2innodb_log_buffer_size = 16M innodb_log_file_size = 128Minnodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 90innodb_lock_wait_timeout = 120innodb_file_per_table = 0mysqldump quick max_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 /bin/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 shutdown function_restart_mysql() printf Restarting MySQL.n function_stop_mysql sleep 5 function_start_mysql function_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 ; then function_start_mysql elif $1 = stop ; then function_stop_mysql elif $1 = restart ; then function_restart_mysql elif $1 = kill ; then function_kill_mysql else printf Usage: /data/mysql/$mysql_port/mysql start|stop|restart|killn fi#赋予shell脚本可执行权限:rootlocalhost src# chmod +x /data/mysql/3306/mysql#启动MySQL:rootlocalhost src# /data/mysql/3306/mysql start2.3 安装Oracle#安装oracle客户端rootlocalhost src# rpm -ivh oracle-instantclient11.2-basic-.0-1.x86_64.rpmrootlocalhost src# rpm -ivh oracle-instantclient11.2-devel-.0-1.x86_64.rpm rootlocalhost src# unzip oracle-instantclient11.2-sdk-.0-1.x86_64.ziprootlocalhost src# cp -rf instantclient_11_2/sdk/ /usr/include/#在shell中执行程序时,shell会提供一组环境变量。export可新增,修改或删除环境变量,供后续执行的程序使用。export的效力仅及于该此登陆操作rootlocalhost src# export ORACLE_HOME=/usr/lib/oracle/11.2/client64/rootlocalhost src# export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64:$LD_LIBRARY_PATH#在当前bash环境下读取并执行FileName中的命令rootlocalhost src# source /etc/profilerootlocalhost src# echo /usr/lib/oracle/11.2/client/lib64 /etc/ld.so.conf.d/oracle.confrootlocalhost 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.gzrootlocalhost 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.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 libmcrypt-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-installrootlocalhost 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-# make 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=/usrrootlocalhost mcrypt-2.6.8# makerootlocalhost mcrypt-2.6.8# make installrootlocalhost mcrypt-2.6.8# cd ./#安装ImageMagickrootlocalhost src# tar zxvf ImageMagick.tar.gzrootlocalhost src# cd ImageMagick-6.5.1-2/rootlocalhost ImageMagick-6.5.1-2# ./configurerootlocalhost ImageMagick-6.5.1-2# makerootlocalhost ImageMagick-6.5.1-2# make installrootlocalhost ImageMagick-6.5.1-2# cd ./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 -p1rootlocalhost src# cp -f fpm.gz 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.13rootlocalhost php-5.3.2# export PHP_AUTOHEADER=/usr/bin/autoheader-2.13rootlocalhost php-5.3.2# ./buildconf -forcerootlocalhost php-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/mysql -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 -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-pcre-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-production /usr/local/webserver/php/etc/php.inirootlocalhost 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/phpizerootlocalhost suhosin-# ./configure -with-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/webserver/memcacherootlocalhost src# tar zxvf memcache-2.2.5.tgzrootlocalhost src# cd memcache-2.2.5rootlocalhost memcache-2.2.5# /usr/local/webserver/php/bin/phpizerootlocalhost memcache-2.2.5# ./configure -with-php-config=/usr/local/webserver/php/bin/php-config -enable-memcache -with-zlib-dirrootlocalhost memcache-2.2.5# makerootlocalhost memcache-2.2.5# make installrootlocalhost memcache-2.2.5# cd ./#安装memcached扩展 性能上比memcache优越rootlocalhost src# tar -zxvf memcached-1.4.5.tar.gzrootlocalhost src# cd memcached-1.4.5rootlocalhost memcached-1.4.5# ./configure -prefix=/usr/local/webserver/memcached -with-libevent=/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/phpizerootlocalhost eaccelerator-# ./configure -enable-eaccelerator=shared -with-php-config=/usr/local/webserver/php/bin/php-configrootlocalhost eaccelerator-# makerootlocalhost eaccelerator-# make installrootlocalhost eaccelerator-# cd ./#安装imagick扩展#先安装ImageMagicrootlocalhost src# tar zxvf imagick-2.3.0.tgzrootlocalhost src# cd imagick-2.3.0rootlocalhost imagick-2.3.0# /usr/local/webserver/php/bin/phpizerootlocalhost imagick-2.3.0# ./configure -with-php-config=/usr/local/webserver/php/bin/php-configrootlocalhost eaccelerator-# makerootlocalhost eaccelerator-# make installrootlocalhost eaccelerator-# cd ./#安装Excel导出文件rootlocalhost src# cd /usr/local/librootlocalhost src# cp libpdf_php.so /usr/lib64/extensions/no-debug-non-zts-20090626/rootlocalhost src# cp bise.so /usr/lib64/extensions/no-debug-non-zts-20090626/rootlocalhost src# cp libxls.so.0.0.0 /usr/lib64/extensions/no-debug-non-zts-20090626/rootlocalhost lib# mv /usr/lib64/extensions/no-debug-non-zts-20090626/libxls.so.0.0.0 /usr/local/lib/libxls.sorootlocalhost lib# mv libxls.so libxls.so.0rootlocalhost lib# mv libxls.so libxls.so.0.0.0rootlocalhost lib# ln -s libxls.so.0 /usr/local/lib/libxls.so.0.0.0 rootlocalhost lib# ln -s /usr/local/lib/libxls.so.0.0.0 /usr/local/lib/libxls.so.0rootlocalhost lib# chmod +x libxls.so.0.0.0 rootlocalhost lib# ln -s /usr/local/lib/libxls.so.0 /usr/local/lib/libxls.sorootlocalhost lib# /sbin/ldconfig#修改php.ini文件rootlocalhost src# vi /usr/local/webserver/php/etc/php.ini#查找/usr/local/webserver/php/etc/php.ini中的extension_dir = ./#修改为; Directory in which the loadable extensions (modules) reside.; /extension-dirextension_dir = /usr/lib64/extensions/no-debug-non-zts-20090626; On windows:; extension_dir = ext#并在extension下增加以下几行,然后保存:;extension=php_sybase_ct.dll;extension=php_tidy.dll;extension=php_xmlrpc.dll;extension=php_xsl.dll;extension=php_zip.dllextension=suhosin.soextension=memcache.soextension=imagick.so#以下是关于excel导出扩展extension=bise.soextension=libpdf_php.so#配置eAccelerator加速PHProotlocalhost src# mkdir -p /usr/local/webserver/eaccelerator_cache#配置php.ini文件rootlocalhost src# vi /usr/local/webserver/php/etc/php.ini#按shift+g键跳到配置文件的最末尾,加上以下配置信息ZendGuardLoaderZend_extension=/usr/lib64/extensions/no-debug-non-zts-20090626/ZendGuardLoader.soZend_loader.enable=1 ; 许可信息,关闭提升少许信息; 默认值为0,关闭Zend_loader.disable_licensing=0; 模糊处理支持; 默认值为3Zend_loader.obfuscation_level_support=3Zend_loader.license_path=eacceleratorzend_extension=/usr/lib64/extensions/no-debug-non-zts-20090626/eaccelerator.so; 共享的内存数量。单位MB; 默认值为0, 操作系统默认eaccelerator.shm_size=64; 用户磁盘缓存的目录; 在该目录中存储预编译代码、session 数据、内容等eaccelerator.cache_dir=/usr/local/webserver/eaccelerator_cacheeaccelerator.enable=1; 开启或关闭内部优化器; 默认值为1,开启eaccelerator.optimizer=1; 开启或关闭PHP文件改动检查; 默认值为1,检查eaccelerator.check_mtime=1; 开启或关闭调试日志记录; 默认值为0,关闭eaccelerator.debug=0; 判断哪些php文件必须缓存; 可以指定缓存文件类型(如 *.Php、*.phtml等); 选择不被缓存,参数前加 !; 默认所有php被缓存eaccelerator.filter=; 该参数指定允许存储的最大值,单位:字节; 默认为0,不限制eacce

温馨提示

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

评论

0/150

提交评论