SlideShare a Scribd company logo
Suche senden
Hochladen
Einloggen
Registrieren
Nginx 0.8.x 安装手册
Melden
Yiwei Ma
Folgen
System Admin um Beijing
5. Mar 2011
•
0 gefällt mir
•
337 views
Nginx 0.8.x 安装手册
5. Mar 2011
•
0 gefällt mir
•
337 views
Yiwei Ma
Folgen
System Admin um Beijing
Melden
Technologie
Nginx 0.8.x 安装手册
1 von 25
1
von
25
Recomendados
Nginx 0.9.x 安装手册
Yiwei Ma
308 views
•
22 Folien
X64服务器 lnmp服务器部署标准 new
Yiwei Ma
1.5K views
•
16 Folien
Apache
Mindtree
535 views
•
22 Folien
Hyperledger composer
wonyong hwang
198 views
•
70 Folien
Docker practice
wonyong hwang
230 views
•
46 Folien
Die .htaccess richtig nutzen
Walter Ebert
5.3K views
•
37 Folien
Más contenido relacionado
Was ist angesagt?
Spider Setup with AWS/sandbox
I Goo Lee
497 views
•
56 Folien
nouka inventry manager
Toshiaki Baba
2.3K views
•
25 Folien
Web Server Free Bsd
Kwanchai Charoennet
41.2K views
•
52 Folien
Centos config
Muhammad Abdi
30 views
•
7 Folien
MongoDB – Sharded cluster tutorial - Percona Europe 2017
Antonios Giannopoulos
106 views
•
186 Folien
Installing Cacti openSUSE Leap 42.1
Didiet A. Pambudiono
1.1K views
•
5 Folien
Was ist angesagt?
(20)
Spider Setup with AWS/sandbox
I Goo Lee
•
497 views
nouka inventry manager
Toshiaki Baba
•
2.3K views
Web Server Free Bsd
Kwanchai Charoennet
•
41.2K views
Centos config
Muhammad Abdi
•
30 views
MongoDB – Sharded cluster tutorial - Percona Europe 2017
Antonios Giannopoulos
•
106 views
Installing Cacti openSUSE Leap 42.1
Didiet A. Pambudiono
•
1.1K views
ByPat博客出品Lvs+keepalived
redhat9
•
599 views
Hadoop Admin role & Hive Data Warehouse support
mdcdwh
•
54 views
My SQL 101
Dave Stokes
•
1.3K views
BlockChain implementation by python
wonyong hwang
•
322 views
Installation of Subversion on Ubuntu,...
wensheng wei
•
371 views
Ansible loves Python, Python Philadelphia meetup
Greg DeKoenigsberg
•
804 views
Puppet
Łukasz Jagiełło
•
1.1K views
Tested install-isp config3-ubuntu-16-04
SANTIAGO HERNÁNDEZ
•
86 views
agri inventory - nouka data collector / yaoya data convertor
Toshiaki Baba
•
1.2K views
Lamp configuration u buntu 10.04
mikehie
•
1.8K views
Site Performance - From Pinto to Ferrari
Joseph Scott
•
3.5K views
grate techniques
junaid novapex
•
151 views
Ansible : what's ansible & use case by REX
Saewoong Lee
•
176 views
Intro django
Alexander Lyabah
•
695 views
Destacado
Using reader responses to make revisions
writRHET -
212 views
•
19 Folien
Услуги в области инноваций региона Кюменлааксо (Финляндия)
St. Petersburg Foundation for SME Development
343 views
•
13 Folien
Zhongxing practice-suchunshan-qcon
Yiwei Ma
364 views
•
35 Folien
BuilHigh Performance Weibo Platform-Qcon2011
Yiwei Ma
444 views
•
38 Folien
Cacti安装手册
Yiwei Ma
203 views
•
12 Folien
Netflix web-adrian-qcon
Yiwei Ma
478 views
•
49 Folien
Destacado
(8)
Using reader responses to make revisions
writRHET -
•
212 views
Услуги в области инноваций региона Кюменлааксо (Финляндия)
St. Petersburg Foundation for SME Development
•
343 views
Zhongxing practice-suchunshan-qcon
Yiwei Ma
•
364 views
BuilHigh Performance Weibo Platform-Qcon2011
Yiwei Ma
•
444 views
Cacti安装手册
Yiwei Ma
•
203 views
Netflix web-adrian-qcon
Yiwei Ma
•
478 views
Puppet安装测试
Yiwei Ma
•
434 views
Виртуальная ИТ-инфраструктура предприятия на базе свободного ПО "под ключ"
St. Petersburg Foundation for SME Development
•
436 views
Similar a Nginx 0.8.x 安装手册
Mysql
Mindtree
1.1K views
•
38 Folien
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud
Dropsolid
3.5K views
•
55 Folien
How to install and configure LEMP stack
RootGate
271 views
•
11 Folien
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Dana Luther
403 views
•
151 Folien
Architecting cloud
Tahsin Hasan
980 views
•
57 Folien
Ansible presentation
John Lynch
34.8K views
•
30 Folien
Similar a Nginx 0.8.x 安装手册
(20)
Mysql
Mindtree
•
1.1K views
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud
Dropsolid
•
3.5K views
How to install and configure LEMP stack
RootGate
•
271 views
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Dana Luther
•
403 views
Architecting cloud
Tahsin Hasan
•
980 views
Ansible presentation
John Lynch
•
34.8K views
Install cacti on open suse 13
Vanda KANY
•
80 views
Caching and tuning fun for high scalability
Wim Godden
•
2.4K views
Cooking with Chef
Ken Robertson
•
3.5K views
Multiple instances on linux
Vasudeva Rao
•
539 views
PHP selber bauen
Walter Ebert
•
4.7K views
MySQL Spider Architecture
I Goo Lee
•
419 views
Converting Your Dev Environment to a Docker Stack - php[world]
Dana Luther
•
311 views
Python Deployment with Fabric
andymccurdy
•
34K views
Automating complex infrastructures with Puppet
Kris Buytaert
•
3.2K views
桃園市教育局Docker技術入門與實作
Philip Zheng
•
1K views
OpenStack Tokyo Meeup - Gluster Storage Day
Dan Radez
•
1.2K views
Converting Your Dev Environment to a Docker Stack - Cascadia
Dana Luther
•
195 views
Award-winning technology: Oxid loves the query cache
Ulf Wendel
•
3.2K views
Continuous Delivery: The Next Frontier
Carlos Sanchez
•
1.6K views
Más de Yiwei Ma
Cibank arch-zhouweiran-qcon
Yiwei Ma
409 views
•
30 Folien
Cibank arch-zhouweiran-qcon
Yiwei Ma
312 views
•
30 Folien
Taobao casestudy-yufeng-qcon
Yiwei Ma
799 views
•
31 Folien
Alibaba server-zhangxuseng-qcon
Yiwei Ma
632 views
•
28 Folien
Taobao practice-liyu-qcon
Yiwei Ma
410 views
•
29 Folien
Thoughtworks practice-hukai-qcon
Yiwei Ma
421 views
•
20 Folien
Más de Yiwei Ma
(20)
Cibank arch-zhouweiran-qcon
Yiwei Ma
•
409 views
Cibank arch-zhouweiran-qcon
Yiwei Ma
•
312 views
Taobao casestudy-yufeng-qcon
Yiwei Ma
•
799 views
Alibaba server-zhangxuseng-qcon
Yiwei Ma
•
632 views
Taobao practice-liyu-qcon
Yiwei Ma
•
410 views
Thoughtworks practice-hukai-qcon
Yiwei Ma
•
421 views
Ufida design-chijianqiang-qcon
Yiwei Ma
•
552 views
Spring design-juergen-qcon
Yiwei Ma
•
546 views
Google arch-fangkun-qcon
Yiwei Ma
•
491 views
Cibank arch-zhouweiran-qcon
Yiwei Ma
•
350 views
Alibaba arch-jiangtao-qcon
Yiwei Ma
•
425 views
Twitter keynote-evan-qcon
Yiwei Ma
•
322 views
Netflix keynote-adrian-qcon
Yiwei Ma
•
381 views
Facebook keynote-nicolas-qcon
Yiwei Ma
•
640 views
Domainlang keynote-eric-qcon
Yiwei Ma
•
445 views
Devjam keynote-david-qcon
Yiwei Ma
•
299 views
Baidu keynote-wubo-qcon
Yiwei Ma
•
340 views
淘宝线上线下性能跟踪体系和容量规划-Qcon2011
Yiwei Ma
•
580 views
网游服务器性能优化-Qcon2011
Yiwei Ma
•
401 views
Xietingbao-Qcon2011
Yiwei Ma
•
470 views
Último
V3Cube Gojek Clone - Rebrand With Superiority
V3cube
61 views
•
10 Folien
Knowledge Graphs and Generative AI_GraphSummit Minneapolis Sept 20.pptx
Neo4j
33 views
•
31 Folien
h2 meet pdf test.pdf
JohnLee971654
64 views
•
4 Folien
Common WordPress APIs_ Settings API
Jonathan Bossenger
29 views
•
10 Folien
"From Orchestration to Choreography and Back", Yevhen Bobrov
Fwdays
48 views
•
57 Folien
UiPath Tips and Techniques for Debugging - Session 3
DianaGray10
49 views
•
9 Folien
Último
(20)
V3Cube Gojek Clone - Rebrand With Superiority
V3cube
•
61 views
Knowledge Graphs and Generative AI_GraphSummit Minneapolis Sept 20.pptx
Neo4j
•
33 views
h2 meet pdf test.pdf
JohnLee971654
•
64 views
Common WordPress APIs_ Settings API
Jonathan Bossenger
•
29 views
"From Orchestration to Choreography and Back", Yevhen Bobrov
Fwdays
•
48 views
UiPath Tips and Techniques for Debugging - Session 3
DianaGray10
•
49 views
Empowering City Clerks
OnBoard
•
82 views
How resolve Gem dependencies in your code?
Hiroshi SHIBATA
•
154 views
Meetup_adessoCamunda_2023-09-13_Part1&2_en.pdf
MariaAlcantara50
•
40 views
Unleashing Innovation: IoT Project with MicroPython
Vubon Roy
•
38 views
How to reduce expenses on monitoring
RomanKhavronenko
•
23 views
Google cloud Study Jam 2023.pptx
GDSCNiT
•
438 views
Accelerating Data Science through Feature Platform, Transformers and GenAI
FeatureByte
•
95 views
Framing Few Shot Knowledge Graph Completion with Large Language Models
MODUL Technology GmbH
•
44 views
Cloud Composer workshop at Airflow Summit 2023.pdf
Leah Cole
•
94 views
The Flutter Job Market At The Moment
Ahmed Abu Eldahab
•
23 views
Understanding Wireguard, TLS and Workload Identity
Christian Posta
•
190 views
Machine learning with quantum computers
Speck&Tech
•
104 views
"Stateful app as an efficient way to build dispatching for riders and drivers...
Fwdays
•
37 views
Privacy in the era of quantum computers
Speck&Tech
•
95 views
Nginx 0.8.x 安装手册
1.
Nginx 0.8.x +
PHP 5.2.10(FastCGI)<br />安装步骤:<br />(系统要求:Linux 2.6+ 内核,本文中的Linux操作系统为CentOS 5.3,另在RedHat AS4上也安装成功)<br /> <br />一、yum安装相关文件:<br />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<br /> <br />二、安装PHP 5.2.10(FastCGI模式)<br />1、编译安装PHP 5.2.10所需的支持库:<br />tar zxvf libiconv-1.13.tar.gz && cd libiconv-1.13<br />./configure --prefix=/usr/local<br />make && make install<br />cd ../<br /> <br />tar zxvf libmcrypt-2.5.8.tar.gz && cd libmcrypt-2.5.8<br />./configure<br />make && make install<br />/sbin/ldconfig<br />cd libltdl/<br />./configure --enable-ltdl-install<br />make && make install<br />cd ../../<br /> <br />tar zxvf mhash-0.9.9.tar.gz && cd mhash-0.9.9<br />./configure<br />make && make install<br />cd ../<br /> <br />ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la<br />ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so<br />ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4<br />ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8<br />ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a<br />ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la<br />ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so<br />ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2<br />ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1<br /> <br />tar zxvf mcrypt-2.6.8.tar.gz && cd mcrypt-2.6.8/<br />/sbin/ldconfig<br />./configure<br />make && make install<br />cd ../<br />2、源码/编译安装MySQL <br />⑴源码安装<br />tar xzvf mysql-5.0.51a-linux-x86_64-icc-glibc23.tar.gz<br />mv mysql-5.0.51a-linux-x86_64-icc-glibc23 /usr/local/<br />cd ..<br />ln -s mysql-5.0.51a-linux-x86_64-icc-glibc23 /usr/local/mysql<br />useradd mysql<br />chown -R mysql:root /usr/local/mysql/<br />cd /usr/local/mysql<br />./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/<br />cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld<br />chown root:root /etc/rc.d/init.d/mysqld<br />chmod 755 /etc/rc.d/init.d/mysqld<br />chkconfig --add mysqld<br />chkconfig --level 3 mysqld on<br />cp ./support-files/my-huge.cnf /etc/my.cnf<br />mv /usr/local/mysql/data /data/mysql<br />chown -R mysql:mysql /data/mysql/<br /># vi /etc/my.cnf 修改以下内容:<br /> <br />在 [mysqld] 段增加或修改:<br />datadir = /data/mysql<br />skip-innodb<br />wait-timeout = 3 | 5 | 10<br />max_connections = 256 | 384 | 512<br />max_connect_errors = 10000000<br />thread_concurrency = CPU个数×2<br />将 log-bin 注释<br /># bin/mysqladmin -u root password 'password_for_root'<br />⑵编译安装<br />/usr/sbin/groupadd mysql<br />/usr/sbin/useradd -g mysql mysql<br />tar zxvf mysql-5.5.2-m2.tar.gz<br />cd mysql-5.5.2-m2/<br />./configure --prefix=/usr/local/webserver/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrg<br />make && make install<br />chmod +w /usr/local/webserver/mysql<br />chown -R mysql:mysql /usr/local/webserver/mysql<br />cd ../<br />附:以下为附加步骤,如果你想在这台服务器上运行MySQL数据库,则执行以下两步。如果你只是希望让PHP支持MySQL扩展库,能够连接其他服务器上的MySQL数据库,那么,以下两步无需执行。<br /> <br />①、创建MySQL数据库存放目录<br />mkdir -p /data/mysql/data/<br />chown -R mysql:mysql /data/mysql/<br /> <br />②、以mysql用户帐号的身份建立数据表:<br />/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql/data --user=mysql<br /> <br />③、创建my.cnf配置文件:<br />vi /data0/mysql/3306/my.cnf<br />输入以下内容:<br />[client]<br />default-character-set = utf8<br />port = 3306<br />socket = /tmp/mysql.sock<br /> <br />[mysql]<br />prompt=quot; (:blog.s135.com:)[]> quot; <br />no-auto-rehash<br /> <br />[mysqld]<br />#default-character-set = utf8<br />user = mysql<br />port = 3306<br />socket = /tmp/mysql.sock<br />basedir = /usr/local/mysql<br />datadir = /data0/mysql/3306/data<br />open_files_limit = 10240<br />back_log = 600<br />max_connections = 3000<br />max_connect_errors = 6000<br />table_cache = 614<br />external-locking = FALSE<br />max_allowed_packet = 32M<br />sort_buffer_size = 2M<br />join_buffer_size = 2M<br />thread_cache_size = 300<br />thread_concurrency = 8<br />query_cache_size = 32M<br />query_cache_limit = 2M<br />query_cache_min_res_unit = 2k<br />default-storage-engine = MyISAM<br />default_table_type = MyISAM<br />thread_stack = 192K<br />transaction_isolation = READ-COMMITTED<br />tmp_table_size = 246M<br />max_heap_table_size = 246M<br />long_query_time = 1<br />log_long_format<br />log-bin = /data0/mysql/3306/binlog<br />binlog_cache_size = 4M<br />binlog_format = MIXED<br />max_binlog_cache_size = 8M<br />max_binlog_size = 512M<br />expire_logs_days = 7<br />key_buffer_size = 256M<br />read_buffer_size = 1M<br />read_rnd_buffer_size = 16M<br />bulk_insert_buffer_size = 64M<br />myisam_sort_buffer_size = 128M<br />myisam_max_sort_file_size = 10G<br />myisam_max_extra_sort_file_size = 10G<br />myisam_repair_threads = 1<br />myisam_recover<br /> <br />skip-name-resolve<br />master-connect-retry = 10<br />slave-skip-errors = 1032,1062,126,1114,1146,1048,1396<br /> <br />server-id = 1<br /> <br />innodb_additional_mem_pool_size = 16M<br />innodb_buffer_pool_size = 2048M<br />innodb_data_file_path = ibdata1:1024M:autoextend<br />innodb_file_io_threads = 4<br />innodb_thread_concurrency = 8<br />innodb_flush_log_at_trx_commit = 2<br />innodb_log_buffer_size = 16M<br />innodb_log_file_size = 128M<br />innodb_log_files_in_group = 3<br />innodb_max_dirty_pages_pct = 90<br />innodb_lock_wait_timeout = 120<br />innodb_file_per_table = 0<br />[mysqldump]<br />quick<br />max_allowed_packet = 32M<br /> <br />④、创建管理MySQL数据库的shell脚本:<br />vi /data/mysql/<br />输入以下内容:<br />#!/bin/sh<br />mysql_port=3306<br />mysql_username=quot; adminquot; <br />mysql_password=quot; 12345678quot; <br />function_start_mysql()<br />{<br /> printf quot; Starting MySQL...quot; <br /> /bin/sh /usr/local/webserver/mysql/bin/mysqld_safe --defaults-file=/data0/mysql/${mysql_port}/my.cnf 2>&1 > /dev/null &<br />}<br />function_stop_mysql()<br />{<br /> printf quot; Stoping MySQL...quot; <br /> /usr/local/webserver/mysql/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /tmp/mysql.sock shutdown<br />}<br />function_restart_mysql()<br />{<br /> printf quot; Restarting MySQL...quot; <br /> function_stop_mysql<br /> sleep 5<br /> function_start_mysql<br />}<br />function_kill_mysql()<br />{<br /> kill -9 $(ps -ef | grep 'bin/mysqld_safe' | grep ${mysql_port} | awk '{printf $2}')<br /> kill -9 $(ps -ef | grep 'libexec/mysqld' | grep ${mysql_port} | awk '{printf $2}')<br />}<br />if [ quot; $1quot; = quot; startquot; ]; then<br /> function_start_mysql<br />elif [ quot; $1quot; = quot; stopquot; ]; then<br /> function_stop_mysql<br />elif [ quot; $1quot; = quot; restartquot; ]; then<br />function_restart_mysql<br />elif [ quot; $1quot; = quot; killquot; ]; then<br />function_kill_mysql<br />else<br /> printf quot; Usage: /data0/mysql/${mysql_port}/mysql {start|stop|restart|kill}quot; <br />fi<br />⑤、赋予shell脚本可执行权限:<br />chmod +x /data0/mysql/3306/mysql<br /> <br />⑥、启动MySQL:<br />/data0/mysql/3306/mysql start<br /> <br />⑦、通过命令行登录管理MySQL服务器(提示输入密码时直接回车):<br />/usr/local/webserver/mysql/bin/mysql -u root -p -S /tmp/mysql.sock<br /> <br />⑧、输入以下SQL语句,创建一个具有root权限的用户和密码(12345678):<br />GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' IDENTIFIED BY '12345678';<br />GRANT ALL PRIVILEGES ON *.* TO 'admin'@'127.0.0.1' IDENTIFIED BY '12345678';<br /> <br />⑨、(可选)停止MySQL:<br />/data0/mysql/3306/mysql stop<br />3、编译安装PHP(FastCGI模式)<br />tar zxvf php-5.2.13.tar.gz<br />gzip -cd php-5.2.13-fpm-0.5.13.diff.gz | patch -d php-5.2.13 -p1<br />cd php-5.2.13/<br />./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --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-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --without-pear --enable-ftp<br />make ZEND_EXTRA_LIBS='-liconv'<br />make install<br />cp php.ini-dist /usr/local/php/etc/php.ini<br />cd ../<br />4、编译安装PHP5扩展模块<br />tar zxvf memcache-2.2.5.tgz && cd memcache-2.2.5/<br />/usr/local/php/bin/phpize<br />./configure --with-php-config=/usr/local/php/bin/php-config<br />make && make install<br />cd ../<br /> <br />tar jxvf eaccelerator-0.9.6.tar.bz2 && cd eaccelerator-0.9.6/<br />/usr/local/php/bin/phpize<br />./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config<br />make && make install<br />cd ../<br /> <br />tar zxvf PDO_MYSQL-1.0.2.tgz && cd PDO_MYSQL-1.0.2/<br />/usr/local/php/bin/phpize<br />./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql<br />make && make install<br />cd ../<br /> <br />tar zxvf ImageMagick.tar.gz && cd ImageMagick-6.5.1-2/<br />./configure<br />make && make install<br />cd ../<br />tar zxvf imagick-2.3.0.tgz && cd imagick-2.3.0/<br />/usr/local/php/bin/phpize<br />./configure --with-php-config=/usr/local/php/bin/php-config<br />make && make install<br />cd ../<br /> <br />5、修改php.ini文件<br />查找/usr/local/php/etc/php.ini中的extension_dir = quot; ./quot; <br />修改为:<br />extension_dir = quot; /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/quot; <br />并在此行后增加以下几行,然后保存:<br />extension = quot; memcache.soquot; <br />extension = quot; pdo_mysql.soquot; <br />extension = quot; imagick.soquot; <br /> <br />再查找output_buffering = Off<br />修改为output_buffering = On<br /> <br />6、配置eAccelerator加速PHP:<br />mkdir /tmp/eaccelerator<br />vi /usr/local/php/etc/php.ini<br />按shift+g键跳到配置文件的最末尾,加上以下配置信息:<br />[eaccelerator]<br />zend_extension=quot; /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.soquot; <br />eaccelerator.shm_size=quot; 64quot; <br />eaccelerator.cache_dir=quot; /tmp/eacceleratorquot; <br />eaccelerator.enable=quot; 1quot; <br />eaccelerator.optimizer=quot; 1quot; <br />eaccelerator.check_mtime=quot; 1quot; <br />eaccelerator.debug=quot; 0quot; <br />eaccelerator.filter=quot; quot; <br />eaccelerator.shm_max=quot; 0quot; <br />eaccelerator.shm_ttl=quot; 3600quot; <br />eaccelerator.shm_prune_period=quot; 3600quot; <br />eaccelerator.shm_only=quot; 0quot; <br />eaccelerator.compress=quot; 1quot; <br />eaccelerator.compress_level=quot; 9quot; <br />7、创建www用户和组:<br />/usr/sbin/groupadd www<br />/usr/sbin/useradd -g www www<br />mkdir -p /data/www/wwwroot<br />chmod +w /data/www/wwwroot<br />chown -R www:www /data/www/wwwroot<br /> <br />8、创建php-fpm配置文件<br />(php-fpm是为PHP打的一个FastCGI管理补丁,可以平滑变更php.ini配置而无需重启php-cgi):<br />在/usr/local/php/etc/目录中创建php-fpm.conf文件:<br />rm -f /usr/local/php/etc/php-fpm.conf<br />vi /usr/local/php/etc/php-fpm.conf<br />输入以下内容:<br /><?xml version=quot; 1.0quot; ?><br /><configuration><br /> All relative paths in this config are relative to php's install prefix<br /> <section name=quot; global_optionsquot; ><br /> <br /> Pid file<br /> <value name=quot; pid_filequot; >/usr/local/php/logs/php-fpm.pid</value><br /> <br /> Error log file<br /> <value name=quot; error_logquot; >/usr/local/php/logs/php-fpm.log</value><br /> <br /> Log level<br /> <value name=quot; log_levelquot; >notice</value><br /> <br /> When this amount of php processes exited with SIGSEGV or SIGBUS ...<br /> <value name=quot; emergency_restart_thresholdquot; >10</value><br /> <br /> ... in a less than this interval of time, a graceful restart will be initiated.<br /> Useful to work around accidental curruptions in accelerator's shared memory.<br /> <value name=quot; emergency_restart_intervalquot; >1m</value><br /> <br /> Time limit on waiting child's reaction on signals from master<br /> <value name=quot; process_control_timeoutquot; >5s</value><br /> <br /> Set to 'no' to debug fpm<br /> <value name=quot; daemonizequot; >yes</value><br /> <br /> </section><br /> <br /> <workers><br /> <br /> <section name=quot; poolquot; ><br /> <br /> Name of pool. Used in logs and stats.<br /> <value name=quot; namequot; >default</value><br /> <br /> Address to accept fastcgi requests on.<br /> Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket'<br /> <value name=quot; listen_addressquot; >127.0.0.1:9000</value><br /> <br /> <value name=quot; listen_optionsquot; ><br /> <br /> Set listen(2) backlog<br /> <value name=quot; backlogquot; >-1</value><br /> <br /> Set permissions for unix socket, if one used.<br /> In Linux read/write permissions must be set in order to allow connections from web server.<br /> Many BSD-derrived systems allow connections regardless of permissions.<br /> <value name=quot; ownerquot; ></value><br /> <value name=quot; groupquot; ></value><br /> <value name=quot; modequot; >0666</value><br /> </value><br /> <br /> Additional php.ini defines, specific to this pool of workers.<br /> <value name=quot; php_definesquot; ><br /> <value name=quot; sendmail_pathquot; >/usr/sbin/sendmail -t -i</value><br /> <value name=quot; display_errorsquot; >1</value><br /> </value><br /> <br /> Unix user of processes<br /> <value name=quot; userquot; >www</value><br /> <br /> Unix group of processes<br /> <value name=quot; groupquot; >www</value><br /> <br /> Process manager settings<br /> <value name=quot; pmquot; ><br /> <br /> Sets style of controling worker process count.<br /> Valid values are 'static' and 'apache-like'<br /> <value name=quot; stylequot; >static</value><br /> <br /> Sets the limit on the number of simultaneous requests that will be served.<br /> Equivalent to Apache MaxClients directive.<br /> Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi<br /> Used with any pm_style.<br /> <value name=quot; max_childrenquot; >128</value><br /> <br /> Settings group for 'apache-like' pm style<br /> <value name=quot; apache_likequot; ><br /> <br /> Sets the number of server processes created on startup.<br /> Used only when 'apache-like' pm_style is selected<br /> <value name=quot; StartServersquot; >20</value><br /> <br /> Sets the desired minimum number of idle server processes.<br /> Used only when 'apache-like' pm_style is selected<br /> <value name=quot; MinSpareServersquot; >5</value><br /> <br /> Sets the desired maximum number of idle server processes.<br /> Used only when 'apache-like' pm_style is selected<br /> <value name=quot; MaxSpareServersquot; >35</value><br /> </value><br /> </value><br /> <br /> The timeout (in seconds) for serving a single request after which the worker process will be terminated<br /> Should be used when 'max_execution_time' ini option does not stop script execution for some reason<br /> '0s' means 'off'<br /> <value name=quot; request_terminate_timeoutquot; >0s</value><br /> <br /> The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file<br /> '0s' means 'off'<br /> <value name=quot; request_slowlog_timeoutquot; >0s</value><br /> <br /> The log file for slow requests<br /> <value name=quot; slowlogquot; >logs/slow.log</value><br /> <br /> Set open file desc rlimit<br /> <value name=quot; rlimit_filesquot; >65535</value><br /> <br /> Set max core size rlimit<br /> <value name=quot; rlimit_corequot; >0</value><br /> <br /> Chroot to this directory at the start, absolute path<br /> <value name=quot; chrootquot; ></value><br /> <br /> Chdir to this directory at the start, absolute path<br /> <value name=quot; chdirquot; ></value><br /> <br /> Redirect workers' stdout and stderr into main error log.<br /> If not set, they will be redirected to /dev/null, according to FastCGI specs<br /> <value name=quot; catch_workers_outputquot; >yes</value><br /> <br /> How much requests each process should execute before respawn.<br /> Useful to work around memory leaks in 3rd party libraries.<br /> For endless request processing please specify 0<br /> Equivalent to PHP_FCGI_MAX_REQUESTS<br /> <value name=quot; max_requestsquot; >102400</value><br /> <br /> Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect.<br /> Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+)<br /> Makes sense only with AF_INET listening socket.<br /> <value name=quot; allowed_clientsquot; >127.0.0.1</value><br /> <br /> Pass environment variables like LD_LIBRARY_PATH<br /> All $VARIABLEs are taken from current environment<br /> <value name=quot; environmentquot; ><br /> <value name=quot; HOSTNAMEquot; >$HOSTNAME</value><br /> <value name=quot; PATHquot; >/usr/local/bin:/usr/bin:/bin</value><br /> <value name=quot; TMPquot; >/tmp</value><br /> <value name=quot; TMPDIRquot; >/tmp</value><br /> <value name=quot; TEMPquot; >/tmp</value><br /> <value name=quot; OSTYPEquot; >$OSTYPE</value><br /> <value name=quot; MACHTYPEquot; >$MACHTYPE</value><br /> <value name=quot; MALLOC_CHECK_quot; >2</value><br /> </value><br /> </section><br /> </workers><br /></configuration><br /> <br />(如果您安装 Nginx + PHP 用于程序调试,请将以下的<value name=quot; display_errorsquot; >0</value>改为<value name=quot; display_errorsquot; >1</value>,以便显示PHP错误信息,否则,Nginx 会报状态为500的空白错误页)<br /> <br />9、启动php-cgi进程,监听127.0.0.1的9000端口,进程数为200(如果服务器内存小于3GB,可以只开启64个进程),用户为www:<br />ulimit -SHn 65535<br />/usr/local/php/sbin/php-fpm start<br />注:/usr/local/php/sbin/php-fpm还有其他参数,包 括:start|stop|quit|restart|reload|logrotate<br />修改php.ini后不重启php-cgi,重新加载配置文件 使用reload。<br /> <br />三、安装Nginx 0.8.15<br />1、安装Nginx所需的pcre库:<br />tar zxvf pcre-8.11.tar.gz && cd pcre-8.11<br />./configure<br />make && make install<br />cd ../<br /> <br />2、安装Nginx<br />tar zxvf nginx-0.8.54.tar.gz && cd nginx-0.8.54<br />./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module<br />make && make install<br />cd ../<br /> <br />3、创建Nginx日志目录<br />mkdir -p /data/log<br />chmod +w /data/log<br />chown -R www:www /data/log<br /> <br />4、创建Nginx配置文件<br />①、在/usr/local/nginx/conf/目录中创建nginx.conf文件:<br />rm -f /usr/local/nginx/conf/nginx.conf<br />vi /usr/local/nginx/conf/nginx.conf<br />输入以下内容:<br />引用<br />user www;<br /> <br />worker_processes 8;<br /> <br />error_log /data/log/nginx_error.log crit;<br /> <br />pid /usr/local/nginx/nginx.pid;<br /> <br />#Specifies the value for maximum file descriptors that can be opened by this process. <br />worker_rlimit_nofile 65535;<br /> <br />events <br />{<br /> use epoll;<br /> worker_connections 65535;<br />}<br /> <br />http <br />{<br /> include mime.types;<br /> default_type application/octet-stream;<br /> <br /> #charset gb2312;<br /> <br /> server_names_hash_bucket_size 128;<br /> client_header_buffer_size 32k;<br /> large_client_header_buffers 4 32k;<br /> client_max_body_size 8m;<br /> <br /> sendfile on;<br /> tcp_nopush on;<br /> <br /> keepalive_timeout 60;<br /> <br /> tcp_nodelay on;<br /> <br /> fastcgi_connect_timeout 300;<br /> fastcgi_send_timeout 300;<br /> fastcgi_read_timeout 300;<br /> fastcgi_buffer_size 64k;<br /> fastcgi_buffers 4 64k;<br /> fastcgi_busy_buffers_size 128k;<br /> fastcgi_temp_file_write_size 128k;<br /> <br /> gzip on;<br /> gzip_min_length 1k;<br /> gzip_buffers 4 16k;<br /> gzip_http_version 1.0;<br /> gzip_comp_level 2;<br /> gzip_types text/plain application/x-javascript text/css application/xml;<br /> gzip_vary on;<br /> <br /> #limit_zone crawler $binary_remote_addr 10m;<br /> server_tokens off; <br /> server<br /> {<br /> listen 80;<br /> server_name pass.rayli.com.cn;<br /> index index.html index.htm index.php;<br /> root /data/www/wwwroot;<br /> <br /> #limit_conn crawler 20; <br /> <br /> location ~ .*(php|php5)?$<br /> { <br /> #fastcgi_pass unix:/tmp/php-cgi.sock;<br /> fastcgi_pass 127.0.0.1:9000;<br /> fastcgi_index index.php;<br /> include fcgi.conf;<br /> }<br /> <br /> location ~ .*(gif|jpg|jpeg|png|bmp|swf)$<br /> {<br /> expires 30d;<br /> }<br /> <br /> location ~ .*(js|css)?$<br /> {<br /> expires 1h;<br /> } <br /> <br /> <br /> location /nginx_status<br /> {<br /> stub_status on;<br /> access_log off;<br /> allow all;<br /> }<br /> <br /> log_format access '$remote_addr - $remote_user [$time_local] quot; $requestquot; '<br /> '$status $body_bytes_sent quot; $http_refererquot; '<br /> 'quot; $http_user_agentquot; $http_x_forwarded_for';<br /> access_log /data/log/access.log access;<br /> <br /> <br /> }<br />}<br /> <br />②、在/usr/local/nginx/conf/目录中创建fcgi.conf文件:<br />vi /usr/local/nginx/conf/fcgi.conf<br />输入以下内容:<br />fastcgi_param GATEWAY_INTERFACE CGI/1.1;<br />fastcgi_param SERVER_SOFTWARE nginx;<br />fastcgi_param QUERY_STRING $query_string;<br />fastcgi_param REQUEST_METHOD $request_method;<br />fastcgi_param CONTENT_TYPE $content_type;<br />fastcgi_param CONTENT_LENGTH $content_length;<br /> <br />fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br />fastcgi_param SCRIPT_NAME $fastcgi_script_name;<br />fastcgi_param REQUEST_URI $request_uri;<br />fastcgi_param DOCUMENT_URI $document_uri;<br />fastcgi_param DOCUMENT_ROOT $document_root;<br />fastcgi_param SERVER_PROTOCOL $server_protocol;<br />fastcgi_param REMOTE_ADDR $remote_addr;<br />fastcgi_param REMOTE_PORT $remote_port;<br />fastcgi_param SERVER_ADDR $server_addr;<br />fastcgi_param SERVER_PORT $server_port;<br />fastcgi_param SERVER_NAME $server_name;<br /># PHP only, required if PHP was built with --enable-force-cgi-redirect<br />fastcgi_param REDIRECT_STATUS 200;<br />5、启动Nginx<br />ulimit -SHn 65535<br />/usr/local/nginx/sbin/nginx<br />四、配置开机自动启动Nginx + PHP<br />vi /etc/rc.local<br />在末尾增加以下内容:<br />ulimit -SHn 65535<br />/usr/local/php/sbin/php-fpm start<br />/usr/local/nginx/sbin/nginx<br />五、优化Linux内核参数<br />vi /etc/sysctl.conf<br />在末尾增加以下内容:<br /># Add<br />net.ipv4.tcp_max_syn_backlog = 65536 <br />net.core.netdev_max_backlog = 32768 <br />net.core.somaxconn = 32768 <br /> <br />net.core.wmem_default = 8388608 <br />net.core.rmem_default = 8388608 <br />net.core.rmem_max = 16777216 <br />net.core.wmem_max = 16777216 <br /> <br />net.ipv4.tcp_timestamps = 0 <br />net.ipv4.tcp_synack_retries = 2 <br />net.ipv4.tcp_syn_retries = 2 <br /> <br />net.ipv4.tcp_tw_recycle = 1 <br />#net.ipv4.tcp_tw_len = 1<br />net.ipv4.tcp_tw_reuse = 1 <br /> <br />net.ipv4.tcp_mem = 94500000 915000000 927000000<br /> <br />net.ipv4.tcp_max_orphans = 3276800 <br />#net.ipv4.tcp_fin_timeout = 30 <br />#net.ipv4.tcp_keepalive_time = 120 <br />net.ipv4.ip_local_port_range = 1024 65535<br /> <br />使配置立即生效:<br />/sbin/sysctl -p<br />六、创建nginx启动脚本<br />vim /etc/init.d/nginx<br />#!/bin/sh<br />#<br /># chkconfig: - 85 15 <br /># description: Nginx is an HTTP(S) server, HTTP(S) reverse lt;br /># proxy and IMAP/POP3 proxy server<br /># processname: nginx<br /># config: /etc/nginx/nginx.conf<br /># config: /etc/sysconfig/nginx<br /># pidfile: /var/run/nginx.pid<br /> <br /># Source function library.<br />. /etc/rc.d/init.d/functions<br /> <br /># Source networking configuration.<br />. /etc/sysconfig/network<br /> <br /># Check that networking is up.<br />[ quot; $NETWORKINGquot; = quot; noquot; ] && exit 0<br />nginx=quot; /usr/local/nginx/sbin/nginxquot; <br />prog=$(basename $nginx)<br />NGINX_CONF_FILE=quot; /usr/local/nginx/conf/nginx.confquot; <br />[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx<br />lockfile=/var/lock/subsys/nginx<br />start() {<br /> [ -x $nginx ] || exit 5<br /> [ -f $NGINX_CONF_FILE ] || exit 6<br /> echo -n $quot; Starting $prog: quot; <br /> daemon $nginx -c $NGINX_CONF_FILE<br /> retval=$?<br /> echo<br /> [ $retval -eq 0 ] && touch $lockfile<br /> return $retval<br />}<br />stop() {<br /> echo -n $quot; Stopping $prog: quot; <br /> killproc $prog -QUIT<br /> retval=$?<br /> echo<br /> [ $retval -eq 0 ] && rm -f $lockfile<br /> return $retval<br />}<br />restart() {<br /> configtest || return $?<br /> stop<br /> sleep 1<br /> start<br />}<br />reload() {<br /> configtest || return $?<br /> echo -n $quot; Reloading $prog: quot; <br /> killproc $nginx -HUP<br /> RETVAL=$?<br /> echo<br />}<br />force_reload() {<br /> restart<br />}<br />configtest() {<br /> $nginx -t -c $NGINX_CONF_FILE<br />}<br />rh_status() {<br /> status $prog<br />}<br />rh_status_q() {<br /> rh_status >/dev/null 2>&1<br />}<br />case quot; $1quot; in<br /> start)<br /> rh_status_q && exit 0<br /> $1<br /> ;;<br /> stop)<br /> rh_status_q || exit 0<br /> $1<br /> ;;<br /> restart|configtest)<br /> $1<br /> ;;<br /> reload)<br /> rh_status_q || exit 7<br /> $1<br /> ;;<br /> force-reload)<br /> force_reload<br /> ;;<br /> status)<br /> rh_status<br /> ;;<br /> condrestart|try-restart)<br /> rh_status_q || exit 0<br /> ;;<br /> *)<br /> echo $quot; Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}quot; <br /> exit 2<br />esac<br />六、在不停止Nginx服务的情况下平滑变更Nginx配置<br />1、修改/usr/local/nginx/conf/nginx.conf配置文件后,请执行以下命令检查配置文件是否正确:<br />/usr/local/nginx/sbin/nginx -t<br />如果屏幕显示以下两行信息,说明配置文件正确:<br />the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok<br />the configuration file /usr/local/nginx/conf/nginx.conf was tested successfully<br /> <br />2、这时,输入以下命令查看Nginx主进程号:<br />ps -ef | grep quot; nginx: master processquot; | grep -v quot; grepquot; | awk -F ' ' '{print $2}'<br />屏幕显示的即为Nginx主进程号,例如:<br />6302<br />这时,执行以下命令即可使修改过的Nginx配置文件生效:<br />kill -HUP 6302<br />或者无需这么麻烦,找到Nginx的Pid文件:<br />kill -HUP `cat /usr/local/nginx/nginx.pid`<br />七、编写每天定时切割Nginx日志的脚本<br />1、创建脚本/usr/local/nginx/sbin/cut_nginx_log.sh<br />vi /usr/local/nginx/sbin/cut_nginx_log.sh<br />输入以下内容:<br />#!/bin/bash<br /># This script run at 00:00<br /> <br /># The Nginx logs path<br />logs_path=quot; /usr/local/nginx/logs/quot; <br /> <br />mkdir -p ${logs_path}$(date -d quot; yesterdayquot; +quot; %Yquot; )/$(date -d quot; yesterdayquot; +quot; %mquot; )/<br />mv ${logs_path}access.log ${logs_path}$(date -d quot; yesterdayquot; +quot; %Yquot; )/$(date -d quot; yesterdayquot; +quot; %mquot; )/access_$(date -d quot; yesterdayquot; +quot; %Y%m%dquot; ).log<br />kill -USR1 `cat /usr/local/nginx/nginx.pid`<br />------------------------------------------------------------------------------------------------------<br />#!/bin/bash<br /># This script run at 00:00<br /># The Nginx logs path<br />logs_path=quot; /data/log/quot; <br />mv ${logs_path}access.log ${logs_path}access.log-$(date -d quot; yesterdayquot; +quot; %Y%m%dquot; <br />)<br />service nginx restart<br /> <br />2、设置crontab,每天凌晨00:00切割nginx访问日志<br />crontab -e<br />输入以下内容:<br />00 00 * * * /bin/bash /usr/local/sbin/cut_nginx_log.sh<br />相关软件包下载地址: <br />适用CentOS、RedHat及其它Linux操作系统下载程序源码包:<br />本文中提到的所有开源软件为截止到2009年09月18日的最新稳定版。<br />从软件的官方网站下载:<br />cd /usr/local/src<br />wget http://sysoev.ru/nginx/nginx-0.8.15.tar.gz<br />wget http://www.php.net/get/php-5.2.10.tar.gz/from/this/mirror<br />wget http://blog.s135.com/soft/linux/nginx_php/phpfpm/php-5.2.10-fpm-0.5.11.diff.gz<br />wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.38.tar.gz/from/http://mysql.he.net/<br />wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.tar.gz<br />wget http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0<br />wget http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0<br />wget http://pecl.php.net/get/memcache-2.2.5.tgz<br />wget http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0<br />wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.9.tar.gz<br />wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2<br />wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz<br />wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz<br />wget http://pecl.php.net/get/imagick-2.2.2.tgz<br />②、从blog.s135.com下载<br />cd /usr/local/src<br />wget http://blog.s135.com/soft/linux/nginx_php/nginx/nginx-0.8.15.tar.gz<br />wget http://blog.s135.com/soft/linux/nginx_php/php/php-5.2.10.tar.gz<br />wget http://blog.s135.com/soft/linux/nginx_php/phpfpm/php-5.2.10-fpm-0.5.11.diff.gz<br />wget http://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.1.38.tar.gz<br />wget http://blog.s135.com/soft/linux/nginx_php/libiconv/libiconv-1.13.tar.gz<br />wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz<br />wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gz<br />wget http://blog.s135.com/soft/linux/nginx_php/memcache/memcache-2.2.5.tgz<br />wget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz<br />wget http://blog.s135.com/soft/linux/nginx_php/pcre/pcre-7.9.tar.gz<br />wget http://blog.s135.com/soft/linux/nginx_php/eaccelerator/eaccelerator-0.9.5.3.tar.bz2<br />wget http://blog.s135.com/soft/linux/nginx_php/pdo/PDO_MYSQL-1.0.2.tgz<br />wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz<br />wget http://blog.s135.com/soft/linux/nginx_php/imagick/imagick-2.2.2.tgz<br />