{"id":1003,"date":"2009-11-29T19:16:00","date_gmt":"2009-11-29T11:16:00","guid":{"rendered":"\/?p=1003"},"modified":"2009-11-29T19:16:00","modified_gmt":"2009-11-29T19:16:00","slug":"1003","status":"publish","type":"post","link":"https:\/\/blog.vimge.com\/archives\/linux\/1003.html","title":{"rendered":"CentOS 5.2\u7684Nginx+PHP+MySQL\u73af\u5883\u642d\u5efa"},"content":{"rendered":"

        PS\uff1a\u5982\u679cnginx\u5b89\u88c5\u5b8c\u6bd5\u540e\u770b\u4e0d\u5230\u6d4b\u8bd5\u9875\u9762\uff0c\u8bd5\u4e00\u4e0bservice iptables stop.<\/p>\n

      \u672c\u6587\u57fa\u4e8e64\u4f4d\u7684CentOS 5 VPS\uff0c\u5982\u679c\u662f32\u4f4d\u7684VPS\uff0c\u8bf7\u5728\u76f8\u5e94\u90e8\u5206\u505a\u4fee\u6539\u3002<\/p>\n

        \u672c\u89e3\u51b3\u65b9\u6848\u4f7f\u7528\u745e\u8c6a\u5f00\u6e90\u81ea\u5df1\u7f16\u8bd1\u7684\u6700\u65b0\u7a33\u5b9a\u7248\u672c\u7684Nginx\uff0cfastcgi\u8fdb\u7a0b\u7ba1\u7406\u4f7f\u7528spawn-fcgi\uff0c\u8fd8\u6709CentOS 5\u81ea\u5e26\u76845.0.45\u7248\u672c\u7684MySQL\u548c5.1.6\u7248\u672c\u7684php\u3002
\u4f18\u7f3a\u70b9<\/p>\n

       \u672c\u65b9\u6848\u7684\u4f18\u70b9\u662f\u4f7f\u7528CentOS5\u81ea\u5e26\u7684php\u548cmysql\uff0c\u6269\u5c55\u6027\u597d\uff0cphp\u7684\u5404\u79cd\u6269\u5c55yum\u5e93\u91cc\u9762\u90fd\u6709\uff0c\u90fd\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\uff1b\u53e6\u5916\uff0c\u7531\u4e8e\u4f7f\u7528\u7cfb\u7edf\u81ea\u5e26\u7684php\u548cmysql\uff0c\u5b89\u5168\u6027\u8981\u597d\u4e00\u4e9b\uff0c\u5982\u679c\u6709\u4ec0\u4e48\u6f0f\u6d1e\u90fd\u53ef\u4ee5\u76f4\u63a5\u5347\u7ea7\u4e3acentos\u5b98\u65b9\u7684\u6700\u65b0\u7248\u672c\u3002\u7531\u4e8e\u4f7f\u7528spawn-fcgi\uff0c\u6240\u4ee5\u65e0\u987b\u91cd\u65b0\u7f16\u8bd1php\u3002<\/p>\n

\u672c\u65b9\u6848\u7684\u7f3a\u70b9\u6709\uff1a<\/strong>
       php\u548cmysql\u90fd\u662fcentos\u81ea\u5e26\u7684\u7248\u672c\uff0c\u4e0d\u662f\u6700\u65b0\u7248\u672c\uff0c\u4e07\u4e00\u7528\u5230php\u6700\u65b0\u7248\u672c\u7684\u67d0\u4e9b\u7279\u6027\u5219\u5c31\u4e0d\u884c\u4e86\u3002
spawn-fcgi\u7684\u6027\u80fd\u4e0d\u5982php-fpm\uff0c\u5982\u679c\u60f3\u7528php-fpm\uff0c\u8bf7\u53c2\u8003 http:\/\/rashost.com\/blog\/centos5-vps-nginx-solution2<\/a><\/p>\n

\u5b89\u88c5Nginx<\/strong><\/p>\n

\u5230 http:\/\/rashost.com\/download<\/a> \u4e0b\u8f7dnginx-0.7.61-1.x86_64.rpm<\/p>\n

\u5b89\u88c5\u547d\u4ee4\uff1a<\/strong><\/p>\n

rpm -ivh nginx-0.7.61-1.x86_64.rpm
chkconfig –list nginx
chkconfig nginx on
\/etc\/init.d\/nginx start
rpm -ql nginx<\/p>\n

\u4e0a\u9762\u7684rpm -ql nginx\u547d\u4ee4\u662f\u770b\u770bnginx\u7684\u6587\u4ef6\u90fd\u5b89\u88c5\u5728\u54ea\u4e9b\u76ee\u5f55\u4e0b\u9762\u4e86\uff0c\u53ef\u4ee5\u770b\u5230nginx\u7684\u7f3a\u7701\u7f51\u9875\u76ee\u5f55\u5e94\u8be5\u662f\/usr\/share\/nginx\/html\/<\/p>\n

\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\uff0c\u5e94\u8be5\u80fd\u770b\u5230nginx\u7684\u7f3a\u7701\u7f51\u9875\u4e86\uff0c\u8bf4\u660enginx\u6b63\u5e38\u5de5\u4f5c\u4e86\uff01<\/p>\n

\u5b89\u88c5MySQL<\/strong><\/p>\n

yum install -y mysql-server
chkconfig –list mysqld
chkconfig mysqld on
\/etc\/init.d\/mysqld start<\/p>\n

\u8fd0\u884cmysql -uroot\u547d\u4ee4\uff0c\u5e94\u8be5\u53ef\u4ee5\u6b63\u5e38\u8fde\u63a5\u5230MySQL<\/p>\n

\u5b89\u88c5PHP<\/strong><\/p>\n

yum install -y php-cgi php-mysql
\u5b89\u88c5spawn-fcgi<\/p>\n

\u5230http:\/\/rashost.com\/download<\/a> \u4e0b\u8f7d spawn-fcgi-1.6.2-1.32.x86_64.rpm<\/p>\n

rpm -ivh spawn-fcgi-1.6.2-1.32.x86_64.rpm<\/p>\n

\u7136\u540e\u5728\/etc\/rc.local\u91cc\u9762\u52a0\u5165spawn-fcgi\u7684\u542f\u52a8\u547d\u4ee4\uff1a<\/p>\n

spawn-fcgi -C 10 -a 127.0.0.1 -p 9000 -u nginx -d \/tmp -f php-cgi<\/p>\n

\u5176\u4e2d\u7684-C 10\u53c2\u6570\u662f\u6307\u542f\u52a8\u7684php fastcgi\u7684\u8fdb\u7a0b\u6570\u76ee\uff0c\u8fd9\u4e2a\u6570\u503c\u53ef\u4ee5\u6839\u636e\u7f51\u7ad9\u7684\u8bbf\u95ee\u91cf\u548c\u5185\u5b58\u5927\u5c0f\u4fee\u6539\u3002<\/p>\n

\u7136\u540e\u5148\u624b\u5de5\u542f\u52a8\u4e00\u4e0bphp:<\/p>\n

spawn-fcgi -C 10 -a 127.0.0.1 -p 9000 -u nginx -d \/tmp -f php-cgi
\u6574\u5408<\/p>\n

\u9996\u5148\u5728\/usr\/share\/nginx\/html\u76ee\u5f55\u4e0b\u521b\u5efa\u6587\u4ef6test.php\uff0c\u5176\u5185\u5bb9\u5f88\u7b80\u5355\uff0c\u53ea\u8981\u4e0b\u9762\u4e00\u884c\uff1a<\/p>\n

<?phpinfo();?><\/p>\n

\u5047\u8bbe\u6240\u5728VPS\u7684\u5730\u5740\u662fcentos5.rashost.com\uff0c\u8fd9\u65f6\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95eehttp:\/\/centos5.rashost.com\/test.php<\/a>\u662f\u5f97\u4e0d\u5230\u6b63\u786e\u7684\u663e\u793a\u7ed3\u679c\u7684\u3002<\/p>\n

\u4fee\u6539nginx\u7684\u914d\u7f6e\u6587\u4ef6\/etc\/nginx\/nginx.conf\uff0c\u5728\u6587\u4ef6\u5185\u641c\u7d22fastcgi_pass\uff0c\u4fee\u6539\u8be5\u90e8\u5206\u5185\u5bb9\u4e3a\uff1a<\/p>\n

     location ~ \\.php$ {
           root          html;
           fastcgi_pass  127.0.0.1:9000;
           fastcgi_indexindex.php;
           fastcgi_paramSCRIPT_FILENAME$document_root\/$fastcgi_script_name;
           include       fastcgi_params;
       }<\/p>\n

\u7136\u540e\u91cd\u542fnginx:<\/p>\n

\/etc\/init.d\/nginx\/restart<\/p>\n","protected":false},"excerpt":{"rendered":"

        PS\uff1a\u5982\u679cnginx\u5b89\u88c5\u5b8c\u6bd5\u540e\u770b\u4e0d\u5230\u6d4b\u8bd5\u9875\u9762\uff0c\u8bd5\u4e00\u4e0bservice iptables stop.<\/p>\n

      \u672c\u6587\u57fa\u4e8e64\u4f4d\u7684CentOS 5 VPS\uff0c\u5982\u679c\u662f32\u4f4d\u7684VPS\uff0c\u8bf7\u5728\u76f8\u5e94\u90e8\u5206\u505a\u4fee\u6539\u3002<\/p>\n

        \u672c\u89e3\u51b3\u65b9\u6848\u4f7f\u7528\u745e\u8c6a\u5f00\u6e90\u81ea\u5df1\u7f16\u8bd1\u7684\u6700\u65b0\u7a33\u5b9a\u7248\u672c\u7684Nginx\uff0cfastcgi\u8fdb\u7a0b\u7ba1\u7406\u4f7f\u7528spawn-fcgi\uff0c\u8fd8\u6709CentOS 5\u81ea\u5e26\u76845.0.45\u7248\u672c\u7684MySQL\u548c5.1.6\u7248\u672c\u7684php\u3002
\u4f18\u7f3a\u70b9<\/p>\n

       \u672c\u65b9\u6848\u7684\u4f18\u70b9\u662f\u4f7f\u7528C<\/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\/1003"}],"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=1003"}],"version-history":[{"count":0,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1003\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/media?parent=1003"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/categories?post=1003"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/tags?post=1003"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}