{"id":866,"date":"2018-06-22T09:55:59","date_gmt":"2018-06-22T00:55:59","guid":{"rendered":"https:\/\/fsck.jp\/?p=866"},"modified":"2018-08-03T11:37:08","modified_gmt":"2018-08-03T02:37:08","slug":"centos7-phpmyadmin","status":"publish","type":"post","link":"https:\/\/fsck.jp\/?p=866","title":{"rendered":"CentOS7 + nginx + phpMyAdmin"},"content":{"rendered":"<p>CentOS7\u306bphpMyAdmin\u3092EPEL\u7d4c\u7531\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u307f\u305f\u3002<\/p>\n<p>\u74b0\u5883:<br \/>\nOS: CentOS 7.5<br \/>\nWeb\u30b5\u30fc\u30d0: nginx (EPEL\u30d1\u30c3\u30b1\u30fc\u30b8)<br \/>\nPHP: php-fpm 5.4.16 (CentOS\u6a19\u6e96\u30d1\u30c3\u30b1\u30fc\u30b8)<br \/>\nDB: MariaDB 5.5.56 (CentOS\u6a19\u6e96\u30d1\u30c3\u30b1\u30fc\u30b8)<\/p>\n<h3>1. nginx\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>EPEL\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u8ffd\u52a0\u3059\u308b\uff08\u307e\u3060\u8ffd\u52a0\u3057\u3066\u3044\u306a\u3044\u5834\u5408\uff09<br \/>\n<code>$ sudo yum install epel-release<\/code><\/p>\n<p>nginx\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002<br \/>\n<code>$ sudo yum install nginx<\/code><br \/>\n\u8ffd\u52a0\u6a5f\u80fd\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u305f\u3044\u5834\u5408\u306f\u3001<a href=\"https:\/\/fsck.jp\/?p=646\">SRPM \u3092\u81ea\u524d\u3067\u30ea\u30d3\u30eb\u30c9\u3057\u3066\u3082\u3088\u3044<\/a>\u3002<\/p>\n<p>\u3042\u3068\u306f\u81ea\u5206\u306e\u7528\u610f\u3057\u305f\u3044Web\u30b5\u30fc\u30d0\u306b\u5408\u308f\u305b\u3066\u30d0\u30fc\u30c1\u30e3\u30eb\u30db\u30b9\u30c8\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u306b\u306a\u308b\u3002\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u4e2d\u306b\u3001phpMyAdmin \u7528\u306e\u8a18\u8ff0\u3092\u5165\u308c\u308b\u3002Apache \u7528\u306e\u8a2d\u5b9a\u304c \/etc\/httpd\/conf.d\/phpMyAdmin.conf \u306b\u3042\u308b\u306e\u3067\u3001\u53c2\u8003\u306b\u3059\u308b\u3002<\/p>\n<pre>\r\n  root \/usr\/share\/phpMyAdmin;\r\n  ...\r\n  location ~ ^\/libraries\/ { deny all; }\r\n  location ~ ^\/setup\/lib\/ { deny all; }\r\n  location ~ ^\/setup\/frames\/ { deny all; }\r\n  location ~ ^\/.*\\.php$ {\r\n    allow 203.0.113.100;\t\t\u2190\u81ea\u5b85\u304b\u3089\u306e\u30a2\u30af\u30bb\u30b9\u8a31\u53ef\r\n    deny all;\t\t\t\t\u2190\u305d\u308c\u4ee5\u5916\u306f\u5168\u90e8\u62d2\u5426\r\n    fastcgi_pass unix:\/run\/php-fpm\/php-fpm.sock;\r\n    include fastcgi_params;\r\n    fastcgi_split_path_info ^(.+\\.php)(\/.+)$;\r\n    fastcgi_param PATH_INFO $fastcgi_path_info;\r\n    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;\r\n    fastcgi_param SCRIPT_FILENAME $document_root\/$fastcgi_script_name;\r\n  }\r\n  location \/ {\r\n    allow 203.0.113.100;\r\n    deny all;\r\n  }<\/pre>\n<p><code>$ sudo systemctl enable nginx<br \/>\n$ sudo systemctl start nginx<\/code><\/p>\n<h3>2. mariadb \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30fb\u8a2d\u5b9a<\/h3>\n<p><code>$ sudo yum install mariadb mariadb-server<br \/>\n$ sudo systemctl enable mariadb<br \/>\n$ sudo systemctl start mariadb<\/code><\/p>\n<p>root\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u521d\u671f\u8a2d\u5b9a\u3092\u884c\u3063\u3066\u304a\u304f\u3002<br \/>\n<code>$ mysql_secure_installation<\/code><\/p>\n<h3>3. php\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30fb\u8a2d\u5b9a<\/h3>\n<p>\u5fc5\u8981\u305d\u3046\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u307e\u3068\u3081\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u304f\u3002<br \/>\n<code>$ sudo yum install php-fpm php-mysql php-gd php-mbstring<\/code><\/p>\n<p>php\u306e\u57fa\u672c\u8a2d\u5b9a\u3092\u884c\u3046\u3002<br \/>\n<code>$ sudo vi \/etc\/php.ini<\/code><\/p>\n<pre>\r\nexpose_php = Off\t\t\t\u2190PHP\u306e\u60c5\u5831\u3092\u96a0\u3059<\/pre>\n<p>\u307b\u304b\u306b\u3082\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u304cphp.ini\u306e\u4e2d\u306b\u3042\u308b\u306e\u3067\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u5909\u66f4\u3057\u3066\u304a\u304f\u3002<\/p>\n<p>php-fpm\u3068\u3057\u3066\u52d5\u4f5c\u3059\u308b\u3068\u304d\u306e\u8a2d\u5b9a\u3092\u884c\u3046\u3002<br \/>\n<code>$ sudo vi \/etc\/php-fpm.d\/www.conf<\/code><\/p>\n<pre>\r\nlisten = \/run\/php-fpm\/php-fpm.sock\t\u2190UNIX\u30bd\u30b1\u30c3\u30c8\u3092\u5229\u7528\r\nlisten.owner = nginx\t\t\t\u2190UNIX\u30bd\u30b1\u30c3\u30c8\u306e\u6240\u6709\u8005\u3092nginx\u5b9f\u884c\u30e6\u30fc\u30b6\u306b\u3059\u308b\r\nlisten.group = nginx\r\nlisten.mode = 0600\t\t\t\u2190nginx\u4ee5\u5916\u304b\u3089\u30bd\u30b1\u30c3\u30c8\u3092\u5229\u7528\u3067\u304d\u306a\u3044\u3088\u3046\u306b\u3059\u308b\r\nuser = nginx\t\t\t\t\u2190php-fpm\u5b9f\u884c\u30e6\u30fc\u30b6\u3092nginx\u306b\u305d\u308d\u3048\u3066\u304a\u304f\r\ngroup = nginx<\/pre>\n<p>php-fpm\u30c7\u30fc\u30e2\u30f3\u3092\u8d77\u52d5\u3059\u308b\u3002<br \/>\n<code>$ sudo systemctl enable php-fpm<br \/>\n$ sudo systemctl start php-fpm<\/code><\/p>\n<h3>3. phpMyAdmin\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30fb\u8a2d\u5b9a<\/h3>\n<p>phpMyAdmin\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002<br \/>\n<code>$ sudo yum install phpMyAdmin<\/code><\/p>\n<p>\u5fc5\u8981\u306a\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u4f5c\u6210\u3001nginx\u304b\u3089\u8aad\u3081\u308b\u3088\u3046\u6a29\u9650\u306e\u4fee\u6b63\u3092\u884c\u3046\u3002<br \/>\n<code>$ sudo mkdir -p \/var\/lib\/php\/session<br \/>\n$ sudo chown nginx:nginx \/var\/lib\/php\/session<br \/>\n$ sudo chgrp -R nginx \/etc\/phpMyAdmin<br \/>\n$ sudo chown -R nginx:nginx \/var\/lib\/phpMyAdmin<\/code><\/p>\n<p>phpMyAdmin\u306b\u5fc5\u8981\u306aDB\u30fb\u30c6\u30fc\u30d6\u30eb\u306e\u4f5c\u6210\u3092\u884c\u3046\u3002<br \/>\n<code>$ mysql -u root -p<br \/>\nEnter password:<br \/>\nMariaDB [(none)]> source \/usr\/share\/phpMyAdmin\/sql\/create_tables.sql;<br \/>\nMariaDB [(none)]> \\q<\/code><\/p>\n<p>\u3042\u3068\u306fWeb\u30d6\u30e9\u30a6\u30b6\u3067 http:\/\/\u81ea\u5206\u306e\u30b5\u30fc\u30d0\/phpMyAdmin\/ \u306b\u30a2\u30af\u30bb\u30b9\u3057\u3001\u52d5\u4f5c\u78ba\u8a8d\u3092\u884c\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CentOS7\u306bphpMyAdmin\u3092EPEL\u7d4c\u7531\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u307f\u305f\u3002 \u74b0\u5883: OS: CentOS 7.5 Web\u30b5\u30fc\u30d0: nginx (EPEL\u30d1\u30c3\u30b1\u30fc\u30b8) PHP: php-fpm 5.4.16 (CentOS [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20,13,26],"tags":[],"_links":{"self":[{"href":"https:\/\/fsck.jp\/index.php?rest_route=\/wp\/v2\/posts\/866"}],"collection":[{"href":"https:\/\/fsck.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fsck.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fsck.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fsck.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=866"}],"version-history":[{"count":0,"href":"https:\/\/fsck.jp\/index.php?rest_route=\/wp\/v2\/posts\/866\/revisions"}],"wp:attachment":[{"href":"https:\/\/fsck.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fsck.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=866"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fsck.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}