{"id":1004,"date":"2009-11-29T19:21:00","date_gmt":"2009-11-29T11:21:00","guid":{"rendered":"\/?p=1004"},"modified":"2009-11-29T19:21:00","modified_gmt":"2009-11-29T19:21:00","slug":"1004","status":"publish","type":"post","link":"https:\/\/blog.vimge.com\/archives\/linux\/1004.html","title":{"rendered":"CentOS+Nginx+PHP+Mysql+\u5b89\u5168\u6307\u5357\u5168\u73af\u5883\u642d\u5efa\u7b14\u8bb0\uff08\u4e00\uff09"},"content":{"rendered":"
\u8fd9\u662f\u7b2c\u4e00\u90e8\u5206\uff0c< \u7cfb\u7edf\u5b89\u88c5\u540e\u7684\u521d\u59cb\u73af\u5883\u8bbe\u7f6e >
\u4e3b\u8981\u5185\u5bb9\u6709\uff1a
[\u7528\u6237\u7ba1\u7406\u4e0e\u7528\u6237\u5b89\u5168]
[\u8bbe\u7f6e\u7cfb\u7edf\u65f6\u95f4\u53ca\u81ea\u52a8\u540c\u6b65\u7cfb\u7edf\u65f6\u95f4]
[\u5173\u95ed\u4e0d\u9700\u8981\u7684\u670d\u52a1]
[\u7cfb\u7edf\u66f4\u65b0]
[\u7528OpenSSH\u6784\u5efaSSH\u670d\u52a1\u5668]<\/p>\n
CentOS+Nginx+PHP+Mysql+\u5b89\u5168\u6307\u5357\u5168\u73af\u5883\u642d\u5efa\u7b14\u8bb0(1)<\/p>\n
- \u7cfb\u7edf\u5b89\u88c5\u540e\u7684\u521d\u59cb\u73af\u5883\u8bbe\u7f6e<\/p>\n
[\u666e\u901a\u7528\u6237\u7684\u5efa\u7acb\u4e0e\u5220\u9664]<\/p>\n
# useradd lovemoon
\u2191 \u5efa\u7acb\u7528\u6237\u540d\u4e3a lovemoon \u7684\u666e\u901a\u7528\u6237
# passwd lovemoon
\u2191 \u4e3a\u7528\u6237 lovemoon \u8bbe\u7f6e\u5bc6\u7801
Changing password for user lovemoon.
New UNIX password:
\u2191 \u8f93\u5165\u5bc6\u7801\uff08\u5bc6\u7801\u4e0d\u4f1a\u88ab\u663e\u793a\uff09
Retype new UNIX password:
\u2191 \u518d\u6b21\u8f93\u5165\u5bc6\u7801\u786e\u8ba4\u4e24\u6b21\u5bc6\u7801\u4e00\u81f4
passwd: all authentication tokens updated successfully.
\u2191 \u5bc6\u7801\u8bbe\u7f6e\u6210\u529f<\/p>\n
#userdel -r lovemoon
\u2191 \u5220\u9664\u7528\u6237\u540d\u4e3a lovemoon \u7684\u666e\u901a\u7528\u6237<\/p>\n
[\u5c06\u666e\u901a\u7528\u6237\u8bbe\u7f6e\u5230\u4e0d\u540c\u7684\u7528\u6237\u7ec4\u4e2d]<\/p>\n
# usermod -G wheel lovemoon
\u2191 \u5c06\u666e\u901a\u7528\u6237 lovemoon \u52a0\u5728\u7ba1\u7406\u5458\u7ec4wheel\u7ec4\u4e2d
# usermod -G wheel,www lovemoon
\u2191 \u5c06\u666e\u901a\u7528\u6237 lovemoon \u540c\u65f6\u52a0\u5728wheel\u548cwww\u7ec4\u4e2d<\/p>\n
[\u8bbe\u7f6e\u53ea\u6709\u7ba1\u7406\u5458wheel\u7ec4\u624d\u53ef\u4ee5\u4f7f\u7528su\u547d\u4ee4\u8fdb\u5165root\u6743\u9650]<\/p>\n
# vi \/etc\/pam.d\/su \u3000\u2190 \u6253\u5f00\u8fd9\u4e2a\u914d\u7f6e\u6587\u4ef6
auth required \/lib\/security\/$ISA\/pam_wheel.so use_uid
\u2191 \u4fee\u6539\u6587\u4ef6\u4e3a\u6b64\u72b6\u6001\uff08\u5927\u7ea6\u5728\u7b2c6\u884c\u7684\u4f4d\u7f6e\uff09
# echo "SU_WHEEL_ONLY yes" >> \/etc\/login.defs
\u2191 \u6dfb\u52a0\u8bed\u53e5\u5230login.defs\u6587\u4ef6\u884c\u672b<\/p>\n
[\u8bbe\u7f6e\u7cfb\u7edf\u65f6\u95f4\u53ca\u81ea\u52a8\u540c\u6b65\u7cfb\u7edf\u65f6\u95f4]<\/p>\n
# yum install Cy ntp
\u2191 \u5b89\u88c5NTP\u5b98\u65b9\u7684\u65f6\u95f4\u540c\u6b65\u7a0b\u5e8f (NTP:\u4e2d\u56fd\u56fd\u5bb6\u6388\u65f6\u4e2d\u5fc3)
# \/usr\/sbin\/ntpdate -s pool.ntp.org
\u2191 \u4ee5NTP\u5b98\u65b9\u670d\u52a1\u5668\u4e3a\u51c6\u8c03\u6574\u672c\u5730\u65f6\u95f4
# crontab -e
\u2191 \u7f16\u8f91\u8ba1\u5212\u4efb\u52a1\u5217\u8868
0 3 * * * \/usr\/sbin\/ntpdate -s pool.ntp.org
\u2191 \u7f16\u8f91\u6587\u4ef6\u5230\u6b64\u72b6\u6001\uff0c\u8868\u793a\u6bcf\u5929\u51cc\u66683\u70b9\u81ea\u52a8\u540c\u6b65\u65f6\u95f4
# \/sbin\/service crond reload
\u2191 \u91cd\u8f7d\u8ba1\u5212\u4efb\u52a1\u914d\u7f6e<\/p>\n
[\u5173\u95ed\u4e0d\u9700\u8981\u7684\u670d\u52a1]<\/p>\n
# setup
\u2191 \u5f00\u542f\u56fe\u5f62\u8bbe\u7f6e\u754c\u9762
\u9009\u62e9System service \u8fdb\u5165\u670d\u52a1\u5217\u8868
\u4f7f\u7528"\u7a7a\u683c"\u952e\u9009\u62e9"[*]"\u6216\u53d6\u6d88"[ ]"\u670d\u52a1<\/p>\n
\u53ea\u4fdd\u7559\u4ee5\u4e0b\u670d\u52a1\uff0c\u672a\u5217\u51fa\u7684\u670d\u52a1\u4e00\u5f8b\u5173\u95ed\uff1a
crond
irqbalance
\u2191 \u4ec5\u5f53\u670d\u52a1\u5668CPU\u4e3aS.M.P\u67b6\u6784\u6216\u652f\u6301\u53cc\u6838\u5fc3\u3001HT\u6280\u672f\u65f6\uff0c\u624d\u9700\u5f00\u542f\uff0c\u5426\u5219\u5173\u95ed\u3002
iptables
microcode_ctl
network
sshd
syslog
vsftpd
yum-updatesd<\/p>\n
[\u7cfb\u7edf\u66f4\u65b0]<\/p>\n
# vi \/etc\/yum.repos.d\/CentOS-Base.repo
\u2191 \u4fee\u6539\u7cfb\u7edf\u66f4\u65b0\u5730\u5740\u6587\u4ef6
\u5c06\u6240\u6709"baseurl=http:\/\/mirror.centos.org\/centos\/$releasever\/os\/$basearch\/"
\u4fee\u6539\u4e3a"baseurl=http:\/\/mirrors.shlug.org\/centos\/$releasever\/os\/$basearch\/"
# yum -y upgrade
\u2191 \u66f4\u65b0\u7cfb\u7edf\u6587\u4ef6<\/p>\n
[\u7528OpenSSH\u6784\u5efaSSH\u670d\u52a1\u5668]<\/p>\n
# vi \/etc\/ssh\/sshd_config
\u2191 \u7528vi\u6253\u5f00SSH\u7684\u914d\u7f6e\u6587\u4ef6
\u5c06"#Protocol 2,1"
\u4fee\u6539\u4e3a "Protocol 2"
\u2191 \u53ea\u5141\u8bb8SSH2\u65b9\u5f0f\u7684\u8fde\u63a5(Centos 5.2\u4e2d\u5df2\u5305\u542b\u6b64\u8bbe\u7f6e)<\/p>\n
\u5c06"#ServerKeyBits 768"
\u4fee\u6539\u4e3a "ServerKeyBits 1024"
\u2191 \u5c06ServerKey\u5f3a\u5ea6\u6539\u4e3a1024\u6bd4\u7279<\/p>\n
\u5c06"#PermitRootLogin yes"
\u4fee\u6539\u4e3a "PermitRootLogin no"
\u2191 \u4e0d\u5141\u8bb8\u7528root\u8fdb\u884c\u767b\u5f55(wheel\u7ec4\u7528\u6237SSH\u767b\u9646\u540e\u53ef\u7528su\u547d\u4ee4\u4f7f\u7528root\u6743\u9650)<\/p>\n
\u5c06"#PasswordAuthentication yes"
\u4fee\u6539\u4e3a "PasswordAuthentication no"
\u2191 \u4e0d\u5141\u8bb8\u5bc6\u7801\u65b9\u5f0f\u7684\u767b\u5f55(SSH\u8fdc\u7a0b\u7ba1\u7406\u7528\u5bc6\u94a5\u767b\u9646\u4f1a\u5b89\u5168\u5f88\u591a)<\/p>\n
\u5c06"#PermitEmptyPasswords no"
\u4fee\u6539\u4e3a "PermitEmptyPasswords no"
\u2191 \u4e0d\u5141\u8bb8\u7a7a\u5bc6\u7801\u767b\u5f55<\/p>\n
# vi \/etc\/hosts.deny
\u2191 \u4fee\u6539\u5c4f\u853d\u89c4\u5219\uff0c\u5728\u6b64\u9650\u5b9a\u4ec5\u6709\u54ea\u4e9bIP\u5730\u5740\u53ef\u4ee5SSH\u8fdc\u7a0b\u767b\u9646\u672c\u670d\u52a1\u5668
sshd: ALL
\u2191 \u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u8fd9\u4e00\u884c\uff0c\u5c4f\u853d\u6240\u6709\u7684SSH\u8fde\u63a5\u8bf7\u6c42<\/p>\n
# vi \/etc\/hosts.allow
\u2191 \u4fee\u6539\u5141\u8bb8\u89c4\u5219\uff0c\u5728\u6b64\u9650\u5b9a\u4ec5\u6709\u54ea\u4e9bIP\u5730\u5740\u53ef\u4ee5SSH\u8fdc\u7a0b\u767b\u9646\u672c\u670d\u52a1\u5668
sshd:222.17.177.
sshd:10.3.92.25
sshd:10.3.97.137
\u2191 \u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u8fd9\u4e09\u884c\uff0c\u53ea\u5141\u8bb8\u6765\u81ea222.17.177\u7f51\u6bb5\u3001IP\u5730\u5740\u4e3a10.3.92.25\u548cIP\u5730\u5740\u4e3a10.3.97.137\u7684SSH\u8fde\u63a5\u8bf7\u6c42<\/p>\n
# \/etc\/rc.d\/init.d\/sshd restart
\u2191 \u91cd\u65b0\u542f\u52a8SSH\u670d\u52a1\u5668
Stopping sshd:\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000 [ OK ]
Starting sshd:\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000 [ OK ]
\u2191 SSH\u670d\u52a1\u5668\u91cd\u65b0\u542f\u52a8\u6210\u529f<\/p>\n
# su -lovemoon
\u2191 \u7528\u666e\u901a\u7528\u6237 lovemoon \u767b\u9646\u670d\u52a1\u5668
$ ssh-keygen -t rsa
\u2191 \u5efa\u7acb\u516c\u94a5\u4e0e\u79c1\u94a5
Generating public\/private rsa key pair.
Enter file in which to save the key (\/home\/kaz\/.ssh\/id_rsa):
\u2191 \u94a5\u5319\u7684\u6587\u4ef6\u540d\uff0c\u8fd9\u91cc\u4fdd\u6301\u9ed8\u8ba4\u76f4\u63a5\u56de\u8f66
Created directory ‘\/home\/kaz\/.ssh’
Enter passphrase (empty for no passphrase):
\u2191 \u8f93\u5165\u5bc6\u94a5\u53e3\u4ee4(\u4f7f\u7528SSH\u8fdc\u7a0b\u8f6f\u4ef6\u65f6\u4f1a\u7528\u5230)
Enter same passphrase again:
\u2191 \u518d\u6b21\u8f93\u5165\u5bc6\u94a5\u53e3\u4ee4(\u4f7f\u7528SSH\u8fdc\u7a0b\u8f6f\u4ef6\u65f6\u4f1a\u7528\u5230)
Your identification has been saved in \/home\/kaz\/.ssh\/id_rsa.
\u2191 \u5efa\u7acb\u4e86id_rsa\u79c1\u94a5\u6587\u4ef6
Your public key has been saved in \/home\/kaz\/.ssh\/id_rsa.pub.
\u2191 \u5efa\u7acb\u4e86id_rsa.pub\u516c\u94a5\u6587\u4ef6<\/p>\n
$ cd ~\/.ssh
\u2191 \u8fdb\u5165 lovemoon \u7528\u6237SSH\u914d\u7f6e\u6587\u4ef6\u7684\u76ee\u5f55(~\/\u76ee\u5f55\u76f8\u5f53\u4e8e\/home\/lovemoon\/)
$ cat ~\/.ssh\/id_rsa.pub >> ~\/.ssh\/authorized_keys
\u2191 \u516c\u94a5\u5185\u5bb9\u8f93\u51fa\u5230authorized_keys\u6587\u4ef6\u4e2d
$ rm -f ~\/.ssh\/id_rsa.pub
\u2191 \u5220\u9664\u539f\u6765\u7684\u516c\u94a5\u6587\u4ef6
$ chmod 400 ~\/.ssh\/authorized_keys
\u2191 \u5c06\u65b0\u5efa\u7acb\u7684\u516c\u94a5\u6587\u4ef6\u5c5e\u6027\u8bbe\u7f6e\u4e3a400<\/p>\n
$ exit
\u2191 \u9000\u51fa\u666e\u901a\u7528\u6237\u7684\u767b\u5f55
\u767b\u9646\u4e3aroot\u7528\u6237\uff0c\u63d2\u5165U\u76d8
# fdisk -l
\u2191 \u663e\u793a\u76ee\u524d\u6240\u6709\u786c\u76d8\uff0c\u627e\u5230U\u76d8\u8bbe\u5907\u540d\u4e3asdb1 (\u5177\u4f53\u60c5\u51b5\u5177\u4f53\u5bf9\u5f85\uff0c\u8fd9\u91cc\u5404\u670d\u52a1\u5668\u6709\u6240\u4e0d\u540c)
# mount \/dev\/sdb1 \/mnt
\u2191 \u6302\u8f7dU\u76d8\u8bbe\u5907\u5230\/mnt\u76ee\u5f55
# mv \/home\/lovemoon\/.ssh\/id_rsa \/mnt\/
\u2191 \u79fb\u52a8id_rsa\u79c1\u94a5\u6587\u4ef6\u5230U\u76d8\u4e2d
# umount \/mnt\/
\u2191 \u5378\u8f7dU\u76d8<\/p>\n
-Nginx+PHP+MySQL\u73af\u5883\u642d\u5efa<\/p>\n
[\u5229\u7528yum\u547d\u4ee4\u914d\u7f6e\u3001\u5347\u7ea7\u6240\u9700\u7a0b\u5e8f\u5e93]<\/p>\n
# sudo -s
# LANG=C
# 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
\u2191\u5b89\u88c5\u3001\u5347\u7ea7\u8fd9\u4e9b\u7a0b\u5e8f\u5e93<\/p>\n
[\u4e0b\u8f7d\u73af\u5883\u6240\u9700\u6587\u4ef6\u5230\u6307\u5b9a\u76ee\u5f55]<\/p>\n
# mkdir -p \/software [\u7f16\u8bd1\u5b89\u88c5PHP 5.2.6\u6240\u9700\u7684\u652f\u6301\u5e93]<\/p>\n # tar zxvf libiconv-1.12.tar.gz # tar zxvf libmcrypt-2.5.8.tar.gz # tar zxvf mhash-0.9.9.tar.gz # cp \/usr\/local\/lib\/libmcrypt.* \/usr\/lib # tar zxvf mcrypt-2.6.7.tar.gz [\u7f16\u8bd1\u5b89\u88c5MySQL 5.1.26-rc]<\/p>\n # \/usr\/sbin\/groupadd mysql # \/usr\/local\/webserver\/mysql\/bin\/mysql_install_db –defaults-file=\/usr\/local\/webserver\/mysql\/my.cnf –basedir=\/usr\/local\/webserver\/mysql –datadir=\/usr\/local\/webserver\/mysql\/data –user=mysql –pid-file=\/usr\/local\/webserver\/mysql\/mysql.pid –skip-locking –port=3306 –socket=\/tmp\/mysql.sock \n To start mysqld at boot time you have to copy<\/span> # \/bin\/sh \/usr\/local\/webserver\/mysql\/bin\/mysqld_safe –defaults-file=\/usr\/local\/webserver\/mysql\/my.cnf & [\u7f16\u8bd1\u5b89\u88c5PHP\uff08FastCGI\u6a21\u5f0f\uff09]<\/p>\n # tar zxvf php-5.2.6.tar.gz [\u7f16\u8bd1\u5b89\u88c5PHP5\u6269\u5c55\u6a21\u5757]<\/p>\n # tar zxvf memcache-2.2.3.tgz # tar jxvf eaccelerator-0.9.5.3.tar.bz2 [\u4fee\u6539php.ini\u6587\u4ef6]<\/p>\n \u624b\u5de5\u4fee\u6539\uff1a \u5c06 "output_buffering = Off" extension = "memcache.so" \u81ea\u52a8\u4fee\u6539(\u5df2\u4f7f\u7528\u624b\u52a8\u4fee\u6539\u7684\u8df3\u8fc7)\uff1a [\u914d\u7f6eeAccelerator\u52a0\u901fPHP]<\/p>\n # mkdir -p \/usr\/local\/webserver\/eaccelerator_cache [eaccelerator] # vi \/etc\/sysctl.conf \u5c06 "kernel.shmmax = **********" # \/sbin\/sysctl -p [\u521b\u5efawww\u7528\u6237\u548c\u7ec4]<\/p>\n # \/usr\/sbin\/groupadd www -g 48 [\u521b\u5efaphp-fpm\u914d\u7f6e\u6587\u4ef6]<\/p>\n php-fpm\u662f\u4e3aPHP\u6253\u7684\u4e00\u4e2aFastCGI\u7ba1\u7406\u8865\u4e01\uff0c\u53ef\u4ee5\u5e73\u6ed1\u53d8\u66f4php.ini\u914d\u7f6e\u800c\u65e0\u9700\u91cd\u542fphp-cgi <?xml version="1.0" ?> All relative paths in this config are relative to php’s install prefix<\/p>\n <section name="global_options"><\/p>\n Pid file Error log file Log level When this amount of php processes exited with SIGSEGV or SIGBUS … … in a less than this interval of time, a graceful restart will be initiated. Time limit on waiting child’s reaction on signals from master Set to ‘no’ to debug fpm <\/section><\/p>\n <workers><\/p>\n <section name="pool"><\/p>\n Name of pool. Used in logs and stats. Address to accept fastcgi requests on. <value name="listen_options"><\/p>\n Set listen(2) backlog Set permissions for unix socket, if one used. Additional php.ini defines, specific to this pool of workers. Unix user of processes Unix group of processes Process manager settings Sets style of controling worker process count. Sets the limit on the number of simultaneous requests that will be served. Settings group for ‘apache-like’ pm style Sets the number of server processes created on startup. Sets the desired minimum number of idle server processes. Sets the desired maximum number of idle server processes. <\/value><\/p>\n <\/value><\/p>\n The timeout (in seconds) for serving a single request after which the worker process will be terminated The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file The log file for slow requests Set open file desc rlimit Set max core size rlimit Chroot to this directory at the start, absolute path Chdir to this directory at the start, absolute path Redirect workers’ stdout and stderr into main error log. How much requests each process should execute before respawn. Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect. Pass environment variables like LD_LIBRARY_PATH <\/section><\/p>\n <\/workers><\/p>\n <\/configuration><\/p>\n [\u542f\u52a8php-cgi\u8fdb\u7a0b\uff0c\u76d1\u542c127.0.0.1\u76849000\u7aef\u53e3]<\/p>\n # ulimit -SHn 51200 [\u5b89\u88c5Nginx\u6240\u9700\u7684pcre\u5e93]<\/p>\n # tar zxvf pcre-7.7.tar.gz [\u5b89\u88c5Nginx 0.7.19]<\/p>\n # tar zxvf nginx-0.7.19.tar.gz [\u521b\u5efaNginx\u65e5\u5fd7\u76ee\u5f55]<\/p>\n # mkdir -p \/logs [\u521b\u5efanginx.conf\u914d\u7f6e\u6587\u4ef6]<\/p>\n # rm -f \/usr\/local\/webserver\/nginx\/conf\/nginx.conf user www www;<\/p>\n worker_processes 8; error_log \/logs\/nginx_error.log warn;<\/p>\n pid \/usr\/local\/webserver\/nginx\/nginx.pid;<\/p>\n #Specifies the value for maximum file descriptors that can be opened by this process. events http #charset gb2312;<\/p>\n server_names_hash_bucket_size 128; sendfile on; keepalive_timeout 60;<\/p>\n tcp_nodelay on;<\/p>\n fastcgi_connect_timeout 300; gzip on; limit_zone crash $binary_remote_addr 10m; server #limit_conn crash 5; location ~ .*\\.(php|php5)?$ location ~ .*\\.(gif|jpg|jpeg|png|bmp|swf)$ location ~ .*\\.(js|css)?$ location \/resource\/ { log_format access ‘$remote_addr – $remote_user [$time_local] "$request" ‘ [\u521b\u5efafcgi.conf\u914d\u7f6e\u6587\u4ef6]<\/p>\n # vi \/usr\/local\/webserver\/nginx\/conf\/fcgi.conf fastcgi_param GATEWAY_INTERFACE CGI\/1.1; fastcgi_param QUERY_STRING $query_string; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param REMOTE_ADDR $remote_addr; # PHP only, required if PHP was built with –enable-force-cgi-redirect [\u542f\u52a8Nginx]<\/p>\n # ulimit -SHn 51200 [\u5728\u4e0d\u505c\u6b62Nginx\u670d\u52a1\u7684\u60c5\u51b5\u4e0b\u5e73\u6ed1\u53d8\u66f4Nginx\u914d\u7f6e]<\/p>\n \u4fee\u6539\/usr\/local\/webserver\/nginx\/conf\/nginx.conf\u914d\u7f6e\u6587\u4ef6\u540e\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5\u914d\u7f6e\u6587\u4ef6\u662f\u5426\u6b63\u786e\uff1a \u5982\u679c\u5c4f\u5e55\u663e\u793a\u4ee5\u4e0b\u4e24\u884c\u4fe1\u606f\uff0c\u8bf4\u660e\u914d\u7f6e\u6587\u4ef6\u6b63\u786e\uff1a [\u914d\u7f6e\u5f00\u673a\u81ea\u52a8\u542f\u52a8Nginx + PHP + MySQL]<\/p>\n # vi \/etc\/rc.local [\u4f18\u5316Linux\u5185\u6838\u53c2\u6570]<\/p>\n # vi \/etc\/sysctl.conf net.ipv4.tcp_fin_timeout = 30 # \/sbin\/sysctl -p [\u7f16\u5199\u6bcf\u5929\u5b9a\u65f6\u5207\u5272Nginx\u65e5\u5fd7\u7684\u811a\u672c]<\/p>\n # vi \/usr\/local\/webserver\/nginx\/sbin\/cut_nginx_log.sh \u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9: # The Nginx logs path mkdir -p ${logs_path}$(date -d "yesterday" +"%Y")\/$(date -d "yesterday" +"%m")\/ [\u8bbe\u7f6e\u5207\u5272\u65e5\u5fd7\u7684\u8ba1\u5212\u4efb\u52a1]<\/p>\n # crontab -e \u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9: \u8fd9\u662f\u7b2c\u4e00\u90e8\u5206\uff0c< \u7cfb\u7edf\u5b89\u88c5\u540e\u7684\u521d\u59cb\u73af\u5883\u8bbe\u7f6e > CentOS+Nginx+PHP+Mysql+\u5b89\u5168\u6307\u5357\u5168\u73af\u5883\u642d\u5efa\u7b14\u8bb0(1)<\/p>\n <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1004"}],"collection":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/comments?post=1004"}],"version-history":[{"count":0,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1004\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/media?parent=1004"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/categories?post=1004"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/tags?post=1004"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
\u2191 \u5728\u6839\u76ee\u5f55\u5efa\u7acbsoftware\u6587\u4ef6\u5939
# cd \/software
\u2191 \u8fdb\u5165software\u6587\u4ef6\u5939
# wget http:\/\/sysoev.ru\/nginx\/nginx-0.7.19.tar.gz<\/a>
# wget http:\/\/www.php.net\/get\/php-5.2.6.tar.gz\/from\/this\/mirror<\/a>
# wget http:\/\/php-fpm.anight.org\/downloads\/head\/php-5.2.6-fpm-0.5.9.diff.gz<\/a>
# wget http:\/\/blog.s135.com\/soft\/linux\/mysql\/mysql-5.1.26-rc.tar.gz<\/a>
# wget http:\/\/ftp.gnu.org\/pub\/gnu\/libiconv\/libiconv-1.12.tar.gz<\/a>
# wget http:\/\/mirror.optus.net\/sourceforge\/m\/mc\/mcrypt\/libmcrypt-2.5.8.tar.gz<\/a>
# wget http:\/\/mirror.optus.net\/sourceforge\/m\/mc\/mcrypt\/mcrypt-2.6.7.tar.gz<\/a>
# wget http:\/\/pecl.php.net\/get\/memcache-2.2.3.tgz<\/a>
# wget http:\/\/mirror.optus.net\/sourceforge\/m\/mh\/mhash\/mhash-0.9.9.tar.gz<\/a>
# wget ftp:\/\/ftp.csx.cam.ac.uk\/pub\/software\/programming\/pcre\/pcre-7.7.tar.gz<\/a>
# wget http:\/\/bart.eaccelerator.net\/source\/0.9.5.3\/eaccelerator-0.9.5.3.tar.bz2<\/a>
\u2191 \u4e0b\u8f7d\u8fd9\u4e9b\u6587\u4ef6\u5230software\u76ee\u5f55<\/p>\n
\u2191 \u89e3\u538b(tar) \u53c2\u6570(zxvf) \u6587\u4ef6\u540d(libiconv-1.12.tar.gz)
# cd libiconv-1.12\/
\u2191 \u8fdb\u5165\u89e3\u538b\u51fa\u6765\u7684\u6587\u4ef6\u7684\u6587\u4ef6\u5939(libiconv-1.12)
# .\/configure –prefix=\/usr\/local
\u2191 \u914d\u7f6e\u5b89\u88c5\u4fe1\u606f \u6307\u5b9a\u5b89\u88c5\u76ee\u5f55\u4e3a\/usr\/local
# make
\u2191 make\u5b89\u88c5\u6587\u4ef6
# make install
\u2191 \u5f00\u59cb\u5b89\u88c5
# cd ..\/
\u2191 \u8fd4\u56de\u4e0a\u7ea7\u76ee\u5f55(\u6b64\u5904\u5373software\u76ee\u5f55)<\/p>\n
# cd libmcrypt-2.5.8\/
# .\/configure
# make
# make install
# \/sbin\/ldconfig
# cd libltdl\/
# .\/configure –enable-ltdl-install
# make
# make install
# cd ..\/..\/<\/p>\n
# cd mhash-0.9.9\/
# .\/configure
# make
# make install
# cd ..\/<\/p>\n
# ln -s \/usr\/local\/lib\/libmhash.so.2 \/usr\/lib\/libmhash.so.2<\/p>\n
# cd mcrypt-2.6.7\/
# .\/configure
# make
# make install
# cd ..\/<\/p>\n
\u2191 \u5efa\u7acbmysql\u7528\u6237\u7ec4
# \/usr\/sbin\/useradd -g mysql mysql
\u2191 \u5efa\u7acbmysql\u7528\u6237\u5230mysql\u7528\u6237\u7ec4\u4e2d
# tar zxvf mysql-5.1.26-rc.tar.gz
# cd mysql-5.1.26-rc\/
# .\/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
# make && make install
# chmod +w \/usr\/local\/webserver\/mysql
# chown -R mysql:mysql \/usr\/local\/webserver\/mysql
# cp support-files\/my-medium.cnf \/usr\/local\/webserver\/mysql\/my.cnf
# cd ..\/<\/p>\n
\u2191 \u4ee5mysql\u7528\u6237\u5e10\u53f7\u7684\u8eab\u4efd\u5efa\u7acb\u6570\u636e\u8868<\/p>\n
support-files\/mysql.server to the right place for your system<\/span>
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !<\/span>
To do so, start the server, then issue the following commands:<\/span>
\/usr\/local\/mysql\/\/bin\/mysqladmin -u root password ‘new-password’<\/span>
\/usr\/local\/mysql\/\/bin\/mysqladmin -u root -h localhost.localdomain password ‘new-password’<\/span>
Alternatively you can run:<\/span>
\/usr\/local\/mysql\/\/bin\/mysql_secure_installation<\/span>
which will also give you the option of removing the test<\/span>
databases and anonymous user created by default. This is<\/span>
strongly recommended for production servers.<\/span>
See the manual for more instructions.<\/span>
You can start the MySQL daemon with:<\/span>
cd \/usr\/local\/mysql\/ ; \/usr\/local\/mysql\/\/bin\/mysqld_safe &<\/span>
You can test the MySQL daemon with mysql-test-run.pl<\/span>
cd mysql-test ; perl mysql-test-run.pl<\/span>
Please report any problems with the \/usr\/local\/mysql\/\/bin\/mysqlbug script!<\/span><\/font><\/p>\n<\/p>\n
\u2191 \u542f\u52a8MySQL\uff08\u6700\u540e\u7684&\u8868\u793a\u5728\u540e\u53f0\u8fd0\u884c\uff09<\/p>\n
# gzip -cd php-5.2.6-fpm-0.5.9.diff.gz | patch -d php-5.2.6 -p1
# cd php-5.2.6\/
# .\/configure –prefix=\/usr\/local\/webserver\/php –with-config-file-path=\/usr\/local\/webserver\/php\/etc –with-mysql=\/usr\/local\/webserver\/mysql –with-mysqli=\/usr\/local\/webserver\/mysql\/bin\/mysql_config –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
# sed -i ‘s#-lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt#& -liconv#’ Makefile
# make
# make install
# cp php.ini-dist \/usr\/local\/webserver\/php\/etc\/php.ini
# cd ..\/<\/p>\n
# cd memcache-2.2.3\/
# \/usr\/local\/webserver\/php\/bin\/phpize
# .\/configure –with-php-config=\/usr\/local\/webserver\/php\/bin\/php-config
# make
# make install
# cd ..\/<\/p>\n
# cd eaccelerator-0.9.5.3\/
# \/usr\/local\/webserver\/php\/bin\/phpize
# .\/configure –enable-eaccelerator=shared –with-php-config=\/usr\/local\/webserver\/php\/bin\/php-config
# make
# make install
# cd ..\/<\/p>\n
# vi \/usr\/local\/webserver\/php\/etc\/php.ini
\u5c06 " extension_dir = ".\/" "
\u4fee\u6539\u4e3a " extension_dir = "\/usr\/local\/webserver\/php\/lib\/php\/extensions\/no-debug-non-zts-20060613\/" "<\/p>\n
\u4fee\u6539\u4e3a " output_buffering = On "<\/p>\n
\u2191 \u6587\u4ef6\u672b\u5c3e\u589e\u52a0\u6b64\u884c<\/p>\n
# sed -i ‘s#extension_dir = ".\/"#extension_dir = "\/usr\/local\/webserver\/php\/lib\/php\/extensions\/no-debug-non-zts-20060613\/"\\nextension = "memcache.so"\\n#’ \/usr\/local\/webserver\/php\/etc\/php.ini
# sed -i ‘s#output_buffering = Off#output_buffering = On#’ \/usr\/local\/webserver\/php\/etc\/php.ini<\/p>\n
# vi \/usr\/local\/webserver\/php\/etc\/php.ini
\u6309shift+g\u952e\u8df3\u5230\u914d\u7f6e\u6587\u4ef6\u7684\u6700\u672b\u5c3e\uff0c\u52a0\u5165\u4ee5\u4e0b\u914d\u7f6e\u4fe1\u606f\uff1a<\/p>\n
zend_extension="\/usr\/local\/webserver\/php\/lib\/php\/extensions\/no-debug-non-zts-20060613\/eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="\/usr\/local\/webserver\/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="300"
eaccelerator.shm_prune_period="120"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"<\/p>\n
\u2191 \u4fee\u6539\u914d\u7f6e\u6587\u4ef6<\/p>\n
\u4fee\u6539\u4e3a "kernel.shmmax = 134217728"<\/p>\n
\u2191 \u6267\u884c\u6b64\u547d\u4ee4\u4f7f\u914d\u7f6e\u751f\u6548<\/p>\n
\u2191 \u521b\u5efawww\u7528\u6237\u7ec4\u5e76\u6307\u5b9a\u7ec4ID\u4e3a48
# \/usr\/sbin\/useradd -u 48 -g www www
\u2191 \u521b\u5efawww\u7528\u6237\u5230www\u7528\u6237\u7ec4\u4e2d
# mkdir -p \/wwwroot
\u2191 \u5728\u6839\u76ee\u5f55\u4e2d\u521b\u5efawwwroot\u7f51\u7ad9\u76ee\u5f55
# chmod +w \/wwwroot
\u2191 \u7ed9wwwroot\u76ee\u5f55\u589e\u52a0\u53ef\u5199\u6743\u9650
# chown -R www:www \/wwwroot
\u2191 \u4f7fwwwroot\u76ee\u5f55\u6240\u5c5e\u7528\u6237\u7ec4\u4e3awww\uff0c\u6240\u5c5e\u7528\u6237\u4e3awww<\/p>\n
# rm -f \/usr\/local\/webserver\/php\/etc\/php-fpm.conf
\u2191 \u5220\u9664\u539f\u6709php-fpm.conf\u6587\u4ef6
# vi \/usr\/local\/webserver\/php\/etc\/php-fpm.conf
\u2191 \u5efa\u7acb\u65b0\u7684php-fpm.conf\u6587\u4ef6\u5e76\u542f\u52a8vi\u7f16\u8f91\u5668\u7f16\u8f91\u8be5\u6587\u4ef6
\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9(\u8bf7\u6ce8\u610f\u4ee5\u4e0b\u5185\u5bb9\u4e2d"\u2191"\u6807\u5fd7\u540e\u7684\u5185\u5bb9\u4e0d\u80fd\u51fa\u73b0\u5728\u5b9e\u9645\u6587\u4ef6\u4e2d)\uff1a<\/p>\n
<configuration><\/p>\n
<value name="pid_file">\/usr\/local\/webserver\/php\/logs\/php-fpm.pid<\/value><\/p>\n
<value name="error_log">\/usr\/local\/webserver\/php\/logs\/php-fpm.log<\/value><\/p>\n
<value name="log_level">notice<\/value><\/p>\n
<value name="emergency_restart_threshold">10<\/value><\/p>\n
Useful to work around accidental curruptions in accelerator’s shared memory.
<value name="emergency_restart_interval">1m<\/value><\/p>\n
<value name="process_control_timeout">5s<\/value><\/p>\n
<value name="daemonize">yes<\/value><\/p>\n
<value name="name">default<\/value><\/p>\n
Valid syntax is ‘ip.ad.re.ss:port’ or just ‘port’ or ‘\/path\/to\/unix\/socket’
<value name="listen_address">127.0.0.1:9000<\/value><\/p>\n
<value name="backlog">-1<\/value><\/p>\n
In Linux read\/write permissions must be set in order to allow connections from web server.
Many BSD-derrived systems allow connections regardless of permissions.
<value name="owner"><\/value>
<value name="group"><\/value>
<value name="mode">0666<\/value>
<\/value><\/p>\n
<value name="php_defines">
<value name="sendmail_path">\/usr\/sbin\/sendmail -t -i<\/value>
<value name="display_errors">0<\/value>
\u2191 \u5982\u679c\u5b89\u88c5 Nginx + PHP \u7528\u4e8e\u7a0b\u5e8f\u8c03\u8bd5\uff0c\u5219\u6b64\u5904\u5e94\u8bbe\u7f6e\u4e3a"1"\u4ee5\u663e\u793aPHP\u9519\u8bef\u4fe1\u606f\uff0c\u8bbe\u7f6e\u4e3a"0" Nginx \u4f1a\u62a5\u72b6\u6001\u4e3a500\u7684\u7a7a\u767d\u9519\u8bef\u9875
<\/value><\/p>\n
<value name="user">www<\/value><\/p>\n
<value name="group">www<\/value><\/p>\n
<value name="pm"><\/p>\n
Valid values are ‘static’ and ‘apache-like’
<value name="style">static<\/value><\/p>\n
Equivalent to Apache MaxClients directive.
Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi
Used with any pm_style.
<value name="max_children">64<\/value>
\u2191 \u8fdb\u7a0b\u6570\u4e3a64\uff0c\u5982\u679c\u670d\u52a1\u5668\u5185\u5b58\u5927\u4e8e3GB\uff0c\u53ef\u4ee5\u53ea\u5f00\u542f128-200\u4e2a\u8fdb\u7a0b<\/p>\n
<value name="apache_like"><\/p>\n
Used only when ‘apache-like’ pm_style is selected
<value name="StartServers">20<\/value><\/p>\n
Used only when ‘apache-like’ pm_style is selected
<value name="MinSpareServers">5<\/value><\/p>\n
Used only when ‘apache-like’ pm_style is selected
<value name="MaxSpareServers">35<\/value><\/p>\n
Should be used when ‘max_execution_time’ ini option does not stop script execution for some reason
‘0s’ means ‘off’
<value name="request_terminate_timeout">0s<\/value><\/p>\n
‘0s’ means ‘off’
<value name="request_slowlog_timeout">0s<\/value><\/p>\n
<value name="slowlog">logs\/slow.log<\/value><\/p>\n
<value name="rlimit_files">51200<\/value><\/p>\n
<value name="rlimit_core">0<\/value><\/p>\n
<value name="chroot"><\/value><\/p>\n
<value name="chdir"><\/value><\/p>\n
If not set, they will be redirected to \/dev\/null, according to FastCGI specs
<value name="catch_workers_output">yes<\/value><\/p>\n
Useful to work around memory leaks in 3rd party libraries.
For endless request processing please specify 0
Equivalent to PHP_FCGI_MAX_REQUESTS
<value name="max_requests">10240<\/value><\/p>\n
Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+)
Makes sense only with AF_INET listening socket.
<value name="allowed_clients">127.0.0.1<\/value><\/p>\n
All $VARIABLEs are taken from current environment
<value name="environment">
<value name="HOSTNAME">$HOSTNAME<\/value>
<value name="PATH">\/usr\/local\/bin:\/usr\/bin:\/bin<\/value>
<value name="TMP">\/tmp<\/value>
<value name="TMPDIR">\/tmp<\/value>
<value name="TEMP">\/tmp<\/value>
<value name="OSTYPE">$OSTYPE<\/value>
<value name="MACHTYPE">$MACHTYPE<\/value>
<value name="MALLOC_CHECK_">2<\/value>
<\/value><\/p>\n
# \/usr\/local\/webserver\/php\/sbin\/php-fpm start<\/p>\n
# cd pcre-7.7\/
# .\/configure
# make && make install
# cd ..\/<\/p>\n
# cd nginx-0.7.19\/
# .\/configure –user=www –group=www –prefix=\/usr\/local\/webserver\/nginx –with-http_stub_status_module –with-http_ssl_module
# make
# make install
# cd ..\/<\/p>\n
# chmod +w \/logs
# chown -R www:www \/logs<\/p>\n
# vi \/usr\/local\/webserver\/nginx\/conf\/nginx.conf
\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9(\u8bf7\u6ce8\u610f\u4ee5\u4e0b\u5185\u5bb9\u4e2d"\u2191"\u6807\u5fd7\u540e\u7684\u5185\u5bb9\u4e0d\u80fd\u51fa\u73b0\u5728\u5b9e\u9645\u6587\u4ef6\u4e2d)\uff1a<\/p>\n
\u2191 Nginx\u6bcf\u4e2a\u8fdb\u7a0b\u8017\u8d3910M~12M\u5185\u5b58<\/p>\n
worker_rlimit_nofile 51200;<\/p>\n
{
use epoll;
worker_connections 51200;
}<\/p>\n
{
include mime.types;
default_type application\/octet-stream;<\/p>\n
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;<\/p>\n
tcp_nopush on;<\/p>\n
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;<\/p>\n
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text\/plain application\/x-javascript text\/css application\/xml;
gzip_vary on;<\/p>\n
\u2191 \u5b9a\u4e49\u4e00\u4e2a\u53eb\u201ccrash\u201d\u7684\u8bb0\u5f55\u533a\uff0c\u603b\u5bb9\u91cf\u4e3a 10M\uff0c\u4ee5\u53d8\u91cf $binary_remote_addr \u4f5c\u4e3a\u4f1a\u8bdd\u7684\u5224\u65ad\u57fa\u51c6\uff08\u5373\u4e00\u4e2a\u5730\u5740\u4e00\u4e2a\u4f1a\u8bdd\uff09\uff0c\u5f53\u533a\u7684\u5927\u5c0f\u4e3a 1M \u7684\u65f6\u5019\uff0c\u5927\u7ea6\u53ef\u4ee5\u8bb0\u5f55 32000 \u4e2a\u4f1a\u8bdd\u4fe1\u606f\uff08\u4e00\u4e2a\u4f1a\u8bdd\u5360\u7528 32 bytes\uff09<\/p>\n
{
listen 80;
server_name 222.17.177.205;
index index.html index.htm index.php;
root \/wwwroot;<\/p>\n
\u2191 *\u6b64\u5904\u5df2\u88ab#\u6ce8\u91ca\u6389\u4e86\uff0c\u5373\u4e0d\u8d77\u4f5c\u7528*\u5b9a\u4e49\u6574\u4e2a\u7f51\u7ad9\u7684\u9650\u5236\u3002\u6b64\u5904\u4e3a\u5728"crash"\u8bb0\u5f55\u533a\u4e2d\uff0c\u4ee5\u53d8\u91cf $binary_remote_addr \u4f5c\u4e3a\u4f1a\u8bdd\u7684\u5224\u65ad\u57fa\u51c6\uff08\u5373\u4e00\u4e2a\u5730\u5740\u4e00\u4e2a\u4f1a\u8bdd\uff09\uff0c\u9650\u5236\u7f51\u7ad9\u5168\u5c40\u76ee\u5f55\uff0c\u4e00\u4e2a\u4f1a\u8bdd\u53ea\u80fd\u8fdb\u884c5\u4e2a\u8fde\u63a5\uff08\u5373\u4e00\u4e2aIP\u53ea\u80fd\u53d1\u8d775\u4e2a\u8fde\u63a5\uff0c\u591a\u8fc75\u4e2a\uff0c\u4e00\u5f8b503\u9519\u8bef\uff09<\/p>\n
{
#fastcgi_pass unix:\/tmp\/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}<\/p>\n
{
expires 30d;
}<\/p>\n
{
expires 1h;
}<\/p>\n
limit_conn crash 2;
\u2191 \u5b9a\u4e49resource\u76ee\u5f55\u7684\u9650\u5236\u3002\u6b64\u5904\u4e3a\u5728"crash"\u8bb0\u5f55\u533a\u4e2d\uff0c\u4ee5\u53d8\u91cf $binary_remote_addr \u4f5c\u4e3a\u4f1a\u8bdd\u7684\u5224\u65ad\u57fa\u51c6\uff08\u5373\u4e00\u4e2a\u5730\u5740\u4e00\u4e2a\u4f1a\u8bdd\uff09\uff0c\u9650\u5236resource\u76ee\u5f55\uff0c\u4e00\u4e2a\u4f1a\u8bdd\u53ea\u80fd\u8fdb\u884c2\u4e2a\u8fde\u63a5\uff08\u5373\u4e00\u4e2aIP\u53ea\u80fd\u53d1\u8d772\u4e2a\u8fde\u63a5\uff0c\u591a\u8fc72\u4e2a\uff0c\u4e00\u5f8b503\u9519\u8bef\uff09
}<\/p>\n
‘$status $body_bytes_sent "$http_referer" ‘
‘"$http_user_agent" $http_x_forwarded_for’;
access_log \/logs\/access.log access;
sendfile on;
tcp_nopush on;
client_max_body_size 50m;
\u2191 \u7f51\u7ad9\u7a0b\u5e8f\u4e2d\u5141\u8bb8\u4e0a\u4f20\u7684\u6700\u5927size\uff0c\u8fd9\u91cc\u8bbe\u7f6e\u621050M\uff0c\u8fd9\u91cc\u53ea\u662fnginx\u7684\u9650\u5236\uff0cPHP\u672c\u8eab\u9650\u52362M
}
}<\/p>\n
\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9:<\/p>\n
fastcgi_param SERVER_SOFTWARE nginx;<\/p>\n
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;<\/p>\n
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;<\/p>\n
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;<\/p>\n
fastcgi_param REDIRECT_STATUS 200;<\/p>\n
# \/usr\/local\/webserver\/nginx\/sbin\/nginx<\/p>\n
# \/usr\/local\/webserver\/nginx\/sbin\/nginx -t
\u5982\u679c\u6d4b\u8bd5ok successfully\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u547d\u4ee4\u91cd\u542fNginx
(\u7b2c1\u79cd)# pkill nginx
# \/usr\/local\/webserver\/nginx\/conf\/nginx.conf
(\u7b2c2\u79cd)# kill -HUP `cat \/usr\/local\/webserver\/nginx\/nginx.pid`
# \/usr\/local\/webserver\/nginx\/conf\/nginx.conf
(\u7b2c3\u79cd)# ps -ef | grep "nginx: master process" | grep -v "grep" | awk -F ‘ ‘ ‘{print $2}’
# kill -HUP \u6570\u5b57
\u2191 \u6b64\u6570\u5b57\u6765\u81ea\u4e8e\u4e0a\u4e00\u6761\u547d\u4ee4\u6267\u884c\u540e\u5c4f\u5e55\u8f93\u51fa\u7684\u6570\u5b57\uff0c\u5373Nginx\u7684pid\u8fdb\u7a0b\u53f7
# \/usr\/local\/webserver\/nginx\/conf\/nginx.conf<\/p>\n
the configuration file \/usr\/local\/webserver\/nginx\/conf\/nginx.conf syntax is ok
the configuration file \/usr\/local\/webserver\/nginx\/conf\/nginx.conf was tested successfully<\/p>\n
\u5728\u672b\u5c3e\u589e\u52a0\u4ee5\u4e0b\u5185\u5bb9:
\/bin\/sh \/usr\/local\/webserver\/mysql\/bin\/mysqld_safe –defaults-file=\/usr\/local\/webserver\/mysql\/my.cnf &
ulimit -SHn 51200
\/usr\/local\/webserver\/php\/sbin\/php-fpm start
\/usr\/local\/webserver\/nginx\/sbin\/nginx<\/p>\n
\u5728\u6587\u4ef6\u672b\u5c3e\u589e\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 5000 65000<\/p>\n
\u2191 \u4f7f\u914d\u7f6e\u7acb\u5373\u751f\u6548<\/p>\n
\u2191 \u521b\u5efa\u5207\u5272\u811a\u672c<\/p>\n
#!\/bin\/bash
# This script run at 00:00<\/p>\n
logs_path="\/logs\/"<\/p>\n
mv ${logs_path}access.log ${logs_path}$(date -d "yesterday" +"%Y")\/$(date -d "yesterday" +"%m")\/access_$(date -d "yesterday" +"%Y%m%d").log
mv ${logs_path}nginx_error.log ${logs_path}$(date -d "yesterday" +"%Y")\/$(date -d "yesterday" +"%m")\/nginx_error_$(date -d "yesterday" +"%Y%m%d").log
kill -USR1 `cat \/usr\/local\/webserver\/nginx\/nginx.pid`<\/p>\n
\u2191 \u7f16\u8f91\u8ba1\u5212\u4efb\u52a1\u5217\u8868<\/p>\n
00 00 * * * \/bin\/bash \/usr\/local\/webserver\/nginx\/sbin\/cut_nginx_log.sh
\u2191 \u6bcf\u5929\u51cc\u666800:00\u5207\u5272nginx\u8bbf\u95ee\u65e5\u5fd7<\/p>\n","protected":false},"excerpt":{"rendered":"
\u4e3b\u8981\u5185\u5bb9\u6709\uff1a
[\u7528\u6237\u7ba1\u7406\u4e0e\u7528\u6237\u5b89\u5168]
[\u8bbe\u7f6e\u7cfb\u7edf\u65f6\u95f4\u53ca\u81ea\u52a8\u540c\u6b65\u7cfb\u7edf\u65f6\u95f4]
[\u5173\u95ed\u4e0d\u9700\u8981\u7684\u670d\u52a1]
[\u7cfb\u7edf\u66f4\u65b0]
[\u7528OpenSSH\u6784\u5efaSSH\u670d\u52a1\u5668]<\/p>\n