{"id":1825,"date":"2018-05-15T10:39:30","date_gmt":"2018-05-15T01:39:30","guid":{"rendered":"https:\/\/lovelinux.mydns.jp\/?p=1825"},"modified":"2018-05-17T01:06:25","modified_gmt":"2018-05-16T16:06:25","slug":"ubuntu-18-04-%e3%81%ab-nginx-mysql-php-phpmyadmin%e7%92%b0%e5%a2%83%e3%82%92%e6%95%b4%e3%81%88%e3%82%8b","status":"publish","type":"post","link":"https:\/\/lovelinux.mydns.jp\/?p=1825","title":{"rendered":"Ubuntu 18.04 \u306b nginx mysql php phpmyadmin\u74b0\u5883\u3092\u6574\u3048\u308b"},"content":{"rendered":"<p>Ubuntu 18.04\u306bnginx mysql php phpmyadmin\u306e\u74b0\u5883\u3092\u6574\u3048\u307e\u3059\u3002<br \/>\nmysql\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u8a2d\u5b9a\u306b\u82e5\u5e72\u82e6\u52b4\u3057\u307e\u3057\u305f\u306e\u3067\u305d\u306e\u6642\u306e\u30e1\u30e2\u3067\u3059\u3002<\/p>\n<h3>nginx\u3001mysql\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>[bash]<br \/>\n$ sudo apt-get install nginx mysql-server<br \/>\n[\/bash]<\/p>\n<h3>nginx\u306e\u8d77\u52d5\u78ba\u8a8d<\/h3>\n<p>[bash]<br \/>\n$ sudo systemctl start nginx<br \/>\n[\/bash]<\/p>\n<p>\u30d6\u30e9\u30a6\u30b6\u30fc\u3067 http:\/\/localhost\u3000\u3068\u3057\u3066nginx\u306e\u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h3>php\u3001php-fpm\u306a\u3069\u306a\u3069\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>[bash]<br \/>\n$ sudo apt-get install php php-fpm php-mysql php-gettext php-common php-mbstring php-mbstring<br \/>\n[\/bash]<\/p>\n<p>\u3053\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u3067nginx\u306eindex.html \u304capache\u30e9\u30a4\u30af\u306a\u3082\u306e\u306b\u66f8\u304d\u63db\u3048\u3089\u308c\u308b\u3063\u307d\u3044\u304c\u3001\u6c17\u306b\u3057\u306a\u3044\uff08\u7b11\uff09<\/p>\n<h3>php.ini\u8abf\u6574<\/h3>\n<p>[bash]<br \/>\n$ sudo nano \/etc\/php\/7.2\/fpm\/php.ini<br \/>\n[\/bash]<\/p>\n<p>\u4ee5\u4e0b\u306e\u90e8\u5206\u3092\u8abf\u6574\u3057\u307e\u3059\u3002<br \/>\n[diff]<br \/>\n+ cgi.fix_pathinfo=0<br \/>\n[\/diff]<\/p>\n<h3>nginx\u3000php\u9023\u643a<\/h3>\n<h4>\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u8abf\u6574<\/h4>\n<p>[bash]<br \/>\n$ sudo nano \/etc\/nginx\/sites-available\/default<br \/>\n[\/bash]<\/p>\n<p>\u4ee5\u4e0b\u3092\u8ffd\u8a18\u3057\u307e\u3059\u3002<\/p>\n<p>[bash]<br \/>\n    location ~ \\.php$ {<br \/>\n        try_files $uri =404;<br \/>\n        fastcgi_pass unix:\/var\/run\/php\/php7.2-fpm.sock;<br \/>\n        fastcgi_index index.php;<br \/>\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br \/>\n        include fastcgi_params;<br \/>\n    }<br \/>\n[\/bash]<\/p>\n<h4>\u30c6\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210<\/h4>\n<p>[bash]<br \/>\n$ sudo nano \/var\/www\/html\/test.php<br \/>\n[\/bash]<\/p>\n<p>\u4ee5\u4e0b\u306e\uff11\u884c\u3092\u8a18\u8ff0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n[bash]<br \/>\n<?php phpinfo(); ?><br \/>\n[\/bash]<\/p>\n<h4>nginx\u518d\u8d77\u52d5<\/h4>\n<p>[bash]<br \/>\n$ sudo systemctl restart nginx<br \/>\n[\/bash]<\/p>\n<h4>\u30d6\u30e9\u30a6\u30b6\u30fc\u3067\u52d5\u4f5c\u78ba\u8a8d<\/h4>\n<p>http:\/\/localhost\/test.php \u3078\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8868\u793a\u304c\u3055\u308c\u308c\u3070OK<br \/>\n<a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2016\/07\/phptest.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2016\/07\/phptest-1024x635.png\" alt=\"phptest\" width=\"620\" height=\"384\" class=\"alignnone size-large wp-image-1208\" srcset=\"https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2016\/07\/phptest-1024x635.png 1024w, https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2016\/07\/phptest-300x186.png 300w, https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2016\/07\/phptest.png 1062w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><\/a><\/p>\n<h3>phpmyadmin\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p><a href=\"https:\/\/www.phpmyadmin.net\/\">https:\/\/www.phpmyadmin.net\/<\/a>\u3088\u308a\u6700\u65b0\u7248\u3092\u5165\u624b\u3002<\/p>\n<h4>\u89e3\u51cd\u3057\u3066 \/usr\/share\u3078\u30b3\u30d4\u30fc<\/h4>\n<p>[bash]<br \/>\n$ unzip phpMyAdmin-4.8.0-all-languages.zip<br \/>\n$ mv phpMyAdmin-4.8.0-all-languages phpmyadmin<br \/>\n$ sudo mv phpmyadmin\/ \/usr\/share\/<br \/>\n[\/bash]<\/p>\n<h4>\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u8abf\u6574<\/h4>\n<p>[bash]<br \/>\n$ sudo nano \/etc\/nginx\/sites-available\/default<br \/>\n[\/bash]<\/p>\n<p>\u4ee5\u4e0b\u3092\u8ffd\u8a18<br \/>\n[bash]<br \/>\n    location \/phpmyadmin {<br \/>\n        root \/usr\/share;<br \/>\n        index index.php;<\/p>\n<p>        location ~ ^\/phpmyadmin.+\\.php$ {<br \/>\n            fastcgi_pass unix:\/var\/run\/php\/php7.2-fpm.sock;<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>    }<br \/>\n[\/bash]<\/p>\n<h4>nginx\u518d\u8d77\u52d5<\/h4>\n<p>[bash]<br \/>\n$ sudo systemctl stop nginx<br \/>\n$ sudo systemctl start nginx<br \/>\n[\/bash]<\/p>\n<h4>\u52d5\u4f5c\u78ba\u8a8d<\/h4>\n<p>http:\/\/localhost\/phpmyadmin \u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8868\u793a\u306b\u306a\u308c\u3070\u6210\u529f<br \/>\n<a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2016\/07\/phptest2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2016\/07\/phptest2.png\" alt=\"phptest2\" width=\"665\" height=\"596\" class=\"alignnone size-full wp-image-1209\" srcset=\"https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2016\/07\/phptest2.png 665w, https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2016\/07\/phptest2-300x268.png 300w\" sizes=\"auto, (max-width: 665px) 100vw, 665px\" \/><\/a><\/p>\n<h4>Mysql root\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u8a2d\u5b9a<\/h4>\n<p>\u4ee5\u524d\u306e\u30c7\u30a3\u30b9\u30c8\u30ea\u30d3\u30e5\u30fc\u30b7\u30e7\u30f3\u3060\u3068 mysql\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6642\u306b\u3001root\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5c0b\u306d\u308b\u30c0\u30a4\u30a2\u30ed\u30b0\u304c\u51fa\u3066\u304d\u3066\u3001\u305d\u3053\u3067root\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u8a2d\u5b9a\u3067\u304d\u305f\u306e\u3067\u3059\u304c\u300118.04\u3067\u306f\u306a\u305c\u304b\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u4ee5\u4e0b\u3067\u8abf\u6574\u3002<\/p>\n<p>[bash]<br \/>\n$ sudo mysql -u root<br \/>\nmysql> USE mysql<br \/>\nmysql> UPDATE user SET plugin=&#8217;mysql_native_password&#8217; WHERE User=&#8217;root&#8217;;<br \/>\nmysql> FLUSH PRIVILEGES;<br \/>\nmysql> exit;<\/p>\n<p>[\/bash]<\/p>\n<p>[bash]<br \/>\n$ mysql -u root<br \/>\nmysql> SET PASSWORD FOR root@&#8217;localhost&#8217; = PASSWORD(&#8216;xxxxxxxx&#8217;);<br \/>\nmysql> exit;<\/p>\n<p>[\/bash]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ubuntu 18.04\u306bnginx mysql php phpmyadmin\u306e\u74b0\u5883\u3092\u6574\u3048\u307e\u3059\u3002 mysql\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u8a2d\u5b9a\u306b\u82e5\u5e72\u82e6\u52b4\u3057\u307e\u3057\u305f\u306e\u3067\u305d\u306e\u6642\u306e\u30e1\u30e2\u3067\u3059\u3002 nginx\u3001mysql\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb [bash] $ sudo apt-get install nginx mysql-server [\/bash] nginx\u306e\u8d77\u52d5\u78ba\u8a8d [bash] $ sudo systemctl start nginx [\/bash] \u30d6\u30e9\u30a6\u30b6\u30fc\u3067 http:\/\/localhost\u3000\u3068\u3057\u3066nginx\u306e\u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002 php\u3001php-fpm\u306a\u3069\u306a\u3069\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb [bash] $ sudo apt-get install php php-fpm php-mysql php-gettext php-common php-mbstring php-mbstring [\/bash] \u3053\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u3067nginx\u306eindex.html \u304capache\u30e9\u30a4\u30af\u306a\u3082\u306e\u306b\u66f8\u304d\u63db\u3048\u3089\u308c\u308b\u3063\u307d\u3044\u304c\u3001\u6c17\u306b\u3057\u306a\u3044\uff08\u7b11\uff09 php.ini\u8abf\u6574 [bash] $ sudo nano \/etc\/php\/7.2\/fpm\/php.ini [\/bash] \u4ee5\u4e0b\u306e\u90e8\u5206\u3092\u8abf\u6574\u3057\u307e\u3059\u3002 [diff] + cgi.fix_pathinfo=0 [\/diff] nginx\u3000php\u9023\u643a \u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u8abf\u6574 [bash] $ sudo nano \/etc\/nginx\/sites-available\/default [\/bash] \u4ee5\u4e0b\u3092\u8ffd\u8a18\u3057\u307e\u3059\u3002 [bash] location ~ \\.php$ { try_files $uri =404; fastcgi_pass unix:\/var\/run\/php\/php7.2-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } [\/bash] \u30c6\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210 [bash] $ sudo nano \/var\/www\/html\/test.php [\/bash] \u4ee5\u4e0b\u306e\uff11\u884c\u3092\u8a18\u8ff0\u3057\u3066\u304f\u3060\u3055\u3044\u3002 [bash] [\/bash] nginx\u518d\u8d77\u52d5 [bash] $ sudo systemctl restart nginx [\/bash] \u30d6\u30e9\u30a6\u30b6\u30fc\u3067\u52d5\u4f5c\u78ba\u8a8d http:\/\/localhost\/test.php \u3078\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8868\u793a\u304c\u3055\u308c\u308c\u3070OK phpmyadmin\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb https:\/\/www.phpmyadmin.net\/\u3088\u308a\u6700\u65b0\u7248\u3092\u5165\u624b\u3002 \u89e3\u51cd\u3057\u3066 \/usr\/share\u3078\u30b3\u30d4\u30fc [bash] $ unzip phpMyAdmin-4.8.0-all-languages.zip $ mv phpMyAdmin-4.8.0-all-languages phpmyadmin $ sudo mv phpmyadmin\/ \/usr\/share\/ [\/bash] \u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u8abf\u6574 [bash] $ sudo nano \/etc\/nginx\/sites-available\/default [\/bash] \u4ee5\u4e0b\u3092\u8ffd\u8a18 [bash] location \/phpmyadmin { root \/usr\/share; index index.php; location ~ ^\/phpmyadmin.+\\.php$ { fastcgi_pass unix:\/var\/run\/php\/php7.2-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } [\/bash] nginx\u518d\u8d77\u52d5 [bash] $ sudo systemctl stop nginx $ sudo systemctl start nginx [\/bash] \u52d5\u4f5c\u78ba\u8a8d http:\/\/localhost\/phpmyadmin \u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8868\u793a\u306b\u306a\u308c\u3070\u6210\u529f Mysql root\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u8a2d\u5b9a \u4ee5\u524d\u306e\u30c7\u30a3\u30b9\u30c8\u30ea\u30d3\u30e5\u30fc\u30b7\u30e7\u30f3\u3060\u3068 mysql\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6642\u306b\u3001root\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5c0b\u306d\u308b\u30c0\u30a4\u30a2\u30ed\u30b0\u304c\u51fa\u3066\u304d\u3066\u3001\u305d\u3053\u3067root\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u8a2d\u5b9a\u3067\u304d\u305f\u306e\u3067\u3059\u304c\u300118.04\u3067\u306f\u306a\u305c\u304b\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u4ee5\u4e0b\u3067\u8abf\u6574\u3002 [bash] $ sudo mysql -u root mysql> USE mysql mysql> UPDATE user SET plugin=&#8217;mysql_native_password&#8217; WHERE User=&#8217;root&#8217;; mysql> FLUSH PRIVILEGES; mysql> exit; [\/bash] [bash] $ mysql -u root mysql> SET PASSWORD FOR root@&#8217;localhost&#8217; = PASSWORD(&#8216;xxxxxxxx&#8217;); mysql> exit; [\/bash]<\/p>\n","protected":false},"author":1,"featured_media":1827,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[4],"tags":[],"class_list":{"0":"post-1825","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-4"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/1825","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1825"}],"version-history":[{"count":4,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/1825\/revisions"}],"predecessor-version":[{"id":1830,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/1825\/revisions\/1830"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/media\/1827"}],"wp:attachment":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1825"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1825"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}