SlideShare une entreprise Scribd logo
1  sur  25
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 &#124; grep 'bin/mysqld_safe' &#124; grep ${mysql_port} &#124; awk '{printf $2}')<br />    kill -9 $(ps -ef &#124; grep 'libexec/mysqld' &#124; grep ${mysql_port} &#124; 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&#124;stop&#124;restart&#124;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 />
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册
Nginx 0.8.x 安装手册

Contenu connexe

Tendances

Spider Setup with AWS/sandbox
Spider Setup with AWS/sandboxSpider Setup with AWS/sandbox
Spider Setup with AWS/sandboxI Goo Lee
 
nouka inventry manager
nouka inventry managernouka inventry manager
nouka inventry managerToshiaki Baba
 
MongoDB – Sharded cluster tutorial - Percona Europe 2017
MongoDB – Sharded cluster tutorial - Percona Europe 2017MongoDB – Sharded cluster tutorial - Percona Europe 2017
MongoDB – Sharded cluster tutorial - Percona Europe 2017Antonios Giannopoulos
 
Installing Cacti openSUSE Leap 42.1
Installing Cacti openSUSE Leap 42.1Installing Cacti openSUSE Leap 42.1
Installing Cacti openSUSE Leap 42.1Didiet A. Pambudiono
 
ByPat博客出品Lvs+keepalived
ByPat博客出品Lvs+keepalivedByPat博客出品Lvs+keepalived
ByPat博客出品Lvs+keepalivedredhat9
 
Hadoop Admin role & Hive Data Warehouse support
Hadoop Admin role & Hive Data Warehouse supportHadoop Admin role & Hive Data Warehouse support
Hadoop Admin role & Hive Data Warehouse supportmdcdwh
 
BlockChain implementation by python
BlockChain implementation by pythonBlockChain implementation by python
BlockChain implementation by pythonwonyong hwang
 
Installation of Subversion on Ubuntu,...
Installation of Subversion on Ubuntu,...Installation of Subversion on Ubuntu,...
Installation of Subversion on Ubuntu,...wensheng wei
 
Ansible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupAnsible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupGreg DeKoenigsberg
 
Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04SANTIAGO HERNÁNDEZ
 
agri inventory - nouka data collector / yaoya data convertor
agri inventory - nouka data collector / yaoya data convertoragri inventory - nouka data collector / yaoya data convertor
agri inventory - nouka data collector / yaoya data convertorToshiaki Baba
 
Lamp configuration u buntu 10.04
Lamp configuration   u buntu 10.04Lamp configuration   u buntu 10.04
Lamp configuration u buntu 10.04mikehie
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariJoseph Scott
 
Ansible : what's ansible & use case by REX
Ansible :  what's ansible & use case by REXAnsible :  what's ansible & use case by REX
Ansible : what's ansible & use case by REXSaewoong Lee
 

Tendances (20)

Spider Setup with AWS/sandbox
Spider Setup with AWS/sandboxSpider Setup with AWS/sandbox
Spider Setup with AWS/sandbox
 
nouka inventry manager
nouka inventry managernouka inventry manager
nouka inventry manager
 
Web Server Free Bsd
Web Server Free BsdWeb Server Free Bsd
Web Server Free Bsd
 
Centos config
Centos configCentos config
Centos config
 
MongoDB – Sharded cluster tutorial - Percona Europe 2017
MongoDB – Sharded cluster tutorial - Percona Europe 2017MongoDB – Sharded cluster tutorial - Percona Europe 2017
MongoDB – Sharded cluster tutorial - Percona Europe 2017
 
Installing Cacti openSUSE Leap 42.1
Installing Cacti openSUSE Leap 42.1Installing Cacti openSUSE Leap 42.1
Installing Cacti openSUSE Leap 42.1
 
ByPat博客出品Lvs+keepalived
ByPat博客出品Lvs+keepalivedByPat博客出品Lvs+keepalived
ByPat博客出品Lvs+keepalived
 
Hadoop Admin role & Hive Data Warehouse support
Hadoop Admin role & Hive Data Warehouse supportHadoop Admin role & Hive Data Warehouse support
Hadoop Admin role & Hive Data Warehouse support
 
My SQL 101
My SQL 101My SQL 101
My SQL 101
 
BlockChain implementation by python
BlockChain implementation by pythonBlockChain implementation by python
BlockChain implementation by python
 
Installation of Subversion on Ubuntu,...
Installation of Subversion on Ubuntu,...Installation of Subversion on Ubuntu,...
Installation of Subversion on Ubuntu,...
 
Ansible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupAnsible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetup
 
Puppet
PuppetPuppet
Puppet
 
Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04
 
agri inventory - nouka data collector / yaoya data convertor
agri inventory - nouka data collector / yaoya data convertoragri inventory - nouka data collector / yaoya data convertor
agri inventory - nouka data collector / yaoya data convertor
 
Lamp configuration u buntu 10.04
Lamp configuration   u buntu 10.04Lamp configuration   u buntu 10.04
Lamp configuration u buntu 10.04
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
 
grate techniques
grate techniquesgrate techniques
grate techniques
 
Ansible : what's ansible & use case by REX
Ansible :  what's ansible & use case by REXAnsible :  what's ansible & use case by REX
Ansible : what's ansible & use case by REX
 
Intro django
Intro djangoIntro django
Intro django
 

En vedette

Using reader responses to make revisions
Using reader responses to make revisionsUsing reader responses to make revisions
Using reader responses to make revisionswritRHET -
 
Услуги в области инноваций региона Кюменлааксо (Финляндия)
Услуги в области инноваций региона Кюменлааксо (Финляндия)Услуги в области инноваций региона Кюменлааксо (Финляндия)
Услуги в области инноваций региона Кюменлааксо (Финляндия)St. Petersburg Foundation for SME Development
 
Zhongxing practice-suchunshan-qcon
Zhongxing practice-suchunshan-qconZhongxing practice-suchunshan-qcon
Zhongxing practice-suchunshan-qconYiwei Ma
 
BuilHigh Performance Weibo Platform-Qcon2011
BuilHigh Performance Weibo Platform-Qcon2011BuilHigh Performance Weibo Platform-Qcon2011
BuilHigh Performance Weibo Platform-Qcon2011Yiwei Ma
 
Cacti安装手册
Cacti安装手册Cacti安装手册
Cacti安装手册Yiwei Ma
 
Netflix web-adrian-qcon
Netflix web-adrian-qconNetflix web-adrian-qcon
Netflix web-adrian-qconYiwei Ma
 
Puppet安装测试
Puppet安装测试Puppet安装测试
Puppet安装测试Yiwei Ma
 
Виртуальная ИТ-инфраструктура предприятия на базе свободного ПО "под ключ"
Виртуальная ИТ-инфраструктура предприятия на базе свободного ПО "под ключ"Виртуальная ИТ-инфраструктура предприятия на базе свободного ПО "под ключ"
Виртуальная ИТ-инфраструктура предприятия на базе свободного ПО "под ключ"St. Petersburg Foundation for SME Development
 

En vedette (8)

Using reader responses to make revisions
Using reader responses to make revisionsUsing reader responses to make revisions
Using reader responses to make revisions
 
Услуги в области инноваций региона Кюменлааксо (Финляндия)
Услуги в области инноваций региона Кюменлааксо (Финляндия)Услуги в области инноваций региона Кюменлааксо (Финляндия)
Услуги в области инноваций региона Кюменлааксо (Финляндия)
 
Zhongxing practice-suchunshan-qcon
Zhongxing practice-suchunshan-qconZhongxing practice-suchunshan-qcon
Zhongxing practice-suchunshan-qcon
 
BuilHigh Performance Weibo Platform-Qcon2011
BuilHigh Performance Weibo Platform-Qcon2011BuilHigh Performance Weibo Platform-Qcon2011
BuilHigh Performance Weibo Platform-Qcon2011
 
Cacti安装手册
Cacti安装手册Cacti安装手册
Cacti安装手册
 
Netflix web-adrian-qcon
Netflix web-adrian-qconNetflix web-adrian-qcon
Netflix web-adrian-qcon
 
Puppet安装测试
Puppet安装测试Puppet安装测试
Puppet安装测试
 
Виртуальная ИТ-инфраструктура предприятия на базе свободного ПО "под ключ"
Виртуальная ИТ-инфраструктура предприятия на базе свободного ПО "под ключ"Виртуальная ИТ-инфраструктура предприятия на базе свободного ПО "под ключ"
Виртуальная ИТ-инфраструктура предприятия на базе свободного ПО "под ключ"
 

Similaire à Nginx 0.8.x 安装手册

Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google CloudDrupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google CloudDropsolid
 
How to install and configure LEMP stack
How to install and configure LEMP stackHow to install and configure LEMP stack
How to install and configure LEMP stackRootGate
 
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPHands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPDana Luther
 
Architecting cloud
Architecting cloudArchitecting cloud
Architecting cloudTahsin Hasan
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationJohn Lynch
 
Install cacti on open suse 13
Install cacti on open suse 13Install cacti on open suse 13
Install cacti on open suse 13Vanda KANY
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
Multiple instances on linux
Multiple instances on linuxMultiple instances on linux
Multiple instances on linuxVasudeva Rao
 
MySQL Spider Architecture
MySQL Spider ArchitectureMySQL Spider Architecture
MySQL Spider ArchitectureI Goo Lee
 
Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]Dana Luther
 
Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabricandymccurdy
 
Automating complex infrastructures with Puppet
Automating complex infrastructures with PuppetAutomating complex infrastructures with Puppet
Automating complex infrastructures with PuppetKris Buytaert
 
桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作Philip Zheng
 
OpenStack Tokyo Meeup - Gluster Storage Day
OpenStack Tokyo Meeup - Gluster Storage DayOpenStack Tokyo Meeup - Gluster Storage Day
OpenStack Tokyo Meeup - Gluster Storage DayDan Radez
 
Converting Your Dev Environment to a Docker Stack - Cascadia
Converting Your Dev Environment to a Docker Stack - CascadiaConverting Your Dev Environment to a Docker Stack - Cascadia
Converting Your Dev Environment to a Docker Stack - CascadiaDana Luther
 
Award-winning technology: Oxid loves the query cache
Award-winning technology: Oxid loves the query cacheAward-winning technology: Oxid loves the query cache
Award-winning technology: Oxid loves the query cacheUlf Wendel
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierCarlos Sanchez
 

Similaire à Nginx 0.8.x 安装手册 (20)

Mysql
Mysql Mysql
Mysql
 
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google CloudDrupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud
 
How to install and configure LEMP stack
How to install and configure LEMP stackHow to install and configure LEMP stack
How to install and configure LEMP stack
 
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPHands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
 
Architecting cloud
Architecting cloudArchitecting cloud
Architecting cloud
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Install cacti on open suse 13
Install cacti on open suse 13Install cacti on open suse 13
Install cacti on open suse 13
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Cooking with Chef
Cooking with ChefCooking with Chef
Cooking with Chef
 
Multiple instances on linux
Multiple instances on linuxMultiple instances on linux
Multiple instances on linux
 
PHP selber bauen
PHP selber bauenPHP selber bauen
PHP selber bauen
 
MySQL Spider Architecture
MySQL Spider ArchitectureMySQL Spider Architecture
MySQL Spider Architecture
 
Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]
 
Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabric
 
Automating complex infrastructures with Puppet
Automating complex infrastructures with PuppetAutomating complex infrastructures with Puppet
Automating complex infrastructures with Puppet
 
桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作
 
OpenStack Tokyo Meeup - Gluster Storage Day
OpenStack Tokyo Meeup - Gluster Storage DayOpenStack Tokyo Meeup - Gluster Storage Day
OpenStack Tokyo Meeup - Gluster Storage Day
 
Converting Your Dev Environment to a Docker Stack - Cascadia
Converting Your Dev Environment to a Docker Stack - CascadiaConverting Your Dev Environment to a Docker Stack - Cascadia
Converting Your Dev Environment to a Docker Stack - Cascadia
 
Award-winning technology: Oxid loves the query cache
Award-winning technology: Oxid loves the query cacheAward-winning technology: Oxid loves the query cache
Award-winning technology: Oxid loves the query cache
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
 

Plus de Yiwei Ma

Cibank arch-zhouweiran-qcon
Cibank arch-zhouweiran-qconCibank arch-zhouweiran-qcon
Cibank arch-zhouweiran-qconYiwei Ma
 
Cibank arch-zhouweiran-qcon
Cibank arch-zhouweiran-qconCibank arch-zhouweiran-qcon
Cibank arch-zhouweiran-qconYiwei Ma
 
Taobao casestudy-yufeng-qcon
Taobao casestudy-yufeng-qconTaobao casestudy-yufeng-qcon
Taobao casestudy-yufeng-qconYiwei Ma
 
Alibaba server-zhangxuseng-qcon
Alibaba server-zhangxuseng-qconAlibaba server-zhangxuseng-qcon
Alibaba server-zhangxuseng-qconYiwei Ma
 
Taobao practice-liyu-qcon
Taobao practice-liyu-qconTaobao practice-liyu-qcon
Taobao practice-liyu-qconYiwei Ma
 
Thoughtworks practice-hukai-qcon
Thoughtworks practice-hukai-qconThoughtworks practice-hukai-qcon
Thoughtworks practice-hukai-qconYiwei Ma
 
Ufida design-chijianqiang-qcon
Ufida design-chijianqiang-qconUfida design-chijianqiang-qcon
Ufida design-chijianqiang-qconYiwei Ma
 
Spring design-juergen-qcon
Spring design-juergen-qconSpring design-juergen-qcon
Spring design-juergen-qconYiwei Ma
 
Google arch-fangkun-qcon
Google arch-fangkun-qconGoogle arch-fangkun-qcon
Google arch-fangkun-qconYiwei Ma
 
Cibank arch-zhouweiran-qcon
Cibank arch-zhouweiran-qconCibank arch-zhouweiran-qcon
Cibank arch-zhouweiran-qconYiwei Ma
 
Alibaba arch-jiangtao-qcon
Alibaba arch-jiangtao-qconAlibaba arch-jiangtao-qcon
Alibaba arch-jiangtao-qconYiwei Ma
 
Twitter keynote-evan-qcon
Twitter keynote-evan-qconTwitter keynote-evan-qcon
Twitter keynote-evan-qconYiwei Ma
 
Netflix keynote-adrian-qcon
Netflix keynote-adrian-qconNetflix keynote-adrian-qcon
Netflix keynote-adrian-qconYiwei Ma
 
Facebook keynote-nicolas-qcon
Facebook keynote-nicolas-qconFacebook keynote-nicolas-qcon
Facebook keynote-nicolas-qconYiwei Ma
 
Domainlang keynote-eric-qcon
Domainlang keynote-eric-qconDomainlang keynote-eric-qcon
Domainlang keynote-eric-qconYiwei Ma
 
Devjam keynote-david-qcon
Devjam keynote-david-qconDevjam keynote-david-qcon
Devjam keynote-david-qconYiwei Ma
 
Baidu keynote-wubo-qcon
Baidu keynote-wubo-qconBaidu keynote-wubo-qcon
Baidu keynote-wubo-qconYiwei Ma
 
淘宝线上线下性能跟踪体系和容量规划-Qcon2011
淘宝线上线下性能跟踪体系和容量规划-Qcon2011淘宝线上线下性能跟踪体系和容量规划-Qcon2011
淘宝线上线下性能跟踪体系和容量规划-Qcon2011Yiwei Ma
 
网游服务器性能优化-Qcon2011
网游服务器性能优化-Qcon2011网游服务器性能优化-Qcon2011
网游服务器性能优化-Qcon2011Yiwei Ma
 
Xietingbao-Qcon2011
Xietingbao-Qcon2011Xietingbao-Qcon2011
Xietingbao-Qcon2011Yiwei Ma
 

Plus de Yiwei Ma (20)

Cibank arch-zhouweiran-qcon
Cibank arch-zhouweiran-qconCibank arch-zhouweiran-qcon
Cibank arch-zhouweiran-qcon
 
Cibank arch-zhouweiran-qcon
Cibank arch-zhouweiran-qconCibank arch-zhouweiran-qcon
Cibank arch-zhouweiran-qcon
 
Taobao casestudy-yufeng-qcon
Taobao casestudy-yufeng-qconTaobao casestudy-yufeng-qcon
Taobao casestudy-yufeng-qcon
 
Alibaba server-zhangxuseng-qcon
Alibaba server-zhangxuseng-qconAlibaba server-zhangxuseng-qcon
Alibaba server-zhangxuseng-qcon
 
Taobao practice-liyu-qcon
Taobao practice-liyu-qconTaobao practice-liyu-qcon
Taobao practice-liyu-qcon
 
Thoughtworks practice-hukai-qcon
Thoughtworks practice-hukai-qconThoughtworks practice-hukai-qcon
Thoughtworks practice-hukai-qcon
 
Ufida design-chijianqiang-qcon
Ufida design-chijianqiang-qconUfida design-chijianqiang-qcon
Ufida design-chijianqiang-qcon
 
Spring design-juergen-qcon
Spring design-juergen-qconSpring design-juergen-qcon
Spring design-juergen-qcon
 
Google arch-fangkun-qcon
Google arch-fangkun-qconGoogle arch-fangkun-qcon
Google arch-fangkun-qcon
 
Cibank arch-zhouweiran-qcon
Cibank arch-zhouweiran-qconCibank arch-zhouweiran-qcon
Cibank arch-zhouweiran-qcon
 
Alibaba arch-jiangtao-qcon
Alibaba arch-jiangtao-qconAlibaba arch-jiangtao-qcon
Alibaba arch-jiangtao-qcon
 
Twitter keynote-evan-qcon
Twitter keynote-evan-qconTwitter keynote-evan-qcon
Twitter keynote-evan-qcon
 
Netflix keynote-adrian-qcon
Netflix keynote-adrian-qconNetflix keynote-adrian-qcon
Netflix keynote-adrian-qcon
 
Facebook keynote-nicolas-qcon
Facebook keynote-nicolas-qconFacebook keynote-nicolas-qcon
Facebook keynote-nicolas-qcon
 
Domainlang keynote-eric-qcon
Domainlang keynote-eric-qconDomainlang keynote-eric-qcon
Domainlang keynote-eric-qcon
 
Devjam keynote-david-qcon
Devjam keynote-david-qconDevjam keynote-david-qcon
Devjam keynote-david-qcon
 
Baidu keynote-wubo-qcon
Baidu keynote-wubo-qconBaidu keynote-wubo-qcon
Baidu keynote-wubo-qcon
 
淘宝线上线下性能跟踪体系和容量规划-Qcon2011
淘宝线上线下性能跟踪体系和容量规划-Qcon2011淘宝线上线下性能跟踪体系和容量规划-Qcon2011
淘宝线上线下性能跟踪体系和容量规划-Qcon2011
 
网游服务器性能优化-Qcon2011
网游服务器性能优化-Qcon2011网游服务器性能优化-Qcon2011
网游服务器性能优化-Qcon2011
 
Xietingbao-Qcon2011
Xietingbao-Qcon2011Xietingbao-Qcon2011
Xietingbao-Qcon2011
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 

Dernier (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

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 &#124; grep 'bin/mysqld_safe' &#124; grep ${mysql_port} &#124; awk '{printf $2}')<br /> kill -9 $(ps -ef &#124; grep 'libexec/mysqld' &#124; grep ${mysql_port} &#124; 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&#124;stop&#124;restart&#124;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 />