{"id":281,"date":"2017-11-23T09:37:45","date_gmt":"2017-11-23T09:37:45","guid":{"rendered":"http:\/\/www.sunyuping.cn\/?p=281"},"modified":"2017-11-23T09:37:45","modified_gmt":"2017-11-23T09:37:45","slug":"centos_6-5%e5%ae%89%e8%a3%85nginxphpmysql","status":"publish","type":"post","link":"https:\/\/www.sunyuping.com\/index.php\/2017\/11\/23\/centos_6-5%e5%ae%89%e8%a3%85nginxphpmysql\/","title":{"rendered":"CentOS_6.5\u5b89\u88c5Nginx+PHP+MySQL"},"content":{"rendered":"<p>\t\t\t\tyum\u5b89\u88c5\u57fa\u672c\u5e93<br \/>\nyum -y install automake autoconf libtool make gcc gcc-c++ libmcrypt-devel mhash-devel libxslt-devel 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 e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel<br \/>\n\u4e00\uff1aNginx\u5b89\u88c5<br \/>\ncd \/data\/soft\/src<br \/>\n1.\u5b89\u88c5PCRE\u5e93<br \/>\nftp:\/\/ftp.csx.cam.ac.uk\/pub\/software\/programming\/pcre\/ \u4e0b\u8f7d\u6700\u65b0\u7684 PCRE \u6e90\u7801\u5305\uff0c\u4f7f\u7528\u4e0b\u9762\u547d\u4ee4\u4e0b\u8f7d\u7f16\u8bd1\u548c\u5b89\u88c5 PCRE \u5305\uff1a<\/p>\n<p>cd \/data\/soft\/src<br \/>\nwget ftp:\/\/ftp.csx.cam.ac.uk\/pub\/software\/programming\/pcre\/pcre-8.40.tar.gz<br \/>\ntar -zxvf pcre-8.40.tar.gz<br \/>\ncd pcre-8.40<br \/>\n.\/configure<br \/>\nmake &#038;&#038; make install<br \/>\n2.\u5b89\u88c5zlib\u5e93<br \/>\nhttp:\/\/zlib.net\/zlib-1.2.11.tar.gz \u4e0b\u8f7d\u6700\u65b0\u7684 zlib \u6e90\u7801\u5305\uff0c\u4f7f\u7528\u4e0b\u9762\u547d\u4ee4\u4e0b\u8f7d\u7f16\u8bd1\u548c\u5b89\u88c5 zlib\u5305\uff1a<\/p>\n<p>cd \/data\/soft\/src<br \/>\nwget http:\/\/zlib.net\/zlib-1.2.11.tar.gz<br \/>\ntar -zxvf zlib-1.2.11.tar.gz<br \/>\ncd zlib-1.2.11<br \/>\n.\/configure<br \/>\nmake &#038;&#038; make install<br \/>\n3.\u5b89\u88c5ssl\uff08\u67d0\u4e9bvps\u9ed8\u8ba4\u6ca1\u88c5ssl)<br \/>\ncd \/data\/soft\/src<br \/>\nwget http:\/\/www.openssl.org\/source\/openssl-1.0.2.tar.gz<br \/>\ntar -zxvf openssl-1.0.2.tar.gz<br \/>\ncd openssl-1.0.2<br \/>\n.\/config<br \/>\nmake &#038;&#038; make install<br \/>\ncp apps\/openssl \/usr\/bin\/\u5982\u679c\u63d0\u793a\u8986\u76d6\uff0c\u786e\u8ba4\u5c31OK\u4e86\uff0c\u518d\u67e5\u770bopenssl version\u7248\u672c\u5c31\u662f\u6700\u65b0\u7248\u4e86<br \/>\n4.\u5b89\u88c5nginx<br \/>\nNginx \u4e00\u822c\u6709\u4e24\u4e2a\u7248\u672c\uff0c\u5206\u522b\u662f\u7a33\u5b9a\u7248\u548c\u5f00\u53d1\u7248\uff0c\u60a8\u53ef\u4ee5\u6839\u636e\u60a8\u7684\u76ee\u7684\u6765\u9009\u62e9\u8fd9\u4e24\u4e2a\u7248\u672c\u7684\u5176\u4e2d\u4e00\u4e2a\uff0c\u4e0b\u9762\u662f\u628a Nginx \u5b89\u88c5\u5230 \/data\/soft\/nginx \u76ee\u5f55\u4e0b\u7684\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n<p>cd \/data\/soft\/src<br \/>\nwget http:\/\/nginx.org\/download\/nginx-1.6.2.tar.gz<br \/>\ntar -zxvf nginx-1.6.2.tar.gz<br \/>\ncd nginx-1.6.2<br \/>\n.\/configure &#8211;sbin-path=\/data\/soft\/nginx\/nginx \\&#8211;conf-path=\/data\/soft\/nginx\/nginx.conf \\&#8211;pid-path=\/data\/soft\/nginx\/nginx.pid \\&#8211;with-http_ssl_module \\&#8211;with-pcre=\/data\/soft\/src\/pcre-8.40 \\&#8211;with-zlib=\/data\/soft\/src\/zlib-1.2.11<br \/>\nmake &#038;&#038; make install<\/p>\n<p>cp \/data\/soft\/nginx\/nginx \/etc\/init.d\/<br \/>\n\/etc\/init.d\/nginx \t\t\t\u542f\u52a8nginx<br \/>\n\/etc\/init.d\/nginx -s reload\t\t\u91cd\u542fnginx<br \/>\n\/etc\/init.d\/nginx -s stop\t\t\u5173\u95ednginx<br \/>\n\u6dfb\u52a0nginx\u5f00\u673a\u542f\u52a8<br \/>\necho &#8220;\/etc\/init.d\/nginx&#8221; >> \/etc\/rc.local<br \/>\n\u4e8c\uff1a\u7f16\u8bd1\u5b89\u88c5php-fpm<br \/>\nPHP-FPM\u662f\u4e00\u4e2aPHP FastCGI\u7ba1\u7406\u5668\uff0c\u662f\u53ea\u7528\u4e8ePHP\u7684,\u53ef\u4ee5\u5728 http:\/\/php-fpm.org\/download\u4e0b\u8f7d\u5f97\u5230.<br \/>\nPHP-FPM\u5176\u5b9e\u662fPHP\u6e90\u4ee3\u7801\u7684\u4e00\u4e2a\u8865\u4e01\uff0c\u65e8\u5728\u5c06FastCGI\u8fdb\u7a0b\u7ba1\u7406\u6574\u5408\u8fdbPHP\u5305\u4e2d\u3002\u5fc5\u987b\u5c06\u5b83patch\u5230\u4f60\u7684PHP\u6e90\u4ee3\u7801\u4e2d\uff0c\u5728\u7f16\u8bd1\u5b89\u88c5PHP\u540e\u624d\u53ef\u4ee5\u4f7f\u7528\u3002<br \/>\n\u65b0\u7248PHP\u5df2\u7ecf\u96c6\u6210php-fpm\u4e86\uff0c\u4e0d\u518d\u662f\u7b2c\u4e09\u65b9\u7684\u5305\u4e86\uff0c\u63a8\u8350\u4f7f\u7528\u3002PHP-FPM\u63d0\u4f9b\u4e86\u66f4\u597d\u7684PHP\u8fdb\u7a0b\u7ba1\u7406\u65b9\u5f0f\uff0c\u53ef\u4ee5\u6709\u6548\u63a7\u5236\u5185\u5b58\u548c\u8fdb\u7a0b\u3001\u53ef\u4ee5\u5e73\u6ed1\u91cd\u8f7dPHP\u914d\u7f6e\uff0c\u6bd4spawn-fcgi\u5177\u6709\u66f4\u591a\u4f18\u70b9\uff0c\u6240\u4ee5\u88abPHP\u5b98\u65b9\u6536\u5f55\u4e86\u3002\u5728.\/configure\u7684\u65f6\u5019\u5e26 \u2013enable-fpm\u53c2\u6570\u5373\u53ef\u5f00\u542fPHP-FPM\uff0c\u5176\u5b83\u53c2\u6570\u90fd\u662f\u914d\u7f6ephp\u7684\uff0c\u5177\u4f53\u9009\u9879\u542b\u4e49\u53ef\u4ee5\u5230\u8fd9\u91cc\u67e5\u770b\uff1ahttp:\/\/www.php.net\/manual\/en\/configure.about.php\u3002<br \/>\n1.php-fpm\u5b89\u88c5(\u63a8\u8350\u5b89\u88c5\u65b9\u5f0f)<br \/>\ncd \/data\/soft\/src<br \/>\nwget http:\/\/museum.php.net\/php5\/php-5.4.7.tar.gz<br \/>\ntar zvxf php-5.4.7.tar.gz<br \/>\ncd php-5.4.7<br \/>\n.\/configure &#8211;prefix=\/data\/soft\/php &#8211;enable-fpm &#8211;with-mcrypt \\&#8211;enable-mbstring &#8211;disable-pdo &#8211;with-curl &#8211;disable-debug  &#8211;disable-rpath \\&#8211;enable-inline-optimization &#8211;with-bz2  &#8211;with-zlib &#8211;enable-sockets \\&#8211;enable-sysvsem &#8211;enable-sysvshm &#8211;enable-pcntl &#8211;enable-mbregex \\&#8211;with-mhash &#8211;enable-zip &#8211;with-pcre-regex &#8211;with-mysql &#8211;with-mysqli \\&#8211;with-gd &#8211;with-jpeg-dir &#8211;enable-pdo &#8211;enable-ftp &#8211;with-pdo_sqlite &#8211;with-openssl=\/usr\/local\/ssl\/ &#8211;with-pdo_mysql<br \/>\nmake &#038;&#038; make install<br \/>\n2.\u4ee5\u4e0a\u5c31\u5b8c\u6210\u4e86php-fpm\u7684\u5b89\u88c5\u3001\u4e0b\u9762\u662f\u5bf9php-fpm\u8fd0\u884c\u7528\u6237\u8fdb\u884c\u8bbe\u7f6e<br \/>\ncd \/data\/soft\/php<br \/>\ncp etc\/php-fpm.conf.default etc\/php-fpm.conf<\/p>\n<p>vi etc\/php-fpm.conf \u4fee\u6539<br \/>\nuser = www<br \/>\ngroup = www<\/p>\n<p>\u5982\u679cwww\u7528\u6237\u4e0d\u5b58\u5728\uff0c\u90a3\u4e48\u5148\u6dfb\u52a0www\u7528\u6237<br \/>\n  groupadd www<br \/>\n  useradd -g www www<\/p>\n<p>\u53bb\u6389\u524d\u9762\u7684\u6ce8\u91ca<br \/>\n  pid = run\/php-fpm.pid<br \/>\n3.\u4fee\u6539nginx\u914d\u7f6e\u6587\u4ef6\u4ee5\u652f\u6301php-fpm<br \/>\n\u4fee\u6539nginx\u914d\u7f6e\u6587\u4ef6\u4e3a,nginx.conf<br \/>\n\u5176\u4e2dserver\u6bb5\u589e\u52a0\u5982\u4e0b\u914d\u7f6e<br \/>\n# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000<br \/>\n  location ~ \\.php$ {<br \/>\n  root \/data\/www; #\u9879\u76ee\u6839\u76ee\u5f55<br \/>\n  fastcgi_pass 127.0.0.1:9000;<br \/>\n  fastcgi_index index.php;<br \/>\n  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br \/>\n  include fastcgi_params;<br \/>\n}<\/p>\n<p>\u91cd\u542fnginx\u670d\u52a1\u5668<br \/>\n  \/data\/nginx\/nginx -s reload<br \/>\n4.\u521b\u5efa\u6d4b\u8bd5php\u6587\u4ef6\u3001\u5728\/data\/www\u4e0b\u521b\u5efaindex.php\u6587\u4ef6\uff0c\u8f93\u5165\u5982\u4e0b\u5185\u5bb9<br \/>\n\u5728\/data\/www\u4e0b\u521b\u5efaindex.php\u6587\u4ef6\uff0c\u8f93\u5165\u5982\u4e0b\u5185\u5bb9\uff1a<br \/>\n<?php\n  echo phpinfo();\n?><br \/>\n5.\u542f\u52a8php-fpm\u670d\u52a1<br \/>\n\/data\/soft\/php\/sbin\/php-fpm<br \/>\n5.5\u6740\u6b7bphp-fpm\u8fdb\u7a0b<br \/>\nkillall php-fpm\uff08\u53ef\u4ee5\u914d\u5408\u542f\u52a8\u547d\u4ee4\u5b9e\u73b0\u91cd\u542f\u6548\u679c\uff09<br \/>\n6.php-fpm\u5173\u95ed\u4e0e\u91cd\u542f<br \/>\nphp-fpm \u5173\u95ed<br \/>\n  kill -INT `cat \/data\/soft\/php\/var\/run\/php-fpm.pid`<\/p>\n<p>php-fpm \u91cd\u542f<br \/>\n  kill -USR2 `cat \/data\/soft\/php\/var\/run\/php-fpm.pid`<br \/>\n7.php-fpm\u5f00\u673a\u542f\u52a8<br \/>\necho &#8220;\/data\/soft\/php\/sbin\/php-fpm&#8221; >> \/etc\/rc.local<br \/>\n8.\u89e3\u51b3php-fpm.pid\u6587\u4ef6\u4e0d\u5b58\u5728(\u91cd\u542fphp-fpm)<br \/>\nvim \/data\/soft\/php\/etc\/php-fpm.conf<br \/>\n  \u6253\u5f00 pid = run\/php-fpm.pid<br \/>\n\u4e09\uff1amysql\u5b89\u88c5<br \/>\ncd \/data\/soft\/src<br \/>\nwget http:\/\/downloads.mysql.com\/archives\/mysql-5.1\/mysql-5.1.70.tar.gz<br \/>\ntar -zxvf mysql-5.1.70.tar.gz<br \/>\ncd mysql-5.1.70<\/p>\n<p>yum install ncurses ncurses-devel<br \/>\n.\/configure  &#8216;&#8211;prefix=\/data\/soft\/mysql&#8217; &#8216;&#8211;without-debug&#8217; &#8216;&#8211;with-charset=utf8&#8217; &#8216;&#8211;with-extra-charsets=all&#8217; &#8216;&#8211;enable-assembler&#8217; &#8216;&#8211;with-pthread&#8217; &#8216;&#8211;enable-thread-safe-client&#8217; &#8216;&#8211;with-mysqld-ldflags=-all-static&#8217; &#8216;&#8211;with-client-ldflags=-all-static&#8217; &#8216;&#8211;with-big-tables&#8217; &#8216;&#8211;with-readline&#8217; &#8216;&#8211;with-ssl&#8217; &#8216;&#8211;with-embedded-server&#8217; &#8216;&#8211;enable-local-infile&#8217; &#8216;&#8211;with-plugins=innobase&#8217;\tmake<br \/>\nmake install<br \/>\n\u5230\u6b64mysql\u5c31\u5b89\u88c5\u5230\u4e86\/data\/soft\/mysql\u8def\u5f84\u4e0b\uff0c\u4e0b\u9762\u5f00\u59cbmysql\u7684\u914d\u7f6e\u5de5\u4f5c<br \/>\n\u914d\u7f6e\u6587\u4ef6<br \/>\ncp support-files\/my-medium.cnf \/etc\/my.cnf<br \/>\nmysql\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\u52a8<br \/>\ncp -r support-files\/mysql.server \/etc\/init.d\/mysqld<br \/>\n\/sbin\/chkconfig &#8211;del mysqld<br \/>\n\/sbin\/chkconfig &#8211;add mysqld<br \/>\n\u914d\u7f6e\u6743\u9650\u8868<br \/>\nchown -R mysql:mysql \/data\/soft\/mysql<br \/>\n\/data\/soft\/mysql\/bin\/mysql_install_db &#8211;user=mysql<br \/>\n\u542f\u52a8mysql<br \/>\n\/etc\/init.d\/mysqld start<br \/>\nmysql\u521d\u59cb\u5316\u914d\u7f6e<br \/>\nexport PATH=\/data\/soft\/mysql\/bin:$PATH<br \/>\n\/data\/soft\/mysql\/bin\/mysql_secure_installation<br \/>\n\u6ce8\uff1a\u8fd9\u91cc\u6839\u636e\u63d0\u793a\u8bbe\u7f6emysql\u7684root\u5bc6\u7801<br \/>\n\u5230\u8fd9\u91ccmysql\u5b89\u88c5\u5b8c\u6210\u4e86\uff0c \u6211\u4eec\u5f00\u59cb\u4f7f\u7528\u5ba2\u6237\u7aef\u8fde\u63a5mysql<br \/>\n\u5982\u679c\u62a5\u9519\uff1a<br \/>\n  SQL Error (1130): Host &#8216;192.168.1.100&#8217; is not allowed to connect to this MySQL server<\/p>\n<p>\u9996\u5148\u6309\u4e0b\u9762\u7684\u6b65\u9aa4\u767b\u5f55Mysql\u670d\u52a1\u5668<\/p>\n<p>\u767b\u5f55mysql\u9700\u8981\u5207\u6362\u5230dos\u4e0b\u7684mysql\u7684bin\u76ee\u5f55\uff0c\u8fdb\u884c\u5982\u4e0b\u64cd\u4f5c\uff1a<\/p>\n<p>#mysql -uroot -ppassword<br \/>\nmysql>use mysql;<\/p>\n<p>mysql>update user set host = &#8216;%&#8217;  where user =&#8217;root&#8217;;<\/p>\n<p>mysql>flush privileges;<\/p>\n<p>mysql>select &#8216;host&#8217;,&#8217;user&#8217; from user where user=&#8217;root&#8217;;<\/p>\n<p>mysql>quit<br \/>\nOK\u3002\u8fdc\u7a0b\u8fde\u63a5\u6210\u529f\uff01\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>yum\u5b89\u88c5\u57fa\u672c\u5e93 yum -y install automake autoconf libtool make  &#8230; <a title=\"CentOS_6.5\u5b89\u88c5Nginx+PHP+MySQL\" class=\"read-more\" href=\"https:\/\/www.sunyuping.com\/index.php\/2017\/11\/23\/centos_6-5%e5%ae%89%e8%a3%85nginxphpmysql\/\" aria-label=\"\u9605\u8bfb CentOS_6.5\u5b89\u88c5Nginx+PHP+MySQL\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-281","post","type-post","status-publish","format-standard","hentry","category-7"],"_links":{"self":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/posts\/281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/comments?post=281"}],"version-history":[{"count":0,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/posts\/281\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/media?parent=281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/categories?post=281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/tags?post=281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}