﻿{"id":538,"date":"2011-07-15T18:27:44","date_gmt":"2011-07-15T10:27:44","guid":{"rendered":"http:\/\/nick.workao.org\/?p=538"},"modified":"2011-07-15T18:27:44","modified_gmt":"2011-07-15T10:27:44","slug":"ubuntu-9-04-server%e7%94%a8apt%e5%ae%89%e8%a3%85nginx%e5%b9%b6%e9%85%8d%e7%bd%aephpfastcgi","status":"publish","type":"post","link":"https:\/\/nick.txtcc.com\/index.php\/linux\/538","title":{"rendered":"Ubuntu 9.04 server\u7528apt\u5b89\u88c5nginx\u5e76\u914d\u7f6ephp(fastcgi)"},"content":{"rendered":"<p>\u7531\u4e8eUbuntu 904\u5df2\u7ecf\u5305\u542b\u4e86nginx\uff0c\u6240\u4ee5\u6839\u672c\u4e0d\u8981\u7f16\u8bd1\uff0c\u5b89\u88c5\u8d85\u7b80\u5355\uff01<\/p>\n<p>\u4fee\u6539\/etc\/apt\/sources.list\u6587\u4ef6\u5185\u5bb9\u4e3a\u56fd\u5185\u955c\u50cf\uff0c\u7136\u540e\u8fd0\u884c\uff1a<\/p>\n<p>apt-get update\napt-get install nginx<\/p>\n<p>\u5373\u53ef\u5b8c\u6210\u5b89\u88c5<\/p>\n<p>\u542f\u52a8nginx\uff1a<\/p>\n<p>\/etc\/init.d\/nginx start\n\u7136\u540e\u5c31\u53ef\u4ee5\u8bbf\u95ee\u4e86\uff0c<a href=\"http:\/\/localhost\/\">http:\/\/localhost\/<\/a> \uff0c \u4e00\u5207\u6b63\u5e38\uff01\u5982\u679c\u4e0d\u80fd\u8bbf\u95ee\uff0c\u5148\u4e0d\u8981\u7ee7\u7eed\uff0c\u770b\u770b\u662f\u4ec0\u4e48\u539f\u56e0\uff0c\u89e3\u51b3\u4e4b\u540e\u518d\u7ee7\u7eed\u3002<\/p>\n<p>\u4e0b\u9762\u914d\u7f6ephp\u548cmysql\u3002<\/p>\n<p>\u5b89\u88c5php\u548cMySQL:<\/p>\n<p>apt-get install php5-cli php5-cgi mysql-server-5.0 php5-mysql\n\u6211\u4eec\u9700\u8981\/usr\/bin\/spawn-fcgi\u8fd9\u4e2a\u6587\u4ef6\uff0c\u800c\u5b83\u662f\u5c5e\u4e8elighttpd\u8fd9\u4e2a\u5305\u91cc\u9762\u7684\uff0c\u6240\u4ee5\u6211\u4eec\u5b89\u88c5lighttpd\u7136\u540e\u628a\u5b83\u8bbe\u7f6e\u4e3a\u5f00\u673a\u4e0d\u542f\u52a8\uff1a<\/p>\n<p>apt-get install lighttpd #\u6211\u4eec\u53ea\u8981\/usr\/bin\/spawn-fcgi\nrcconf #\u53bb\u6389lighttpd\u5f00\u673a\u81ea\u542f\u52a8\n\u4fee\u6539nginx\u7684\u914d\u7f6e\u6587\u4ef6\uff1a\/etc\/nginx\/sites-available\/default\n\u4fee\u6539 server_name 58.30.17.154;\n\u4fee\u6539index\u7684\u4e00\u884c\u4fee\u6539\u4e3a\uff1a\nindex index.php index.html index.htm;<\/p>\n<p>\u53bb\u6389\u4e0b\u9762\u90e8\u5206\u7684\u6ce8\u91ca\uff1a<\/p>\n<p>location ~ .php$ {\nfastcgi_pass   127.0.0.1:9000;\nfastcgi_index  index.php;\nfastcgi_param  SCRIPT_FILENAME \/var\/www\/nginx-default$fastcgi_script_name;\ninclude \/etc\/nginx\/fastcgi_params;\n}\n\u91cd\u65b0\u542f\u52a8nginx:<\/p>\n<p>\/etc\/init.d\/nginx stop\n\/etc\/init.d\/nginx start\n\u542f\u52a8fastcgi php:<\/p>\n<p>spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f \/usr\/bin\/php-cgi\n\u4e3a\u4e86\u8ba9php-cgi\u5f00\u673a\u81ea\u542f\u52a8\uff1a<\/p>\n<p>cd \/etc\/init.d\ncp nginx php-cgi\nvim php-cgi\n\u66ff\u6362nginx\u4e3aphp-cgi\n\u5e76\u4fee\u6539\u76f8\u5e94\u90e8\u5206\u4e3a\uff1a<\/p>\n<p>DAEMON=\/usr\/bin\/spawn-fcgi\nDAEMON_OPTS=\u201d-a 127.0.0.1 -p 9000 -C 10 -u www-data -f \/usr\/bin\/php-cgi\u201d\n\u2026\nstop)\necho -n \u201cStopping $DESC: \u201d\npkill -9 php-cgi\necho \u201c$NAME.\u201d\n\u7136\u540e\u8fd0\u884crcconf\u8bbe\u7f6ephp-cgi\u4e3a\u5f00\u673a\u81ea\u542f\u52a8<\/p>\n<p>\u5728\/var\/www\/nginx-default\/\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\uff1a<\/p>\n<p>echo \u2018< ?phpinfo();?>\u2019  > \/var\/www\/nginx-default\/index.php\n\u7136\u540e\u6d4f\u89c8\u5668\u8bbf\u95eenginx\u5c31\u53ef\u4ee5\u770b\u5230\u4e00\u5207\u6b63\u5e38\u4e86<\/p>","protected":false},"excerpt":{"rendered":"<p>\u7531\u4e8eUbuntu 904\u5df2\u7ecf\u5305\u542b\u4e86nginx\uff0c\u6240\u4ee5\u6839\u672c\u4e0d\u8981\u7f16\u8bd1\uff0c\u5b89\u88c5\u8d85\u7b80\u5355\uff01 \u4fee\u6539\/etc\/apt\/sources.list\u6587\u4ef6\u5185\u5bb9\u4e3a\u56fd\u5185\u955c\u50cf\uff0c\u7136\u540e\u8fd0\u884c\uff1a apt-get update apt-get&#46;&#46;&#46;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[305,268,442,7],"class_list":["post-538","post","type-post","status-publish","format-standard","hentry","category-linux","tag-fastcgi","tag-nginx","tag-php","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/538","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/comments?post=538"}],"version-history":[{"count":1,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/538\/revisions"}],"predecessor-version":[{"id":539,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/538\/revisions\/539"}],"wp:attachment":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/media?parent=538"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/categories?post=538"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/tags?post=538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}