{"id":278,"date":"2013-03-15T17:01:58","date_gmt":"2013-03-15T09:01:58","guid":{"rendered":"http:\/\/www.shuran.cn\/?p=278"},"modified":"2013-09-24T17:42:28","modified_gmt":"2013-09-24T09:42:28","slug":"%e9%98%bf%e9%87%8c%e4%ba%91%e6%9c%8d%e5%8a%a1%e5%99%a8-%e5%ae%89%e8%a3%85-nginxphpmysql-%e7%ac%ac%e4%b8%80%e6%ad%a5%e5%ae%89%e8%a3%85nginx","status":"publish","type":"post","link":"https:\/\/www.shuran.cn\/?p=278","title":{"rendered":"\u963f\u91cc\u4e91\u670d\u52a1\u5668 \u5b89\u88c5 nginx+php+mysql----------\u7b2c\u4e00\u6b65\u5b89\u88c5nginx"},"content":{"rendered":"<p>1\u3001\u6309\u7167\u5b98\u65b9\u63d0\u4f9b\u7684\u811a\u672c\u6302\u8f7d\u811a\u672c\uff0c\u589e\u52a0swap\u5206\u533a\u3002<br \/>\n2\u3001\u4e0b\u8f7dnginx\uff0c\u89e3\u538b\u7f29\uff0c\u914d\u7f6enginx<\/p>\n<blockquote><p>.\/configure --prefix=\/home\/web\/nginx --conf-path=\/home\/web\/nginx\/conf\/nginx.conf --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --with-file-aio --with-pcre<\/p><\/blockquote>\n<p>\u62a5\u9519\uff0c\u6ca1\u6709C\u7f16\u8bd1\u73af\u5883\uff0c\u5b89\u88c5\u4e4b<\/p>\n<p>yum -y install gcc<br \/>\nyum install -y gcc gcc-c++<br \/>\nyum install -y install make gcc<\/p>\n<p>\u518d\u6765<br \/>\n.\/configure...<br \/>\n\u62a5\u9519\uff0c.\/configure: error: the HTTP rewrite module requires the PCRE library.<\/p>\n<p>\u597d\u5427\uff0c\u4e0b\u8f7d wget ftp:\/\/ftp.csx.cam.ac.uk\/pub\/software\/programming\/pcre\/pcre-8.32.tar.gz<br \/>\ntar -zxvf pcre-8.32.tar.gz<br \/>\ncd pcre-8.32<br \/>\n.\/configure<br \/>\nmake<br \/>\nmake install<\/p>\n<p>\u518d\u6765\uff0c\u62a5\u9519.\/configure: error: SSL modules require the OpenSSL library.<br \/>\n\u6ca1\u8bf4\u7684\uff0cyum -y install openssl openssl-devel<\/p>\n<p>\u518d\u6765<br \/>\n.\/configure...<br \/>\nmake<br \/>\nmake install<br \/>\ngroupadd nginx<br \/>\nuseradd -g nginx nginx<\/p>\n<p>mkdir \/home\/web\/nginx\/conf\/webs<br \/>\nvi \/home\/web\/nginx\/conf\/nginx.conf<\/p>\n<p>\u914d\u7f6e\u6587\u4ef6\u5982\u4e0b\uff1a<\/p>\n<blockquote><p>user nobody;<br \/>\nworker_processes 1;<\/p>\n<p>#error_log logs\/error.log;<br \/>\n#error_log logs\/error.log notice;<br \/>\n#error_log logs\/error.log info;<\/p>\n<p>#pid logs\/nginx.pid;<br \/>\nevents {<br \/>\nuse epoll;<br \/>\nworker_connections 1024;<br \/>\n}<\/p>\n<p>http {<br \/>\ninclude mime.types;<br \/>\ndefault_type application\/octet-stream;<\/p>\n<p>#log_format main '$remote_addr - $remote_user [$time_local] \"$request\" '<br \/>\n# '$status $body_bytes_sent \"$http_referer\" '<br \/>\n# '\"$http_user_agent\" \"$http_x_forwarded_for\"';<\/p>\n<p>#access_log logs\/access.log main;<\/p>\n<p>sendfile on;<br \/>\ntcp_nopush on;<br \/>\nkeepalive_timeout 65;<\/p>\n<p>client_max_body_size 50m;<br \/>\nlarge_client_header_buffers 4 128k;<br \/>\nclient_header_buffer_size 128k;<br \/>\nserver_names_hash_bucket_size 128;<\/p>\n<p>fastcgi_connect_timeout 300;<br \/>\nfastcgi_send_timeout 300;<br \/>\nfastcgi_read_timeout 300;<br \/>\nfastcgi_buffer_size 64k;<br \/>\nfastcgi_buffers 4 64k;<br \/>\nfastcgi_busy_buffers_size 128k;<br \/>\nfastcgi_temp_file_write_size 128k;<\/p>\n<p>gzip_static on;<br \/>\ngzip on;<br \/>\ngzip_min_length 1k;<br \/>\ngzip_buffers 4 16k;<br \/>\ngzip_types text\/plain application\/x-javascript text\/css application\/xml;<br \/>\ngzip_disable \"MSIE [1-6]\\.\";<br \/>\ngzip_vary on;<br \/>\ngzip_proxied expired no-cache no-store private auth;<\/p>\n<p>aio on;<br \/>\ndirectio 1;<br \/>\noutput_buffers 1 128k;<\/p>\n<p>include webs\/*.conf;<\/p>\n<p># another virtual host using mix of IP-, name-, and port-based configuration<br \/>\n#<br \/>\n#server {<br \/>\n# listen 8000;<br \/>\n# listen somename:8080;<br \/>\n# server_name somename alias another.alias;<\/p>\n<p># location \/ {<br \/>\n# root html;<br \/>\n# index index.html index.htm;<br \/>\n# }<br \/>\n#}<br \/>\n# HTTPS server<br \/>\n#<br \/>\n#server {<br \/>\n# listen 443 ssl;<br \/>\n# server_name localhost;<\/p>\n<p># ssl_certificate cert.pem;<br \/>\n# ssl_certificate_key cert.key;<\/p>\n<p># ssl_session_cache shared:SSL:1m;<br \/>\n# ssl_session_timeout 5m;<\/p>\n<p># ssl_ciphers HIGH:!aNULL:!MD5;<br \/>\n# ssl_prefer_server_ciphers on;<\/p>\n<p># location \/ {<br \/>\n# root html;<br \/>\n# index index.html index.htm;<br \/>\n# }<br \/>\n#}<\/p>\n<p>}<\/p><\/blockquote>\n<p>\u914d\u7f6e\u901a\u7528\u7684php-cgi\u52a0\u8f7d\u811a\u672c<br \/>\nvi \/home\/web\/nginx\/conf\/fcgi.conf<\/p>\n<blockquote><p>fastcgi_param GATEWAY_INTERFACE CGI\/1.1;<br \/>\nfastcgi_param SERVER_SOFTWARE nginx;<br \/>\nfastcgi_param QUERY_STRING $query_string;<br \/>\nfastcgi_param REQUEST_METHOD $request_method;<br \/>\nfastcgi_param CONTENT_TYPE $content_type;<br \/>\nfastcgi_param CONTENT_LENGTH $content_length;<br \/>\nfastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br \/>\nfastcgi_param SCRIPT_NAME $fastcgi_script_name;<br \/>\nfastcgi_param REQUEST_URI $request_uri;<br \/>\nfastcgi_param DOCUMENT_URI $document_uri;<br \/>\nfastcgi_param DOCUMENT_ROOT $document_root;<br \/>\nfastcgi_param SERVER_PROTOCOL $server_protocol;<br \/>\nfastcgi_param REMOTE_ADDR $remote_addr;<br \/>\nfastcgi_param REMOTE_PORT $remote_port;<br \/>\nfastcgi_param SERVER_ADDR $server_addr;<br \/>\nfastcgi_param SERVER_PORT $server_port;<br \/>\nfastcgi_param SERVER_NAME $server_name;<\/p>\n<p># PHP only, required if PHP was built with --enable-force-cgi-redirect<br \/>\nfastcgi_param REDIRECT_STATUS 200;<\/p><\/blockquote>\n<p><em id=\"__mceDel\">\u4fdd\u5b58\u6587\u6863\u3002<\/em><\/p>\n<p>\u5efa\u7acb\u4e00\u4e2a\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>vi \/home\/web\/nginx\/conf\/webs\/defaults.conf<\/p>\n<p>\u8f93\u5165\u5982\u4e0b\u5185\u5bb9<\/p>\n<blockquote><p>server {<br \/>\nlisten 80;<br \/>\nserver_name XXX.COM;<\/p>\n<p>#charset koi8-r;<\/p>\n<p>#access_log logs\/host.access.log main;<\/p>\n<p>root \/home\/www\/xxx.com;<\/p>\n<p>index index.html index.htm index.php default.php;<\/p>\n<p>#error_page 404 \/404.html;<\/p>\n<p># redirect server error pages to the static page \/50x.html<br \/>\n#<br \/>\nerror_page 500 502 503 504 \/50x.html;<br \/>\nlocation = \/50x.html {<br \/>\nroot html;<br \/>\n}<\/p>\n<p># proxy the PHP scripts to Apache listening on 127.0.0.1:80<br \/>\n#<br \/>\n#location ~ \\.php$ {<br \/>\n# proxy_pass http:\/\/127.0.0.1;<br \/>\n#}<\/p>\n<p># pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000<br \/>\n#<br \/>\nlocation ~ \\.php$ {<br \/>\nfastcgi_pass 127.0.0.1:9000;<br \/>\nfastcgi_index index.php;<br \/>\ninclude fcgi.conf;<br \/>\n}<\/p>\n<p># deny access to .htaccess files, if Apache's document root<br \/>\n# concurs with nginx's one<br \/>\n#<br \/>\n#location ~ \/\\.ht {<br \/>\n# deny all;<br \/>\n#}<br \/>\n}<\/p><\/blockquote>\n<p>..........<br \/>\n\u914d\u7f6enginx\u542f\u52a8<\/p>\n<p>vi \/etc\/init.d\/nginx<\/p>\n<blockquote><p>#!\/bin\/sh<br \/>\n#<br \/>\n# nginx - this script starts and stops the nginx daemin<br \/>\n#<br \/>\n# chkconfig: 234 85 15<br \/>\n# description: Nginx is an HTTP(S) server, HTTP(S) reverse<br \/>\n# proxy and IMAP\/POP3 proxy server<br \/>\n# processname: nginx<br \/>\n# config: \/home\/web\/nginx\/conf\/nginx.conf<br \/>\n# pidfile: \/home\/web\/nginx\/logs\/nginx.pid<\/p>\n<p># Source function library.<br \/>\n. \/etc\/rc.d\/init.d\/functions<\/p>\n<p># Source networking configuration.<br \/>\n. \/etc\/sysconfig\/network<\/p>\n<p># Check that networking is up.<br \/>\n[ \"$NETWORKING\" = \"no\" ] &amp;&amp; exit 0<\/p>\n<p>nginx=\"\/home\/web\/nginx\/sbin\/nginx\"<br \/>\nprog=$(basename $nginx)<\/p>\n<p>NGINX_CONF_FILE=\"\/home\/web\/nginx\/conf\/nginx.conf\"<\/p>\n<p>lockfile=\/var\/lock\/subsys\/nginx<\/p>\n<p>start() {<br \/>\n[ -x $nginx ] || exit 5<br \/>\n[ -f $NGINX_CONF_FILE ] || exit 6<br \/>\necho -n $\"Starting $prog: \"<br \/>\ndaemon $nginx -c $NGINX_CONF_FILE<br \/>\nretval=$?<br \/>\necho<br \/>\n[ $retval -eq 0 ] &amp;&amp; touch $lockfile<br \/>\nreturn $retval<br \/>\n}<\/p>\n<p>stop() {<br \/>\necho -n $\"Stopping $prog: \"<br \/>\nkillproc $prog -QUIT<br \/>\nretval=$?<br \/>\necho<br \/>\n[ $retval -eq 0 ] &amp;&amp; rm -f $lockfile<br \/>\nreturn $retval<br \/>\n}<\/p>\n<p>restart() {<br \/>\nconfigtest || return $?<br \/>\nstop<br \/>\nstart<br \/>\n}<\/p>\n<p>reload() {<br \/>\nconfigtest || return $?<br \/>\necho -n $\"Reloading $prog: \"<br \/>\nkillproc $nginx -HUP<br \/>\nRETVAL=$?<br \/>\necho<br \/>\n}<\/p>\n<p>force_reload() {<br \/>\nrestart<br \/>\n}<\/p>\n<p>configtest() {<br \/>\n$nginx -t -c $NGINX_CONF_FILE<br \/>\n}<\/p>\n<p>rh_status() {<br \/>\nstatus $prog<br \/>\n}<\/p>\n<p>rh_status_q() {<br \/>\nrh_status &gt;\/dev\/null 2&gt;&amp;1<br \/>\n}<\/p>\n<p>case \"$1\" in<br \/>\nstart)<br \/>\nrh_status_q &amp;&amp; exit 0<br \/>\n$1<br \/>\n;;<br \/>\nstop)<br \/>\nrh_status_q || exit 0<br \/>\n$1<br \/>\n;;<br \/>\nrestart|configtest)<br \/>\n$1<br \/>\n;;<br \/>\nreload)<br \/>\nrh_status_q || exit 7<br \/>\n$1<br \/>\n;;<br \/>\nforce-reload)<br \/>\nforce_reload<br \/>\n;;<br \/>\nstatus)<br \/>\nrh_status<br \/>\n;;<br \/>\ncondrestart|try-restart)<br \/>\nrh_status_q || exit 0<br \/>\n;;<br \/>\n*)<br \/>\necho $\"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}\"<br \/>\nexit 2<br \/>\nesac<\/p><\/blockquote>\n<p>chmod +x \/etc\/init.d\/nginx<\/p>\n<p>\/sbin\/chkconfig nginx on<\/p>\n<p>\/sbin\/chkconfig --list nginx<br \/>\nnginx 0:off 1:off 2:on 3:on 4:on 5:on 6:off<\/p>\n<p>\u5b8c\u6210\u4e4b\u540e\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4e86<br \/>\nservice nginx start<br \/>\nservice nginx stop<br \/>\nservice nginx restart<br \/>\nservice nginx reload<br \/>\n\/etc\/init.d\/nginx start<br \/>\n\/etc\/init.d\/nginx stop<br \/>\n\/etc\/init.d\/nginx restart<br \/>\n\/etc\/init.d\/nginx reload<\/p>\n<p>\u5f88\u9057\u61be\uff0c\u542f\u52a8\u62a5\u9519\uff0c<br \/>\nStarting nginx: \/home\/web\/nginx\/sbin\/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory<\/p>\n<p>&gt; ldd $(which \/home\/web\/nginx\/sbin\/nginx)<\/p>\n<p>linux-vdso.so.1 =&gt; (0x00007fff3291f000)<br \/>\nlibpthread.so.0 =&gt; \/lib64\/libpthread.so.0 (0x0000003b99600000)<br \/>\nlibcrypt.so.1 =&gt; \/lib64\/libcrypt.so.1 (0x0000003ba5a00000)<br \/>\nlibpcre.so.1 =&gt; not found<br \/>\nlibssl.so.10 =&gt; \/usr\/lib64\/libssl.so.10 (0x00007f1a5d4fc000)<br \/>\nlibcrypto.so.10 =&gt; \/usr\/lib64\/libcrypto.so.10 (0x00007f1a5d162000)<br \/>\nlibdl.so.2 =&gt; \/lib64\/libdl.so.2 (0x0000003b99200000)<br \/>\nlibz.so.1 =&gt; \/lib64\/libz.so.1 (0x00007f1a5cf4b000)<br \/>\nlibc.so.6 =&gt; \/lib64\/libc.so.6 (0x0000003b98e00000)<br \/>\n\/lib64\/ld-linux-x86-64.so.2 (0x0000003b98a00000)<br \/>\nlibfreebl3.so =&gt; \/lib64\/libfreebl3.so (0x0000003ba6600000)<br \/>\nlibgssapi_krb5.so.2 =&gt; \/lib64\/libgssapi_krb5.so.2 (0x00007f1a5cd06000)<br \/>\nlibkrb5.so.3 =&gt; \/lib64\/libkrb5.so.3 (0x00007f1a5ca20000)<br \/>\nlibcom_err.so.2 =&gt; \/lib64\/libcom_err.so.2 (0x00007f1a5c81b000)<br \/>\nlibk5crypto.so.3 =&gt; \/lib64\/libk5crypto.so.3 (0x00007f1a5c5ef000)<br \/>\nlibkrb5support.so.0 =&gt; \/lib64\/libkrb5support.so.0 (0x00007f1a5c3e4000)<br \/>\nlibkeyutils.so.1 =&gt; \/lib64\/libkeyutils.so.1 (0x00007f1a5c1e0000)<br \/>\nlibresolv.so.2 =&gt; \/lib64\/libresolv.so.2 (0x0000003b9b200000)<br \/>\nlibselinux.so.1 =&gt; \/lib64\/libselinux.so.1 (0x00007f1a5bfc0000)<\/p>\n<p>\u7f3a\u5c11\u6587\u4ef6\uff0c\u90a3\u5c31\u7b80\u5355\u4e86\uff0cfind \u7136\u540eln<\/p>\n<p>ln -s \/usr\/local\/lib\/libpcre.so.1 \/lib64\/libpcre.so.1<\/p>\n<p>&nbsp;<\/p>\n<p>\u81f3\u6b64\uff0c\u542f\u52a8nginx \u6210\u529f<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u6309\u7167\u5b98\u65b9\u63d0\u4f9b\u7684\u811a\u672c\u6302\u8f7d\u811a\u672c\uff0c\u589e\u52a0swap\u5206\u533a\u3002 2\u3001\u4e0b\u8f7dnginx\uff0c\u89e3\u538b\u7f29\uff0c\u914d\u7f6enginx .\/confi\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.shuran.cn\/?p=278\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-278","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts\/278","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=278"}],"version-history":[{"count":14,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts\/278\/revisions"}],"predecessor-version":[{"id":410,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts\/278\/revisions\/410"}],"wp:attachment":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}