{"id":989,"date":"2017-10-02T19:50:37","date_gmt":"2017-10-02T10:50:37","guid":{"rendered":"https:\/\/www.dogrow.net\/linux\/?p=989"},"modified":"2021-09-16T00:23:14","modified_gmt":"2021-09-15T15:23:14","slug":"blog58","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/linux\/blog58\/","title":{"rendered":"(58)\u3010\u9023\u8f091-2\u3011VirtualBox\u4e0a\u306eUbuntu\u3092WEB\u30b5\u30fc\u30d0\u30fc\u306b"},"content":{"rendered":"<p>\u9023\u8f09\uff12\u56de\u76ee\u3001\u524d\u56de\u306e <a href=\"https:\/\/www.dogrow.net\/linux\/blog57\/\">\u300c(57)\u3010\u9023\u8f091\u3011CentOS7\u306bVirtualBox\u3092\u5165\u308c\u308b\u300d<\/a> \u306e\u7d9a\u304d\u3067\u3059\u3002<\/p>\n<h1 class=\"my_h\">\u3053\u306e\u9023\u8f09\u3067\u6700\u7d42\u7684\u306b\u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>CentOS7\u3092\u5165\u308c\u305f\u7269\u7406\u30b5\u30fc\u30d0\u30fc\u306b VirtualBox\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001<br \/>\n\u3000VirtualBox\u306e\u4eee\u60f3\u30de\u30b7\u30f3\u4e0a\u3067 Ubuntu\u306e\u4eee\u60f3\u30b5\u30fc\u30d0\u30fc\u3092\u52d5\u304b\u3057\u3001<br \/>\n\u3000\u3000Ubuntu\u306e\u4eee\u60f3\u30b5\u30fc\u30d0\u30fc\u4e0a\u3067 WEB\u30b5\u30fc\u30d0\u30fc\u3092\u52d5\u304b\u3057\u3001<br \/>\n\u3000\u3000\u3000eclipse \uff0b xdebug, PhpStorm + xdebug\u3067\u30ea\u30e2\u30fc\u30c8\u30c7\u30d0\u30c3\u30b0\u3057\u305f\u3044\u3002<\/p>\n<h1 class=\"my_h\">\u4eca\u56de\u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>CentOS7\u3092\u5165\u308c\u305f\u7269\u7406\u30b5\u30fc\u30d0\u30fc\u306b VirtualBox\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001Ubuntu\u306e\u4eee\u60f3\u30b5\u30fc\u30d0\u30fc\u3092\u52d5\u304b\u3057\u305f\u3002<br \/>\n\u4eca\u56de\u306f\u3053\u306e Ubuntu\u3092 WEB\u30b5\u30fc\u30d0\u30fc\u3068\u3057\u3066\u4f7f\u3044\u3001PHP\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u52d5\u304b\u3057\u3066MySQL\u3092\u5236\u5fa1\u3057\u305f\u3044\u3002<\/p>\n<h1 class=\"my_h\">(1) \u5fc5\u8981\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h1>\n<p>1) \u5b9a\u756a\u306eHTTP\u30b5\u30fc\u30d0\u30fc\u3067\u3042\u308b Apache2\u3092\u5165\u308c\u308b\u3002<\/p>\n<pre class=\"my_pre\">\r\nsudo apt install apache2\r\n\r\nsudo systemctl enable apache2\r\nsudo systemctl restart apache2\r\nsudo systemctl status apache2\r\n<\/pre>\n<p>\u524d\u56de\u306e\u6295\u7a3f\u3067 FireWall\u3092\u5c0e\u5165\u3057\u305f\u306e\u3067\u3001Port#80\uff08for http\uff09\u3092\u958b\u3051\u3066\u304a\u304f\u3002<\/p>\n<pre class=\"my_pre\">\r\nsudo ufw allow http\r\nsudo ufw status\r\n<\/pre>\n<p>2) PHP7.0\u3092\u5165\u308c\u308b\u3002  <span class=\"my_fs_small1 my_fc_red\">\u203bapt\u306b7.1\u304c\u306a\u304b\u3063\u305f\u3002<\/span><\/p>\n<pre class=\"my_pre\">\r\nsudo apt install php7.0\r\nsudo apt install php7.0-mysql php7.0-gd php7.0-mbstring php7.0-pear php7.0-common\r\nsudo apt install libapache2-mod-php7.0 php7.0-curl php7.0-mcrypt php7.0-cgi\r\n\r\nsudo a2enconf php7.0-cgi\r\nsudo systemctl reload apache2\r\n<\/pre>\n<p>3) MySQL\u3092\u5165\u308c\u308b\u3002<\/p>\n<pre class=\"my_pre\">\r\nsudo apt install mysql-server\r\n<\/pre>\n<p>MySQL\u306f 5.7.19 \u304c\u5165\u3063\u305f\u3002<\/p>\n<pre class=\"my_pre\">\r\nuser@:~$ mysql --version\r\nmysql  Ver 14.14 Distrib 5.7.19, for Linux (x86_64) using  EditLine wrapper\r\n<\/pre>\n<h1 class=\"my_h\" style=\"margin-top:3rem !important\">(2) \u3068\u308a\u3042\u3048\u305a\u52d5\u304f\u304b\u898b\u3066\u307f\u308b<\/h1>\n<h3 class=\"my_h\">1. WEB\u30d6\u30e9\u30a6\u30b6\u3067\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u308b\u3002<\/h3>\n<p>Windows\u30d1\u30bd\u30b3\u30f3\u3067 http:\/\/192.168.1.4 \u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u308b\u3002<br \/>\n<span class=\"my_fc_red my_fs_small1\">\u203b192.168.1.4\u306f\u524d\u56de\u6295\u7a3f\u3067\u5f53\u8a72VM\u306b\u5272\u308a\u5f53\u3066\u305f\u56fa\u5b9aIP\u30a2\u30c9\u30ec\u30b9<\/span><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.dogrow.net\/linux\/wp-content\/uploads\/2017\/10\/Image1-1.png\" alt=\"\" \/><br \/>\n\u3053\u3053\u307e\u3067\u306f\u3088\u308d\u3057\u3044\u3088\u3046\u3067\u3002<\/p>\n<h3 class=\"my_h\">2. phpinfo\u3092\u898b\u3066\u307f\u308b\u3002<\/h3>\n<p>phpinfo\u3092\u8868\u793a\u3059\u308b\u3060\u3051\u306e PHP\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u308a\u3001WEB\u30d6\u30e9\u30a6\u30b6\u3067\u3053\u308c\u3092\u8868\u793a\u3057\u3066\u307f\u308b\u3002<\/p>\n<pre class=\"my_pre\">\r\nvi \/var\/www\/html\/info.php\r\n<\/pre>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n  phpinfo();\r\n?&gt;\r\n<\/pre>\n<p>Windows\u30d1\u30bd\u30b3\u30f3\u3067 http:\/\/192.168.1.4\/info.php \u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u308b\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.dogrow.net\/linux\/wp-content\/uploads\/2017\/10\/Image3.png\" alt=\"\" \/><br \/>\n\u3053\u3061\u3089\u3082\u5927\u4e08\u592b\u306a\u3088\u3046\u3067\u3002<\/p>\n<h3 class=\"my_h\">3. PHP\u30b9\u30af\u30ea\u30d7\u30c8\u5185\u3067MySQL DB\u3092\u64cd\u4f5c\u3057\u3066\u307f\u308b\u3002<\/h3>\n<p>1) \u307e\u305a\u306f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5f8c\u4f55\u3082\u3057\u3066\u3044\u306a\u3044MySQL DB\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p>\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u3002<\/p>\n<pre class=\"my_pre\">\r\nuser@:~$ mysql -uroot -pxxxxx\r\n<\/pre>\n<p>Test\u3068\u3044\u3046\u540d\u524d\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<pre class=\"my_pre\">\r\ncreate database Test;\r\nuse Test;\r\n<\/pre>\n<p>Test\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b Ttt\u3068\u3044\u3046\u540d\u524d\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3002\u30ab\u30e9\u30e0\u306fINT AAA\u3068 TEXT BBB\u306e 2\u500b\u3068\u3059\u308b\u3002<\/p>\n<pre class=\"my_pre\">\r\ncreate table Ttt (`AAA` INT, `BBB` TEXT);\r\n<\/pre>\n<p>\u30c6\u30fc\u30d6\u30eb\u306b\u30ec\u30b3\u30fc\u30c9\u30921\u500b\u633f\u5165\u3059\u308b\u3002\u5024\u306f AAA=123, BBB=&#8217;ABC&#8217;<\/p>\n<pre class=\"my_pre\">\r\ninsert into Ttt values('123','ABC');\r\n<\/pre>\n<p>\u3053\u3093\u306a\u30c6\u30fc\u30d6\u30eb\u304c\u3067\u304d\u305f\u3002<\/p>\n<pre class=\"my_pre\">\r\nmysql> show tables;\r\n+----------------+\r\n| Tables_in_Test |\r\n+----------------+\r\n| Ttt            |\r\n+----------------+\r\n1 row in set (0.00 sec)\r\n\r\nmysql> desc Ttt;\r\n+-------+---------+------+-----+---------+-------+\r\n| Field | Type    | Null | Key | Default | Extra |\r\n+-------+---------+------+-----+---------+-------+\r\n| AAA   | int(11) | YES  |     | NULL    |       |\r\n| BBB   | text    | YES  |     | NULL    |       |\r\n+-------+---------+------+-----+---------+-------+\r\n2 rows in set (0.00 sec)\r\n\r\nmysql> select * from Ttt;\r\n+------+------+\r\n| AAA  | BBB  |\r\n+------+------+\r\n|  123 | ABC  |\r\n+------+------+\r\n1 row in set (0.00 sec)\r\n<\/pre>\n<p>\u3053\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u8aad\u307f\u51fa\u3059PHP\u30b9\u30af\u30ea\u30d7\u30c8 view.php \u3092\u66f8\u304f\u3002<\/p>\n<pre class=\"my_pre\">\r\nvi \/var\/www\/html\/view.php\r\n<\/pre>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n    \/\/ DB\u306b\u63a5\u7d9a\r\n    $cdb = new mysqli('127.0.0.1', 'root', 'xxxxx', 'Test');\r\n\r\n    \/\/ Test\u30c6\u30fc\u30d6\u30eb\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u53d6\u5f97\r\n    $res = $cdb-&gt;query('SELECT * FROM `Ttt`;');\r\n\r\n    \/\/ \u53d6\u5f97\u3057\u305f\u30ec\u30b3\u30fc\u30c9\u3092\u8868\u793a\r\n    $row = $res-&gt;fetch_assoc();\r\n    var_dump($row);\r\n?&gt;\r\n<\/pre>\n<p>Windows\u30d1\u30bd\u30b3\u30f3\u3067 http:\/\/192.168.1.4\/view.php \u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u308b\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.dogrow.net\/linux\/wp-content\/uploads\/2017\/10\/Image4-1.png\" alt=\"\" \/><br \/>\n\u78ba\u304b\u306b\u5024\u304c\u53d6\u5f97\u3067\u304d\u305f\u3002\u3053\u3061\u3089\u3082\u5927\u4e08\u592b\u306a\u3088\u3046\u3060\u3002<\/p>\n<h1 class=\"my_h\">\u2605\u6700\u7d42\u7684\u306b\u3067\u304d\u305f\u3053\u3068<\/h1>\n<p>\u30fbCentOS7\u7269\u7406\u30b5\u30fc\u30d0\u30fc\u4e0a\u306eUbuntu17\u4eee\u60f3\u30b5\u30fc\u30d0\u30fc\u306bWEB\u30b5\u30fc\u30d0\u30fc\u3092\u8a2d\u7f6e\u3067\u304d\u305f\u3002<br \/>\n\u30fb\u3053\u306eWEB\u30b5\u30fc\u30d0\u30fc\u4e0a\u3067\u306f PHP + SQL \u3067WEB\u30a2\u30d7\u30ea\u3092\u4f5c\u6210\u3067\u304d\u308b\u3002<\/p>\n<p>\u76ee\u7684\u3092\u9054\u6210\u3067\u304d\u305f\u306e\u3067\u3053\u3053\u307e\u3067\u3067OK\u3068\u3059\u308b\u3002<\/p>\n<hr class=\"my_hr_bottom\">\n","protected":false},"excerpt":{"rendered":"<p>\u9023\u8f09\uff12\u56de\u76ee\u3001\u524d\u56de\u306e \u300c(57)\u3010\u9023\u8f091\u3011CentOS7\u306bVirtualBox\u3092\u5165\u308c\u308b\u300d \u306e\u7d9a\u304d\u3067\u3059\u3002 \u3053\u306e\u9023\u8f09\u3067\u6700\u7d42\u7684\u306b\u3084\u308a\u305f\u3044\u3053\u3068 CentOS7\u3092\u5165\u308c\u305f\u7269\u7406\u30b5\u30fc\u30d0\u30fc\u306b VirtualBox\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001 \u3000Vir\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/linux\/blog58\/\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[125,80,79],"tags":[],"class_list":["post-989","post","type-post","status-publish","format-standard","hentry","category-db","category-mysql","category-php"],"views":5168,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/posts\/989","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/comments?post=989"}],"version-history":[{"count":45,"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/posts\/989\/revisions"}],"predecessor-version":[{"id":1409,"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/posts\/989\/revisions\/1409"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/media?parent=989"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/categories?post=989"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/tags?post=989"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}