{"id":1011,"date":"2017-02-21T11:37:08","date_gmt":"2017-02-21T02:37:08","guid":{"rendered":"http:\/\/blue-bear.jp\/kb\/?p=1011"},"modified":"2017-02-21T11:37:52","modified_gmt":"2017-02-21T02:37:52","slug":"aws-aws-amazon-linux%e3%81%a7nginxphpmysql%e7%92%b0%e5%a2%83%e3%82%92%e6%a7%8b%e7%af%89%e3%81%99%e3%82%8b%e3%83%97%e3%83%a9%e3%82%b9phpmyadmin","status":"publish","type":"post","link":"https:\/\/blue-bear.jp\/kb\/aws-aws-amazon-linux%e3%81%a7nginxphpmysql%e7%92%b0%e5%a2%83%e3%82%92%e6%a7%8b%e7%af%89%e3%81%99%e3%82%8b%e3%83%97%e3%83%a9%e3%82%b9phpmyadmin\/","title":{"rendered":"[AWS] AWS Amazon Linux\u3067Nginx+PHP+MySQL\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b(\u30d7\u30e9\u30b9phpmyadmin)"},"content":{"rendered":"<h2>AWS Amazon Linux\u3067Nginx+PHP+MySQL\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b<\/h2>\n<p>AWS\u4e0a\u3067Wordpress\u3092\u69cb\u7bc9\u3059\u308b\u306b\u306f\u3001\u516c\u5f0fAMI\u3067\u3042\u308b\u7db2\u5143\u3092\u5229\u7528\u3059\u308b\u307b\u3046\u304c\u30b5\u30fc\u30d0\u306e\u8a2d\u5b9a\u306a\u3069\u304c\u4e0d\u8981\u3067\u3044\u304d\u306a\u308aWordpress\u3092\u5229\u7528\u3067\u304d\u308b\u306e\u3067\u4fbf\u5229\u306a\u306e\u3060\u304c\u3001<br \/>\n\u30b5\u30fc\u30d0\u30b9\u30da\u30c3\u30af\u3092\u4e0a\u3052\u308b\u3068\u7db2\u5143\u306e\u5229\u7528\u6599\u91d1\u3082\u4e0a\u304c\u308b\u306e\u3067\u3001Nginx+PHP+MySQL\u74b0\u5883\u3092\u7db2\u5143\u306a\u3057\u3067\u69cb\u7bc9\u3057\u3066\u307f\u305f\u3002<\/p>\n<h3>AWS\u3067\u30b5\u30fc\u30d0\u8d77\u52d5<\/h3>\n<p>AWS\u4e0a\u3067Amazon Linux\u3092\u8d77\u52d5\u3055\u305b\u308b\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30dd\u30ea\u30b7\u30fc\u306f80\u3068\uff12\uff12\u3092\u958b\u3051\u3066\u304a\u304f\u3053\u3068<\/p>\n<h3>Nginx+MySQL+PHP\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>yum\u3092\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3057\u3066\u304a\u304f<\/p>\n<pre>sudo yum update -y\r\n<\/pre>\n<p>Nginx+MySQL+PHP\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<pre>sudo yum install nginx php56 php56-fpm mysql56-server php56-mysqlnd -y\r\n<\/pre>\n<h3>Nginx\u306e\u8d77\u52d5\u30fb\u8a2d\u5b9a<\/h3>\n<p>Nginx\u306e\u8d77\u52d5<\/p>\n<pre>sudo service nginx start<\/pre>\n<p>Nginx\u306e\u8d77\u52d5\u78ba\u8a8d<br \/>\n\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u30b5\u30fc\u30d0\u306e\u30a2\u30c9\u30ec\u30b9\u306b\u30a2\u30af\u30bb\u30b9<br \/>\nhttps:\/\/xxx.xxx.xxx.xxx<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1012\" src=\"http:\/\/blue-bear.jp\/kb\/wp-content\/uploads\/2017\/02\/nginx.png\" alt=\"nginx\" width=\"660\" height=\"355\" srcset=\"https:\/\/blue-bear.jp\/kb\/wp-content\/uploads\/2017\/02\/nginx.png 660w, https:\/\/blue-bear.jp\/kb\/wp-content\/uploads\/2017\/02\/nginx-300x161.png 300w\" sizes=\"(max-width: 660px) 100vw, 660px\" \/><\/p>\n<p>\u7121\u4e8b\u306bNginx\u306e\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308c\u3070OK<\/p>\n<p>Nginx\u30e9\u30f3\u30ec\u30d9\u30eb\u8a2d\u5b9a<\/p>\n<pre>sudo chkconfig nginx on<\/pre>\n<p>\u30e9\u30f3\u30ec\u30d9\u30eb\u78ba\u8a8d<\/p>\n<pre>chkconfig --list nginx<\/pre>\n<p>2,3,5\u304con\u306b\u306a\u3063\u3066\u3044\u308c\u3070OK<\/p>\n<h3>\/var\/www\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u8a2d\u5b9a<\/h3>\n<p>ec2-user\u3067\u3082www\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u66f8\u304d\u8fbc\u307f\u3067\u304d\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3059\u308b<\/p>\n<p>www\u30b0\u30eb\u30fc\u30d7\u306e\u8ffd\u52a0<\/p>\n<pre>sudo groupadd www<\/pre>\n<p>www\u30b0\u30eb\u30fc\u30d7\u306bec2-user\u3092\u8ffd\u52a0<\/p>\n<pre>sudo usermod -a -G www ec2-user<\/pre>\n<p>\u4e00\u65e6\u30ed\u30b0\u30a2\u30a6\u30c8\u3057\u3066AWS\u30b5\u30fc\u30d0\u306b\u518d\u63a5\u7d9a\u3059\u308b<br \/>\n\u30b0\u30eb\u30fc\u30d7\u78ba\u8a8d<\/p>\n<pre>groups\r\n<\/pre>\n<p>\/var\/www\u306e\u6240\u6709\u6a29\u3092www\u30b0\u30eb\u30fc\u30d7\u306b\u5909\u66f4<\/p>\n<pre>sudo chown -R root:www \/var\/www<\/pre>\n<p>\/var\/www\u30d5\u30a9\u30eb\u30c0\u306e\u66f8\u304d\u8fbc\u307f\u6a29\u9650\u5909\u66f4<\/p>\n<pre>sudo chmod 2775 \/var\/www<\/pre>\n<p>\/var\/www\u30d5\u30a9\u30eb\u30c0\u306e\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u30b0\u30eb\u30fc\u30d7ID\u3092\u8ffd\u52a0<\/p>\n<pre>find \/var\/www -type d -exec sudo chmod 2775 {} +<\/pre>\n<p>\/var\/www\u30d5\u30a9\u30eb\u30c0\u914d\u4e0b\u306b\u30b0\u30eb\u30fc\u30d7\u306e\u66f8\u304d\u8fbc\u307f\u8a31\u53ef\u3092\u8ffd\u52a0<\/p>\n<pre>find \/var\/www -type f -exec sudo chmod 0664 {} +<\/pre>\n<h3>PHP\u8a2d\u5b9a<\/h3>\n<p>Nginx\u306e\u8a2d\u5b9a\u3092\u5909\u66f4<\/p>\n<pre>sudo vi \/etc\/nginx\/nginx.conf<\/pre>\n<p>\u5909\u66f4\u5185\u5bb9<br \/>\n\/var\/www\/html\u914d\u4e0b\u306bphp\u30d5\u30a1\u30a4\u30eb\u3092\u914d\u7f6e\u3059\u308b\u3053\u3068\u3092\u60f3\u5b9a<\/p>\n<pre>index   index.html index.htm index.php;\r\n\r\n\r\n server {\r\n        listen       80;\r\n        server_name  localhost;\r\n        root         \/var\/www\/html;\r\n\r\n\r\n\r\nlocation ~ \\.php$ {\r\n            root           \/var\/www\/html;\r\n            fastcgi_pass   unix:\/var\/run\/php-fpm\/php-fpm.sock;\r\n            fastcgi_index  index.php;\r\n            fastcgi_param  SCRIPT_FILENAME   \/var\/www\/html$fastcgi_script_name;\r\n            include        fastcgi_params;\r\n        }\r\n<\/pre>\n<p>php-fpm\u306e\u8a2d\u5b9a\u3092\u5909\u66f4<\/p>\n<pre>sudo vi \/etc\/php-fpm.d\/www.conf<\/pre>\n<p>\uff0aphp-fpm\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306b\u3088\u3063\u3066\u306f\u30d5\u30a9\u30eb\u30c0\u306e\u5834\u6240\u304c\u7570\u306a\u308b\u3053\u3068\u3042\u308a<\/p>\n<pre>user = nginx\r\ngroup = nginx\r\n<\/pre>\n<p>\uff0a\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306fapache\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3001nginx\u306b\u5909\u66f4<\/p>\n<p>php-fpm\u306e\u30e9\u30f3\u30ec\u30d9\u30eb\u5909\u66f4<\/p>\n<pre>sudo chkconfig php-fpm on<\/pre>\n<p>Nginx\u3068php-fpm\u3092\u518d\u8d77\u52d5<\/p>\n<pre>service nginx restart\r\nservice php-fpm start\r\n<\/pre>\n<p>\u30c6\u30b9\u30c8\u7528php\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210<\/p>\n<pre>echo \"<!--?php phpinfo();\" &gt;&gt; \/var\/www\/html\/phpinfo.php&lt;\/pre&gt;\r\n&lt;p&gt;&lt;img src=\"http:\/\/blue-bear.jp\/kb\/wp-content\/uploads\/2017\/02\/forin.png\" alt=\"forin\" width=\"678\" height=\"215\" class=\"alignnone size-full wp-image-1002\" ?--><\/pre>\n<p>https:\/\/xxx.xxx.xxx.xxx\/phpinfo.php\u306b\u30a2\u30af\u30bb\u30b9<br \/>\nphpinfo\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308c\u3070OK<\/p>\n<h3>MySQL\u306e\u8a2d\u5b9a<\/h3>\n<p>MySQL\u306e\u8d77\u52d5<\/p>\n<pre>sudo service mysqld start<\/pre>\n<p>MySQL\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u8a2d\u5b9a<\/p>\n<pre>sudo mysql_secure_installation<\/pre>\n<p>Root\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u5165\u529b\u2192\u307e\u3060\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u305d\u306e\u307e\u307eEnter<br \/>\nSet root password? [Y\/n] Y<br \/>\n\u2192\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5165\u529b<br \/>\nRemove anonymous users? [Y\/n] Y<br \/>\n\u2192\u533f\u540d\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u524a\u9664YES<br \/>\nDisallow root login remotely? [Y\/n] Y<br \/>\n\u2192Root\u306e\u30ea\u30e2\u30fc\u30c8\u30ed\u30b0\u30a4\u30f3\u3092\u4e0d\u8a31\u53efYES<br \/>\nRemove test database and access to it? [Y\/n] Y<br \/>\n\u2192TestDB\u3092\u524a\u9664YES<br \/>\nReload privilege tables now? [Y\/n] Y<br \/>\n\u2192\u6a29\u9650Table\u3092\u30ea\u30ed\u30fc\u30c9YES<\/p>\n<p>MySQL\u306e\u30e9\u30f3\u30ec\u30d9\u30eb\u8a2d\u5b9a<\/p>\n<h3>sudo chkconfig mysqld on<\/h3>\n<h3>phpMyAdmin\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30fb\u8a2d\u5b9a<\/h3>\n<p>GUI\u3067MySQL\u3092\u7ba1\u7406\u3057\u305f\u304b\u3063\u305f\u306e\u3067phpMyAdmin\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<p>EPEL\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u6709\u52b9\u5316<\/p>\n<pre>sudo yum-config-manager --enable epel<\/pre>\n<p>phpMyAdmin\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<pre>sudo yum install phpMyAdmin -y<\/pre>\n<p>Nginx\u306e\u8a2d\u5b9a<\/p>\n<pre>sudo vi \/etc\/nginx\/nginx.conf<\/pre>\n<p>\u5909\u66f4\u5185\u5bb9<br \/>\n\/var\/www\/html\u914d\u4e0b\u306bphp\u30d5\u30a1\u30a4\u30eb\u3092\u914d\u7f6e\u3059\u308b\u3053\u3068\u3092\u60f3\u5b9a<\/p>\n<pre>index   index.html index.htm index.php;\r\n\r\n server {\r\n        listen       80;\r\n        server_name  localhost;\r\n        root         \/var\/www\/html;\r\n\r\n        ####\u8ffd\u52a0\r\n        location \/phpMyAdmin {\r\n            alias \/usr\/share\/phpMyAdmin;\r\n            index index.php index.html;\r\n            #allow 127.0.0.1;\r\n            #deny  all;\r\n        }\r\n\r\n        ####\u8ffd\u52a0\r\n        location ~ \/phpMyAdmin\/.*\\.php$ {\r\n            fastcgi_pass  unix:\/var\/run\/php-fpm\/php-fpm.sock;\r\n            fastcgi_index index.php;\r\n            #fastcgi_param SCRIPT_FILENAME \/usr\/share\/phpMyAdmin$fastcgi_script_name;\r\n            fastcgi_param SCRIPT_FILENAME \/usr\/share\/$uri;\r\n            include fastcgi_params;\r\n        }\r\n\r\nlocation ~ \\.php$ {\r\n            root           \/var\/www\/html;\r\n            fastcgi_pass   unix:\/var\/run\/php-fpm\/php-fpm.sock;\r\n            fastcgi_index  index.php;\r\n            fastcgi_param  SCRIPT_FILENAME   \/var\/www\/html$fastcgi_script_name;\r\n            include        fastcgi_params;\r\n        }\r\n<\/pre>\n<p>Nginx\u3068php-fpm\u3092\u518d\u8d77\u52d5<\/p>\n<pre>service nginx restart\r\nservice php-fpm restart\r\n<\/pre>\n<p>https:\/\/xxx.xxx.xxx.xxx\/phpMyAdmin\u306b\u30a2\u30af\u30bb\u30b9<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1013\" src=\"http:\/\/blue-bear.jp\/kb\/wp-content\/uploads\/2017\/02\/phpmyadmin.png\" alt=\"phpmyadmin\" width=\"462\" height=\"523\" srcset=\"https:\/\/blue-bear.jp\/kb\/wp-content\/uploads\/2017\/02\/phpmyadmin.png 462w, https:\/\/blue-bear.jp\/kb\/wp-content\/uploads\/2017\/02\/phpmyadmin-265x300.png 265w\" sizes=\"(max-width: 462px) 100vw, 462px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>AWS Amazon Linux\u3067Ngi<\/p>\n","protected":false},"author":1,"featured_media":1012,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,117,6],"tags":[139,125,115],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/1011"}],"collection":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/comments?post=1011"}],"version-history":[{"count":2,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/1011\/revisions"}],"predecessor-version":[{"id":1015,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/1011\/revisions\/1015"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media\/1012"}],"wp:attachment":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media?parent=1011"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/categories?post=1011"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/tags?post=1011"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}