{"id":764,"date":"2011-03-02T20:35:15","date_gmt":"2011-03-02T12:35:15","guid":{"rendered":"http:\/\/www.jpuyy.com\/blog\/?p=764"},"modified":"2012-12-28T13:57:04","modified_gmt":"2012-12-28T05:57:04","slug":"use-nginx-as-web-server","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=764","title":{"rendered":"nginx\u5b89\u88c5| lnmp | apache\u6362\u4e3anginx | \u7981\u7528apache"},"content":{"rendered":"<p>\u529e\u516c\u5ba4\u7684\u7535\u8111\uff0c\u62ff\u6765\u7528\u7528\uff0c\u8bd5\u8bd5nginx\u7684\u7279\u6027<br \/>\n\u521d\u6b65\u89c9\u5f97\u8981\u662f\u5378\u8f7d\u53ef\u80fd\u6bd4\u8f83\u9ebb\u70e6\uff0c\u53cd\u6b63\u7535\u8111\u7a7a\u95f4\u4e5f\u5927<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\n<h2>\u91c7\u53d6\u4e0d\u5378\u8f7d\uff0c\u505c\u6b62apache\u670d\u52a1\uff0c\u5e76\u7981\u6b62\u5176\u5f00\u673a\u542f\u52a8\u7684\u65b9\u6cd5<\/h2>\n<\/li>\n<\/ul>\n<p>\u5148\u67e5\u770bapache\u670d\u52a1<\/p>\n<p>#ps -ef | grep apache2<\/p>\n<p>root 1243 1 0 19:50 ? 00:00:00 \/usr\/sbin\/apache2 -k start<br \/>\nwww-data 1264 1243 0 19:50 ? 00:00:00 \/usr\/sbin\/apache2 -k start<br \/>\nwww-data 1265\u3002\u3002\u3002\u3002\u3002\u3002apache2 -k start<br \/>\nroot 3154 2796 0 20:30 pts\/0 00:00:00 grep &#8211;color=auto apache2<br \/>\n\u505c\u6b62apache2<\/p>\n<p>#service apache2 stop<\/p>\n<p>* Stopping web server apache2 &#8230; waiting [ OK ]<br \/>\n\u91cd\u542f\u4e86\u679c\u771f\u53c8\u51fa\u73b0\u4e86\uff0c\u90a3\u4e48\u8bf4\u660e\u8981\u5728\u542f\u52a8\u4e0a\u4e0b\u624b<\/p>\n<p>It works!<br \/>\nThis is the default web page for this server.<\/p>\n<p>\u7f51\u4e0a\u67e5\u627e\u4f8b\u5b50\uff08\u5176\u4ed6\u90fd\u7c7b\u4f3c\uff09\uff1a<br \/>\n\u5220\u9664apache2\u968f\u673a\u5668\u542f\u52a8\u7684\u670d\u52a1<\/p>\n<p>#update-rc.d -f apache2 remove<\/p>\n<p>Removing any system startup links for \/etc\/init.d\/apache2 &#8230;<br \/>\n\/etc\/rc0.d\/K09apache2<br \/>\n\/etc\/rc1.d\/K09apache2<br \/>\n\/etc\/rc2.d\/S91apache2<br \/>\n\/etc\/rc3.d\/S91apache2<br \/>\n\/etc\/rc4.d\/S91apache2<br \/>\n\/etc\/rc5.d\/S91apache2<br \/>\n\/etc\/rc6.d\/K09apache2<br \/>\n\u594f\u6548<\/p>\n<p>\u63a5\u4e0b\u6765\u60f3\u5b89\u88c5nginx<br \/>\n\u4e5f\u4e0d\u77e5\u9053\u662f\u4ece\u6e90\u91cc\u76f4\u63a5\u5b89\u88c5\u597d\u8fd8\u662f\u7f16\u8bd1\u5b89\u88c5\u597d<br \/>\n\u7f16\u8bd1\u4e86\u540e\u6ca1\u6210\u529f\uff0c\u7f3a\u5c11\u683c\u7269\u81f4\u77e5\u7cbe\u795e<br \/>\n\u540e\u6765\u7528\u7684lnmp \u811a\u672c<br \/>\nnginx\u662f\u8d77\u6765\u4e86\uff0c\u4f46\u662f\u8fd8\u662f\u6709\u6743\u6839\u95ee\u9898<br \/>\n\u5bf9\u5404\u4e2a\u6587\u4ef6\u76ee\u5f55\u4e0d\u592a\u719f<br \/>\n\u5bfc\u81f4\u8fd8\u662f\u8bf7ihipop\u6765\u5e2e\u5fd9<br \/>\n\u7ecf\u8fc7\u591a\u6b21\u5b9e\u9a8c\uff0c\u5b8c\u6574\u5b89\u88c5\u8fc7\u7a0b\u5982\u4e0b\uff08\u4ee5\u4e0b\u5185\u5bb9 added at 2011-8-7\uff09\uff1a<\/p>\n<p>\u4ee5\u4e0b\u5b89\u88c5\u5728debian\u4e0b\u8fdb\u884c(ubuntu\u4e0b\u81ea\u5df1\u6709php\uff0c\u4e0d\u9700\u8981\uff0cubuntu\u7684\u5b89\u88c5\u65b9\u6cd5http:\/\/wiki.ubuntu.org.cn\/Nginx)<\/p>\n<p>\u5b89\u88c5\u57fa\u672c\u73af\u5883:<\/p>\n<pre>apt-get install build-essential<\/pre>\n<ul>\n<li>\n<h2>\u7f16\u8bd1\u5b89\u88c5nginx:<\/h2>\n<\/li>\n<\/ul>\n<p>\u5148\u4e0b\u8f7d\u597d\u6700\u65b0\u7248\u672c\u7684nginx<a title=\"nginx\u4e0b\u8f7d\u94fe\u63a5\" href=\"http:\/\/nginx.org\/en\/download.html\" target=\"_blank\">http:\/\/nginx.org\/en\/download.html<\/a><\/p>\n<pre>wget http:\/\/nginx.org\/download\/nginx-0.8.54.tar.gz\r\n tar vxzf nginx-0.8.54.tar.gz\r\n cd nginx-0.8.54\r\n .\/configure --with-http_ssl_module\r\n make &amp;&amp; make install<\/pre>\n<p>\u4e0b\u9762\u4e3a\u7f16\u8bd1\u91cc\u9047\u5230\u7684\u95ee\u9898\uff0c\u7f3a\u5c11\u4e86\u67d0\u4e9b\u5e93\uff0capt-get\u4ee5\u540e\u5c31\u6ca1\u6709\u95ee\u9898\u4e86\uff1a<\/p>\n<p>.\/configure: error: the HTTP rewrite module requires the PCRE library.<br \/>\n\u8fd9\u65f6\u8981\u6267\u884c\u4e0b\u9762\u547d\u4ee4(\u56e0\u4e3arewrite\u6a21\u5757\u9700\u8981)<br \/>\napt-get install libpcre3-dev<\/p>\n<p>.\/configure: error: the HTTP gzip module requires the zlib library.<br \/>\n\u8fd9\u65f6\u8981\u6267\u884c\u4e0b\u9762\u547d\u4ee4(\u56e0\u4e3agzip\u6a21\u5757\u9700\u8981)<br \/>\napt-get install zlib1g-dev<\/p>\n<p>\u5728.\/configure &#8211;with-http_ssl_module\u65f6\u63d0\u793a\u5982\u4e0b\u4fe1\u606f<br \/>\n.\/configure: error: SSL modules require the OpenSSL library.<br \/>\n\u8fd9\u65f6\u8981\u6267\u884c\u4e0b\u9762\u547d\u4ee4(\u56e0\u4e3aOpenSSL\u6a21\u5757\u9700\u8981)<br \/>\napt-get install libssl-dev<\/p>\n<ul>\n<li>\n<h2>\u5b89\u88c5mysql\uff1a<\/h2>\n<\/li>\n<\/ul>\n<pre>apt-get install mysql-server\u00a0 php5-mysql<\/pre>\n<p>\u8fc7\u7a0b\u4e2d\u4f1a\u63d0\u793a\u8f93\u5165mysql\u6839\u7528\u6237\u5bc6\u7801<\/p>\n<ul>\n<li>\n<h2>\u5b89\u88c5php:<\/h2>\n<\/li>\n<\/ul>\n<p>php5-fpm\u7684\u6e90<\/p>\n<pre>deb http:\/\/packages.dotdeb.org stable all\r\ndeb-src http:\/\/packages.dotdeb.org stable all\r\ndeb http:\/\/php53.dotdeb.org stable all<\/pre>\n<p>\u4e3a\u7701\u529b\u6267\u884c\u4e0b\u9762\u547d\u4ee4\uff1a<\/p>\n<pre>echo \"deb http:\/\/packages.dotdeb.org stable all\" &gt;&gt; \/etc\/apt\/sources.list;echo \"deb-src http:\/\/packages.dotdeb.org stable all\" &gt;&gt; \/etc\/apt\/sources.list;echo \"deb http:\/\/php53.dotdeb.org stable all\" &gt;&gt; \/etc\/apt\/sources.list<\/pre>\n<p>\u52a0\u5165\u540eapt-get update\u51fa\u73b0\u4ee5\u4e0b\u63d0\u793a<\/p>\n<p>\u6b63\u5728\u8bfb\u53d6\u8f6f\u4ef6\u5305\u5217\u8868&#8230; \u5b8c\u6210<br \/>\nW: GPG \u9519\u8bef\uff1ahttp:\/\/packages.dotdeb.org stable Release: \u7531\u4e8e\u6ca1\u6709\u516c\u94a5\uff0c\u65e0\u6cd5\u9a8c\u8bc1\u4e0b\u5217\u7b7e\u540d\uff1a NO_PUBKEY E9C74FEEA2098A6E<br \/>\nW: GPG \u9519\u8bef\uff1ahttp:\/\/php53.dotdeb.org stable Release: \u7531\u4e8e\u6ca1\u6709\u516c\u94a5\uff0c\u65e0\u6cd5\u9a8c\u8bc1\u4e0b\u5217\u7b7e\u540d\uff1a NO_PUBKEY E9C74FEEA2098A6E<\/p>\n<p>\u6545\u901a\u8fc7\u4e0b\u9762\u547d\u4ee4\u5bfc\u5165\u516c\u94a5<\/p>\n<pre>wget http:\/\/www.dotdeb.org\/dotdeb.gpg\r\ncat dotdeb.gpg | apt-key add -<\/pre>\n<p>apt-get update<\/p>\n<p>apt-get install php5-fpm<\/p>\n<p>\u81f3\u6b64\uff0clnmp\u5b89\u88c5\u5b8c\u6210\u3002<\/p>\n<p>\u8981\u60f3\u6210\u529f\u89e3\u8bd1\u51faphp\uff0c\u5728nginx.conf \u91cc\u76f8\u5e94 server \u90e8\u5206\u505a\u5982\u4e0b\u4fee\u6539\uff1a<\/p>\n<p># pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000<\/p>\n<p>location ~ \\.php$ {<br \/>\nroot\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/web\/;<br \/>\nfastcgi_pass\u00a0\u00a0 127.0.0.1:9000;<br \/>\nfastcgi_index\u00a0 index.php;<br \/>\nfastcgi_param\u00a0 SCRIPT_FILENAME\u00a0 \/web\/$fastcgi_script_name;<br \/>\ninclude\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fastcgi_params;<br \/>\n}<\/p>\n<p>:)EOT<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u529e\u516c\u5ba4\u7684\u7535\u8111\uff0c\u62ff\u6765\u7528\u7528\uff0c\u8bd5\u8bd5nginx\u7684\u7279\u6027 \u521d\u6b65\u89c9\u5f97\u8981\u662f\u5378\u8f7d\u53ef\u80fd\u6bd4\u8f83\u9ebb\u70e6\uff0c\u53cd\u6b63\u7535\u8111\u7a7a\u95f4\u4e5f\u5927 &nbsp; \u91c7\u53d6\u4e0d\u5378\u8f7d\uff0c\u505c\u6b62apache\u670d\u52a1\uff0c\u5e76\u7981\u6b62\u5176\u5f00\u673a\u542f\u52a8\u7684\u65b9\u6cd5 \u5148\u67e5\u770bapache\u670d\u52a1 #ps -ef | grep apache2 root 1243 1 0 19:50 ? 00:00:00 \/usr\/sbin\/apache2 -k start www-data 1264 1243 0 19:50 ? 00:00:00 \/usr\/sbin\/apache2 -k start www-data 1265\u3002\u3002\u3002\u3002\u3002\u3002apache2 -k start root 3154 2796 0 20:30 pts\/0 00:00:00 grep &#8211;color=auto apache2 \u505c\u6b62apache2 #service apache2 stop * Stopping web server apache2 &#8230; waiting [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[23],"class_list":["post-764","post","type-post","status-publish","format-standard","hentry","category-linux","tag-summary"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=764"}],"version-history":[{"count":43,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/764\/revisions"}],"predecessor-version":[{"id":4489,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/764\/revisions\/4489"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}