{"id":2435,"date":"2013-11-30T15:00:40","date_gmt":"2013-11-30T06:00:40","guid":{"rendered":"https:\/\/www.united-bears.co.jp\/blog\/?p=2435"},"modified":"2013-11-28T17:31:47","modified_gmt":"2013-11-28T08:31:47","slug":"apache-2-2-x-%e3%81%a7%e3%83%99%e3%83%bc%e3%82%b7%e3%83%83%e3%82%af%e8%aa%8d%e8%a8%bc2-%ef%bd%9e-mysql-%e3%82%92%e5%88%a9%e7%94%a8%e3%81%99%e3%82%8b%ef%bd%9e","status":"publish","type":"post","link":"https:\/\/www.united-bears.co.jp\/blog\/archives\/2435","title":{"rendered":"Apache 2.2.x \u3067\u30d9\u30fc\u30b7\u30c3\u30af\u8a8d\u8a3c(2) \uff5e MySQL \u3092\u5229\u7528\u3059\u308b\uff5e"},"content":{"rendered":"<p><a href=\"https:\/\/www.united-bears.co.jp\/blog\/archives\/2422\" target=\"_blank\">\u524d\u56de<\/a>\u306f\u3001\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306b\u3088\u308b\u30d9\u30fc\u30b7\u30c3\u30af\u8a8d\u8a3c\u3092\u884c\u3063\u305f\u304c\u3001\u4eca\u56de\u306f\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u4ee3\u308f\u308a\u306b MySQL \u3092\u5229\u7528\u3059\u308b\u3002\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u5229\u7528\u3059\u308b\u65b9\u6cd5\u306f\u7c21\u5358\u3067\u4fbf\u5229\u3060\u304c\u3001\u30e6\u30fc\u30b6\u30fc\u6570\u304c\u5897\u3048\u3066\u304d\u305f\u308a\u3001\u30e6\u30fc\u30b6\u30fc\u3092\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u7ba1\u7406\u3059\u308b\u3068\u304d\u306b\u4e0d\u4fbf\u3060\u3002\u305d\u3053\u3067\u3001MySQL \u306e\u30c6\u30fc\u30d6\u30eb\u3092\u5229\u7528\u3057\u3066\u8a8d\u8a3c\u3059\u308b\u65b9\u6cd5\u3092\u691c\u8a3c\u3057\u3066\u307f\u305f\u3002<\/p>\n<p>\u691c\u8a3c\u74b0\u5883\u306f\u3001Cent OS 6.4 \u3068 Apache 2.2.15\u3001MySQL 5.1.69\u3060\u3002Windows \u74b0\u5883\u306e\u5834\u5408\u3001\u6b8b\u5ff5\u306a\u304c\u3089<a href=\"http:\/\/httpd.apache.org\/download.cgi\" target=\"_blanK\">Apache \u3067\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u308b\u30d0\u30a4\u30ca\u30ea<\/a>\u3067\u306f<strong>\u52d5\u4f5c\u3057\u306a\u3044<\/strong>\u3002mod_auth_mysql \u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u542b\u307e\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3060\u3002<\/p>\n<p>\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u5229\u7528\u3057\u305f\u5834\u5408\u3068\u540c\u69d8\u3001MySQL \u3092\u5229\u7528\u3059\u308b\u57fa\u672c\u8a8d\u8a3c\u306f\u8907\u6570\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u7d4c\u7531\u3057\u3066\u884c\u308f\u308c\u308b\u3002<\/p>\n<ol>\n<li>AuthType Basic \u306b\u3088\u308a mod_auth_basic \u304c\u8d77\u52d5<\/li>\n<li>AuthMYSQLEnable on \u306b\u3088\u308a mod_auth_mysql \u304c\u8d77\u52d5\u3057\u3001\u5b9a\u7fa9\u306b\u5f93\u3063\u3066\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u53c2\u7167\u3059\u308b<\/li>\n<li>Require \u306e\u5b9a\u7fa9\u306b\u5f93\u3063\u3066\u3001mod_authz_user \u304c\u627f\u8a8d<\/li>\n<\/ol>\n<p>MySQL \u3092\u4f7f\u3063\u3066\u30d9\u30fc\u30b7\u30c3\u30af\u8a8d\u8a3c\u3092\u884c\u3046\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5b9a\u7fa9\u304c\u5fc5\u8981\u306b\u306a\u308b\u3002<\/p>\n<pre>\r\n#\u57fa\u672c\u8a8d\u8a3c\r\nLoadModule auth_basic_module modules\/mod_auth_basic.so\r\n#\u30db\u30b9\u30c8\u540d\/IP\u30a2\u30c9\u30ec\u30b9\u306b\u3088\u308b\u5236\u5fa1\r\nLoadModule authz_host_module modules\/mod_authz_host.so\r\n#\u30e6\u30fc\u30b6\u30fc\u540d\u306b\u3088\u308b\u627f\u8a8d\r\nLoadModule authz_user_module modules\/mod_authz_user.so\r\n#MySQL \u306e\u8a8d\u8a3c\u30e2\u30b8\u30e5\u30fc\u30eb\r\nLoadModule mysql_auth_module modules\/mod_auth_mysql.so\r\n\r\n...\r\n\r\n&lt;Directory \"\/var\/www\/html\"&gt;\r\n    Options FollowSymLinks\r\n    AllowOverride None\r\n    \r\n    AuthType Basic\r\n    AuthName \"User Zone\"\r\n\r\n    AuthMYSQLEnable on\r\n    # MySQL \u306b\u63a5\u7d9a\u3059\u308b\u6642\u306e\u30e6\u30fc\u30b6\u30fc ID\r\n    AuthMySQLUser user\r\n    # MySQL \u306b\u63a5\u7d9a\u3059\u308b\u6642\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\r\n    AuthMySQLPassword password\r\n    # MySQL \u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u540d\r\n    AuthMySQLDB auth\r\n    # AuthMySQLDB \u3067\u6307\u5b9a\u3057\u305f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u5185\u306e\u30c6\u30fc\u30d6\u30eb\u540d\r\n    AuthMySQLUserTable users\r\n    # AuthMySQLUserTable \u3067\u6307\u5b9a\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u5185\u306e\u30e6\u30fc\u30b6\u30fcID\u5217\r\n    AuthMySQLNameField login_id\r\n    # AuthMySQLUserTable \u3067\u6307\u5b9a\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u5185\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u5217\r\n    AuthMySQLPasswordField password\r\n    # \u30d1\u30b9\u30ef\u30fc\u30c9\u5217\u306e\u6697\u53f7\u5316\u65b9\u5f0f\r\n    AuthMySQLPwEncryption sha1\r\n\r\n    Require valid-user\r\n    \r\n    Order allow,deny\r\n    Allow from all\r\n&lt;\/Directory&gt;\r\n<\/pre>\n<p>MySQL \u3067\u8a8d\u8a3c\u3092\u884c\u3046\u305f\u3081\u306e\u300cmod_auth_mysql\u300d\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u8aad\u307f\u8fbc\u307f\u3001\u300cAuthMYSQLEnable\u300d\u306b\u300cOn\u300d\u3092\u6307\u5b9a\u3059\u308b\u3068 MySQL \u306b\u3088\u308b\u8a8d\u8a3c\u304c\u6709\u52b9\u306b\u306a\u308b\u3002\u4ee5\u964d\u306e\u5b9a\u7fa9\u306f\u3001MySQL \u3068\u63a5\u7d9a\u3059\u308b\u6642\u306e\u8a8d\u8a3c\u60c5\u5831\u3001\u5229\u7528\u3059\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3001\u30c6\u30fc\u30d6\u30eb\u3001\u5217\u540d\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u6697\u53f7\u5316\u65b9\u5f0f\u306b\u306a\u308b\u3002<\/p>\n<p>\u8a8d\u8a3c\u306b\u5229\u7528\u3059\u308b\u30c6\u30fc\u30d6\u30eb\u306b\u306f\u3001Apache \u3067\u5229\u7528\u3057\u306a\u3044\u5217\u304c\u542b\u307e\u308c\u3066\u3044\u3066\u3082\u3088\u3044\u3002Apache \u3067\u4e0a\u8a18\u306e\u5b9a\u7fa9\u3092\u884c\u3063\u3066\u3044\u308b\u524d\u63d0\u3067\u3001\u30d7\u30e9\u30a4\u30de\u30ea\u30fc\u30ad\u30fc\u306b user_id \u3092\u7528\u610f\u3057\u3001AUTO INCREMENT \u3059\u308b\u5217\u3092\u8ffd\u52a0\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3059\u308b\u4f8b\u3092\u6319\u3052\u308b\u3002<\/p>\n<pre>\r\nCREATE DATABASE auth;\r\nUSE auth;\r\nCREATE TABLE users (\r\n    user_id int(11) NOT NULL AUTO_INCREMENT,\r\n    login_id varchar(40) NOT NULL,\r\n    password varchar(40) NOT NULL,\r\n    PRIMARY KEY (user_id)\r\n);\r\nGRANT SELECT ON auth.users TO user@localhost IDENTIFIED BY 'password';\r\nFLUSH PRIVILEGES;\r\n<\/pre>\n<p>\u30e6\u30fc\u30b6\u30fc\u3092\u8ffd\u52a0\u3059\u308b\u5834\u5408\u306f\u3001SQL \u3067\u884c\u3092\u8ffd\u52a0\u3059\u308b\u3060\u3051\u3060\u3002<\/p>\n<pre>\r\nINSERT INTO users VALUES ('user1', SHA1('password'));\r\n<\/pre>\n<p>\u6697\u53f7\u5316\u65b9\u5f0f\u306b SHA1 \u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u5217\u306b\u633f\u5165\u3059\u308b\u30c7\u30fc\u30bf\u306f SHA1 \u95a2\u6570\u3092\u901a\u3057\u3066\u3044\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u306f\u3001\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306b\u3088\u308b\u30d9\u30fc\u30b7\u30c3\u30af\u8a8d\u8a3c\u3092\u884c\u3063\u305f\u304c\u3001\u4eca\u56de\u306f\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u4ee3\u308f\u308a\u306b MySQL \u3092\u5229\u7528\u3059\u308b\u3002\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u5229\u7528\u3059\u308b\u65b9\u6cd5\u306f\u7c21\u5358\u3067\u4fbf\u5229\u3060\u304c\u3001\u30e6\u30fc\u30b6\u30fc\u6570\u304c\u5897\u3048\u3066\u304d\u305f\u308a\u3001\u30e6\u30fc\u30b6\u30fc\u3092\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u7ba1\u7406 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-2435","post","type-post","status-publish","format-standard","hentry","category-server"],"_links":{"self":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts\/2435","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/comments?post=2435"}],"version-history":[{"count":1,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts\/2435\/revisions"}],"predecessor-version":[{"id":2436,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts\/2435\/revisions\/2436"}],"wp:attachment":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/media?parent=2435"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/categories?post=2435"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/tags?post=2435"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}