{"id":18525,"date":"2014-10-15T06:37:02","date_gmt":"2014-10-14T22:37:02","guid":{"rendered":"https:\/\/2blog.ilc.edu.tw\/25793\/2014\/10\/15\/lamobo-m1-%e6%b8%ac%e8%a9%a6-bananian-%e7%af%87-%e5%ae%89%e8%a3%9d-nginx-mysql-php-server\/"},"modified":"2021-03-18T17:24:07","modified_gmt":"2021-03-18T09:24:07","slug":"lamobo-m1-%e6%b8%ac%e8%a9%a6-bananian-%e7%af%87-%e5%ae%89%e8%a3%9d-nginx-mysql-php-server","status":"publish","type":"post","link":"https:\/\/2blog.ilc.edu.tw\/25793\/2014\/10\/15\/lamobo-m1-%e6%b8%ac%e8%a9%a6-bananian-%e7%af%87-%e5%ae%89%e8%a3%9d-nginx-mysql-php-server\/","title":{"rendered":"Lamobo M1 \u6e2c\u8a66 &#8211; Bananian \u7bc7 \u5b89\u88dd Nginx \/ MySQL \/ PHP Server"},"content":{"rendered":"<p>\u5b89\u88dd Nginx Web Server<br \/># <span style=\"color: #ff0000\">apt-get install nginx<\/span><\/p>\n<p>\u4e0d\u904e\u5b89\u88dd\u7684\u7248\u672c\u6709\u4e9b\u820a<br \/># <span style=\"color: #ff0000\">nginx -v<\/span><br \/><span style=\"color: #0000ff\">nginx version: nginx\/1.2.1<\/span><\/p>\n<p>\u79fb\u9664 nginx\u00a0\u5957\u4ef6<br \/># <span style=\"color: #ff0000\">apt-get remove &#8211;purge libfreetype6 libgd2-noxpm libgeoip1 libjpeg8 libpcre3 libpng12-0 libxml2 libxslt1.1 nginx-common nginx-full nginx<\/span><\/p>\n<p>\u6240\u4ee5\u6539\u7528 Source Code\u00a0\u7684\u65b9\u5f0f\u4f86\u5b89\u88dd[@more@]\u5e95\u4e0b\u6587\u7ae0\u53c3\u8003 <a href=\"http:\/\/ithelp.ithome.com.tw\/question\/10137466\" target=\"_blank\" rel=\"noopener noreferrer\">Linux Pi\u7684\u5947\u5e7b\u65c5\u7a0b(22)-\u7de8\u8b6fNginx &#8211; iT\u90a6\u5e6b\u5fd9::IT\u77e5\u8b58\u5206\u4eab\u793e\u7fa4<\/a><\/p>\n<p>\u5b89\u88dd\u7de8\u8b6f\u6642\u6240\u9700\u5957\u4ef6<br \/># <span style=\"color: #ff0000\">apt-get install build-essential<\/span><\/p>\n<p>Nginx\u00a0\u5b98\u65b9\u7db2\u7ad9\uff1a<a href=\"http:\/\/nginx.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/nginx.org\/<\/a><\/p>\n<p>\u4e0b\u8f09 Source Code<br \/># <span style=\"color: #ff0000\">wget http:\/\/nginx.org\/download\/nginx-1.6.2.tar.gz<\/span><\/p>\n<p>\u89e3\u58d3\u7e2e<br \/># <span style=\"color: #ff0000\">tar xvzf nginx-1.6.2.tar.gz<\/span><\/p>\n<p>\u5207\u63db\u76ee\u9304<br \/># <span style=\"color: #ff0000\">cd nginx-1.6.2<\/span><\/p>\n<p>\u5b89\u88dd\u7de8\u8b6f nginx\u00a0\u6240\u9700\u5957\u4ef6<br \/># <span style=\"color: #ff0000\">apt-get install libpcre3* libssl-dev<\/span><\/p>\n<p>\u9032\u884c\u7de8\u8b6f<br \/># <span style=\"color: #ff0000\">.\/configure &#8211;prefix=\/usr &#8211;sbin-path=\/usr\/sbin\/nginx &#8211;conf-path=\/etc\/nginx\/nginx.conf &#8211;pid-path=\/var\/run\/nginx.pid &#8211;lock-path=\/var\/lock\/nginx.lock &#8211;user=www-data &#8211;group=www-data &#8211;http-log-path=\/var\/log\/nginx\/access.log &#8211;error-log-path=\/var\/log\/nginx\/error.log &#8211;http-client-body-temp-path=\/var\/lib\/nginx\/body &#8211;http-proxy-temp-path=\/var\/lib\/nginx\/proxy &#8211;http-fastcgi-temp-path=\/var\/lib\/nginx\/proxy &#8211;http-uwsgi-temp-path=\/var\/lib\/nginx\/uwsgi &#8211;http-scgi-temp-path=\/var\/lib\/nginx\/scgi &#8211;with-http_ssl_module &#8211;with-http_stub_status_module &#8211;with-debug<\/span><\/p>\n<p>\u9032\u884c\u5b89\u88dd<br \/># <span style=\"color: #ff0000\">make;make install<\/span><\/p>\n<p>\u57f7\u884c\u6642\u51fa\u73fe\u932f\u8aa4<br \/># <span style=\"color: #ff0000\">\/usr\/sbin\/nginx<\/span><br \/><span style=\"color: #0000ff\">nginx: [emerg] mkdir() &#8220;\/var\/lib\/nginx\/body&#8221; failed (2: No such file or directory)<\/span><\/p>\n<p>\u5efa\u7acb\u76ee\u9304<br \/># <span style=\"color: #ff0000\">mkdir -p \/var\/lib\/nginx\/body<\/span><\/p>\n<p>\u6aa2\u67e5\u662f\u5426\u6709\u57f7\u884c\u6210\u529f<br \/># <span style=\"color: #ff0000\">netstat -ant | grep :80<\/span><br \/><span style=\"color: #0000ff\">tcp\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0 0 0.0.0.0:80\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0:*\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 LISTEN<\/span><\/p>\n<p>\u5b89\u88dd\u7684 nginx\u00a0\u7248\u672c<br \/># <span style=\"color: #ff0000\">nginx -v<\/span><br \/><span style=\"color: #0000ff\">nginx version: nginx\/1.6.2<\/span><\/p>\n<p>\u4f7f\u7528\u700f\u89bd\u5668\u6aa2\u67e5<br \/><a id=\"res_2675030\" href=\"https:\/\/2blog.ilc.edu.tw\/wp-content\/uploads\/sites\/985\/25793\/25793-2675030.png\"><img decoding=\"async\" src=\"https:\/\/2blog.ilc.edu.tw\/wp-content\/uploads\/sites\/985\/25793\/previews-med\/25793-2675030.png\" border=\"0\" alt=\"\" \/><\/a><\/p>\n<p>\u5b89\u88dd MySQL Server<br \/># <span style=\"color: #ff0000\">apt-get install mysql-server mysql-client<\/span><\/p>\n<p>MySQL Server\u00a0\u5b89\u88dd\u5f8c\u8a2d\u5b9a<br \/># <span style=\"color: #ff0000\">\/usr\/bin\/mysql_secure_installation<\/span><\/p>\n<p>\u5b89\u88dd PHP<br \/># <span style=\"color: #ff0000\">apt-get install php5-fpm php5-mysql php5-gd php-apc php5<\/span><\/p>\n<p>PHP\u00a0\u7248\u672c<br \/># <span style=\"color: #ff0000\">php5-fpm -v<\/span><br \/><span style=\"color: #0000ff\">PHP 5.4.4-14+deb7u14 (fpm-fcgi) (built: Aug 21 2014 10:32:42)<\/span><br \/><span style=\"color: #0000ff\">Copyright (c) 1997-2009 The PHP Group<\/span><br \/><span style=\"color: #0000ff\">Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies<\/span><\/p>\n<p>\u5efa\u7acb\u7db2\u7ad9\u6839\u76ee\u9304<br \/># <span style=\"color: #ff0000\">mkdir \/var\/www<\/span><\/p>\n<p>\u6539\u8b8a\u76ee\u9304\u64c1\u6709\u8005\u53ca\u7fa4\u7d44<br \/># <span style=\"color: #ff0000\">chown -R www-data:www-data \/var\/www<\/span><\/p>\n<p>\u67e5\u770b php5-fpm\u00a0\u57f7\u884c\u6642\u7522\u751f\u7684 socket\u00a0\u6a94<br \/># <span style=\"color: #ff0000\">ls -ls \/var\/run\/php5-fpm.sock<\/span><br \/><span style=\"color: #0000ff\">0 srw-rw&#8212;- 1 www-data www-data 0 Sep 27 16:20 \/var\/run\/php5-fpm.sock<\/span><\/p>\n<p>\u4fee\u6539 nginx Web Server\u00a0\u8a2d\u5b9a\u6a94<br \/># <span style=\"color: #ff0000\">vim \/etc\/nginx\/nginx.conf<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0 server {<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 listen\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 80;<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 server_name\u00a0 localhost;<\/span><\/p>\n<p><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #charset koi8-r;<\/span><\/p>\n<p><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #access_log\u00a0 logs\/host.access.log\u00a0 main;<\/span><\/p>\n<p><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 location \/ {<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0 \/var\/www;<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 index\u00a0 index.php index.html index.htm;<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #error_page\u00a0 404\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/404.html;<\/span><\/p>\n<p><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # redirect server error pages to the static page \/50x.html<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 error_page\u00a0\u00a0 500 502 503 504\u00a0 \/50x.html;<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 location = \/50x.html {<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0 html;<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # proxy the PHP scripts to Apache listening on 127.0.0.1:80<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #location ~ .php$ {<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u00a0\u00a0\u00a0 proxy_pass\u00a0\u00a0 http:\/\/127.0.0.1;<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #}<\/span><\/p>\n<p><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 location ~ .php$ {<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/var\/www;<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u00a0\u00a0\u00a0 fastcgi_pass\u00a0\u00a0 127.0.0.1:9000;<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 try_files $uri =404;<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fastcgi_split_path_info ^(.+.php)(\/.+)$;<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fastcgi_pass unix:\/var\/run\/php5-fpm.sock;<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fastcgi_index\u00a0 index.php;<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fastcgi_param\u00a0 SCRIPT_FILENAME $document_root$fastcgi_script_name;<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 include\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fastcgi_params;<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # deny access to .htaccess files, if Apache&#8217;s document root<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # concurs with nginx&#8217;s one<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 location ~ \/.ht {<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 deny\u00a0 all;<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/span><br \/><span style=\"color: #0000ff\">\u00a0\u00a0\u00a0 }<\/span><\/p>\n<p>\u6aa2\u67e5\u8a2d\u5b9a\u6a94\u662f\u5426\u6b63\u78ba<br \/># <span style=\"color: #ff0000\">\/usr\/sbin\/nginx -t<\/span><br \/><span style=\"color: #0000ff\">nginx: the configuration file \/etc\/nginx\/nginx.conf syntax is ok<\/span><br \/><span style=\"color: #0000ff\">nginx: configuration file \/etc\/nginx\/nginx.conf test is successful<\/span><\/p>\n<p>\u95dc\u9589 nginx web Server<br \/># <span style=\"color: #ff0000\">kill -9 $(ps aux | grep nginx | grep -v grep | awk &#8216;{print $2}&#8217;)<\/span><br \/>or<br \/># <span style=\"color: #ff0000\">killall nginx<\/span><\/p>\n<p>\u91cd\u65b0\u57f7\u884c<br \/># <span style=\"color: #ff0000\">\/usr\/sbin\/nginx<\/span><\/p>\n<p>\u57f7\u884c php5-fpm<br \/># <span style=\"color: #ff0000\">\/etc\/init.d\/php5-fpm start<\/span><\/p>\n<p>\u6aa2\u67e5 php\u00a0\u662f\u5426\u80fd\u6b63\u5e38\u57f7\u884c<br \/># <span style=\"color: #ff0000\">vim \/var\/www\/index.php<\/span><br \/><span style=\"color: #0000ff\">&lt;?php<\/span><br \/><span style=\"color: #0000ff\">phpinfo();<\/span><br \/><span style=\"color: #0000ff\">?&gt;<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88dd Nginx Web Server# apt-get install nginx \u4e0d\u904e\u5b89\u88dd\u7684\u7248\u672c\u6709\u4e9b\u820a# &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/2blog.ilc.edu.tw\/25793\/2014\/10\/15\/lamobo-m1-%e6%b8%ac%e8%a9%a6-bananian-%e7%af%87-%e5%ae%89%e8%a3%9d-nginx-mysql-php-server\/\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008Lamobo M1 \u6e2c\u8a66 &#8211; Bananian \u7bc7 \u5b89\u88dd Nginx \/ MySQL \/ PHP Server\u3009<\/span><\/a><\/p>\n","protected":false},"author":55,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[162,137],"tags":[],"class_list":["post-18525","post","type-post","status-publish","format-standard","hentry","category-c-83744","category-c-78482"],"meta_key":{"_pingme":["1"],"_encloseme":["1"],"lt_post_id":["519947"]},"_links":{"self":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts\/18525"}],"collection":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/users\/55"}],"replies":[{"embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/comments?post=18525"}],"version-history":[{"count":1,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts\/18525\/revisions"}],"predecessor-version":[{"id":20158,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts\/18525\/revisions\/20158"}],"wp:attachment":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/media?parent=18525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/categories?post=18525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/tags?post=18525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}