{"id":15656,"date":"2024-01-02T08:15:08","date_gmt":"2024-01-01T23:15:08","guid":{"rendered":"https:\/\/lab4ict.com\/system\/?p=15656"},"modified":"2024-01-18T05:35:16","modified_gmt":"2024-01-17T20:35:16","slug":"%e5%85%ac%e9%96%8b%e7%94%a8%e3%81%aewordpress%e3%82%b5%e3%83%bc%e3%83%90%e3%82%92%e6%a7%8b%e7%af%89%e3%81%99%e3%82%8b%ef%bc%81%ef%bc%88ubuntu-20-04%ef%bc%89","status":"publish","type":"post","link":"https:\/\/lab4ict.com\/system\/archives\/15656","title":{"rendered":"\u516c\u958b\u7528\u306eWordPress\u30b5\u30fc\u30d0\u3092\u69cb\u7bc9\u3059\u308b\uff01\uff08Ubuntu 20.04\uff09"},"content":{"rendered":"<p>Ubuntu Server 20.04\u3092\u4f7f\u7528\u3057\u3066\u3001\u516c\u958b\u7528\u306eWordPress\u30b5\u30fc\u30d0\u3092\u69cb\u7bc9\u3057\u307e\u3059\u3002\u4f5c\u696d\u306f\u3001root\u6a29\u9650\u3092\u4f7f\u7528\u3057\u3066\u884c\u3044\u307e\u3059\u3002<br \/>\n<!--more--><\/p>\n<h2>SSH\u306e\u901a\u4fe1\u304c\u53ef\u80fd\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\uff01<\/h2>\n<p>SSH\u3067\u901a\u4fe1\u3067\u304d\u306a\u3044\u3068\u3001\u30b5\u30fc\u30d0\u306e\u64cd\u4f5c\u304c\u884c\u3048\u306a\u3044\u305f\u3081\u3001\u307e\u305aSSH\u3067\u30ed\u30b0\u30a4\u30f3\u3067\u304d\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<h2>Apache\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\uff01<\/h2>\n<p>Apache\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<h3>Apache\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\uff01<\/h3>\n<p>Apache\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002Apach\u306f\u3001apt\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# apt install -y apache2\r\n<\/pre>\n<h3>Firewall\u306e\u8a2d\u5b9a\u3092\u884c\u3046\uff01<\/h3>\n<p>Apache\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u305f\u3068\u3053\u308d\u3067\u3001Firewall\u306e\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002Apache\u3068SSH\u306e\u901a\u4fe1\u3092\u8a31\u53ef\u3057\u307e\u3059\u3002Apache\u306f\u3001HTTP\u3068HTTPS\u306e\u53cc\u65b9\u3092\u901a\u4fe1\u53ef\u80fd\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,7,10]; title: ; notranslate\" title=\"\">\r\n# ufw app list\r\nAvailable applications:\r\n  Apache\r\n  Apache Full\r\n  Apache Secure\r\n  OpenSSH\r\n# ufw allow in &quot;Apache Full&quot;\r\nRules updated\r\nRules updated (v6)\r\n# ufw allow in &quot;OpenSSH&quot;\r\nRules updated\r\nRules updated (v6)\r\n<\/pre>\n<p>Firewall\u306e\u8a2d\u5b9a\u306f\u3001\u8a2d\u5b9a\u3092\u884c\u3063\u305f\u3060\u3051\u3067\u306f\u6709\u52b9\u5316\u3055\u308c\u307e\u305b\u3093\u3002\u30d5\u30a1\u30a4\u30a2\u30a6\u30a9\u30fc\u30eb\u306e\u30b5\u30fc\u30d3\u30b9\u304c\u8d77\u52d5\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u3001\u8a2d\u5b9a\u3092\u6709\u52b9\u5316\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# systemctl status ufw\r\n\u25cf ufw.service - Uncomplicated firewall\r\n     Loaded: loaded (\/lib\/systemd\/system\/ufw.service; enabled; vendor preset: enabled)\r\n     Active: active (exited) since Sun 2021-01-17 20:46:32 JST; 1h 44min ago\r\n...\r\n<\/pre>\n<p>Firewall\u306e\u72b6\u614b\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002\u30b5\u30fc\u30d3\u30b9\u306f\u8d77\u52d5\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u72b6\u614b\u306f\u300cinactive\u300d\u3067\u3059\u306e\u3067\u3001\u8a2d\u5b9a\u3092\u6709\u52b9\u5316\u3059\u308b\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,3,6]; title: ; notranslate\" title=\"\">\r\n# ufw status\r\nStatus: inactive\r\n# ufw enable\r\nCommand may disrupt existing ssh connections. Proceed with operation (y|n)? y\r\nFirewall is active and enabled on system startup\r\n# ufw status\r\nStatus: active\r\n\r\nTo                         Action      From\r\n--                         ------      ----\r\nApache Full                ALLOW       Anywhere                  \r\nOpenSSH                    ALLOW       Anywhere                  \r\nApache Full (v6)           ALLOW       Anywhere (v6)             \r\nOpenSSH (v6)               ALLOW       Anywhere (v6)             \r\n<\/pre>\n<p>http:\/\/\u301c\/\u3067Apache2\u306e\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<h2>MariaDB\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\uff01<\/h2>\n<p>MariaDB\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\uff01<\/p>\n<h3>MariaDB\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\uff01<\/h3>\n<p>MariaDB\u3092apt\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\uff01<\/p>\n<pre class=\"brush: plain; highlight: [1,2]; title: ; notranslate\" title=\"\">\r\n# apt update\r\n# apt install -y mariadb-server\r\n<\/pre>\n<h3>MariaDB\u306e\u6587\u5b57\u30b3\u30fc\u30c9\u3092\u78ba\u8a8d\u3059\u308b\uff01<\/h3>\n<p>MariaDB\u306e\u6587\u5b57\u30b3\u30fc\u30c9\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u76ee\u7684\u306e\u300cutf8mb4\u300d\u306b\u306a\u3063\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,2]; title: ; notranslate\" title=\"\">\r\n# grep utf8 \/etc\/mysql\/mariadb.conf.d\/50-server.cnf\r\n# utf8 4-byte character set. See also client.cnf\r\ncharacter-set-server  = utf8mb4\r\ncollation-server      = utf8mb4_general_ci\r\n<\/pre>\n<h3>MariaDB\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u8a2d\u5b9a\u3092\u884c\u3046\uff01<\/h3>\n<p>\u300cmysql_secure_installation\u300d\u30b3\u30de\u30f3\u30c9\u3067\u3001MariaDB\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# mysql_secure_installation\r\n\r\nNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB\r\n      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!\r\n\r\nIn order to log into MariaDB to secure it, we'll need the current\r\npassword for the root user.  If you've just installed MariaDB, and\r\nyou haven't set the root password yet, the password will be blank,\r\nso you should just press enter here.\r\n\r\nEnter current password for root (enter for none): \r\nOK, successfully used password, moving on...\r\n\r\nSetting the root password ensures that nobody can log into the MariaDB\r\nroot user without the proper authorisation.\r\n\r\nSet root password? &#x5B;Y\/n] \r\nNew password: \r\nRe-enter new password: \r\nPassword updated successfully!\r\nReloading privilege tables..\r\n ... Success!\r\n\r\n\r\nBy default, a MariaDB installation has an anonymous user, allowing anyone\r\nto log into MariaDB without having to have a user account created for\r\nthem.  This is intended only for testing, and to make the installation\r\ngo a bit smoother.  You should remove them before moving into a\r\nproduction environment.\r\n\r\nRemove anonymous users? &#x5B;Y\/n] \r\n ... Success!\r\n\r\nNormally, root should only be allowed to connect from 'localhost'.  This\r\nensures that someone cannot guess at the root password from the network.\r\n\r\nDisallow root login remotely? &#x5B;Y\/n] \r\n ... Success!\r\n\r\nBy default, MariaDB comes with a database named 'test' that anyone can\r\naccess.  This is also intended only for testing, and should be removed\r\nbefore moving into a production environment.\r\n\r\nRemove test database and access to it? &#x5B;Y\/n] \r\n - Dropping test database...\r\n ... Success!\r\n - Removing privileges on test database...\r\n ... Success!\r\n\r\nReloading the privilege tables will ensure that all changes made so far\r\nwill take effect immediately.\r\n\r\nReload privilege tables now? &#x5B;Y\/n] \r\n ... Success!\r\n\r\nCleaning up...\r\n\r\nAll done!  If you've completed all of the above steps, your MariaDB\r\ninstallation should now be secure.\r\n\r\nThanks for using MariaDB!\r\n<\/pre>\n<h3>MariaDB\u306b\u30ed\u30b0\u30a4\u30f3\u3059\u308b\uff01<\/h3>\n<p>MariaDB\u306b\u30ed\u30b0\u30a4\u30f3\u3067\u304d\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3057\u3087\u3046\uff01\u4ee5\u4e0b\u3067\u306f\u3001\u30ed\u30b0\u30a4\u30f3\u5f8c\u3001DB\u306e\u6587\u5b57\u30b3\u30fc\u30c9\u306e\u8a2d\u5b9a\u3092\u78ba\u8a8d\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# mysql -u root -p\r\nEnter password: \r\nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\r\nYour MariaDB connection id is 58\r\nServer version: 10.3.25-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.04\r\n\r\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\r\n\r\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\r\n\r\nMariaDB &#x5B;(none)]&gt; show variables like 'character%';\r\n+--------------------------+----------------------------+\r\n| Variable_name            | Value                      |\r\n+--------------------------+----------------------------+\r\n| character_set_client     | utf8mb4                    |\r\n| character_set_connection | utf8mb4                    |\r\n| character_set_database   | utf8mb4                    |\r\n| character_set_filesystem | binary                     |\r\n| character_set_results    | utf8mb4                    |\r\n| character_set_server     | utf8mb4                    |\r\n| character_set_system     | utf8                       |\r\n| character_sets_dir       | \/usr\/share\/mysql\/charsets\/ |\r\n+--------------------------+----------------------------+\r\n8 rows in set (0.003 sec)\r\n\r\nMariaDB &#x5B;(none)]&gt; quit\r\nBye\r\n<\/pre>\n<h2>PHP\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\uff01<\/h2>\n<p>PHP\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<h3>PHP\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\uff01<\/h3>\n<p>PHP7.4\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002Ubuntu 20.04\u3067\u306f\u3001\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u767b\u9332\u4f5c\u696d\u3092\u884c\u308f\u306a\u304f\u3066\u3082\u3001PHP7.4\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u6ce8\u610f\u6df1\u304f\u30ed\u30b0\u3092\u898b\u308b\u3068\u3001Apache\u306e\u8a2d\u5b9a\u304c\u5909\u66f4\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u306a\u3069\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# apt install php7.4 php7.4-mysql\r\nReading package lists... Done\r\nBuilding dependency tree       \r\nReading state information... Done\r\nThe following additional packages will be installed:\r\n  libapache2-mod-php7.4 php-common php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-readline\r\nSuggested packages:\r\n  php-pear\r\nThe following NEW packages will be installed:\r\n  libapache2-mod-php7.4 php-common php7.4 php7.4-cli php7.4-common php7.4-json php7.4-mysql php7.4-opcache php7.4-readline\r\n...\r\nCreating config file \/etc\/php\/7.4\/apache2\/php.ini with new version\r\nModule mpm_event disabled.\r\nEnabling module mpm_prefork.\r\napache2_switch_mpm Switch to prefork\r\napache2_invoke: Enable module php7.4\r\n...\r\n<\/pre>\n<p>\u305d\u306e\u4ed6\u3001WordPress\u3067\u5fc5\u8981\u3068\u306a\u308b\u4ee5\u4e0b\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3082\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002php-gd\u306f\u3001\u5fc5\u9808\u30e2\u30b8\u30e5\u30fc\u30eb\u3067\u3059\u3002\u305d\u306e\u4ed6\u306f\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u4f7f\u7528\u3055\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# apt install php-gd php-mbstring\r\n# apt install php-zip\r\n# apt install php-curl\r\n# apt install php-dom\r\n# apt install php-imagick\r\n<\/pre>\n<h3>PHP\u306e\u8a2d\u5b9a\u3092\u884c\u3046\uff01<\/h3>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3001PHP\u306e\u30bf\u30a4\u30e0\u30be\u30fc\u30f3\u304a\u3088\u3073\u65e5\u672c\u8a9e\u306b\u95a2\u3059\u308b\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# vi \/etc\/php\/7.4\/apache2\/php.ini\r\ndate.timezone = &quot;Asia\/Tokyo&quot;\r\nmbstring.language = Japanese\r\nmbstring.internal_encoding = UTF-8\r\nmbstring.http_input = pass\r\nmbstring.http_output = pass\r\nmbstring.encoding_translation = Off\r\nmbstring.detect_order = auto\r\nmbstring.substitute_character = none;\r\nmbstring.func_overload = 0\r\nmbstring.strict_detection = Off\r\n<\/pre>\n<h3>Apache\u3092\u518d\u8d77\u52d5\u3059\u308b\uff01<\/h3>\n<p>\u8ffd\u52a0\u3057\u305f\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u6709\u52b9\u5316\u3059\u308b\u305f\u3081\u3001Apache\u3092\u518d\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# systemctl restart apache2\r\n<\/pre>\n<h3>PHP\u306e\u52d5\u4f5c\u78ba\u8a8d\u3092\u884c\u3046\uff01<\/h3>\n<p>PHP\u306e\u52d5\u4f5c\u78ba\u8a8d\u3092\u884c\u3044\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u300cphpcheck.php\u300d\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,2]; title: ; notranslate\" title=\"\">\r\n# cd \/var\/www\/html\r\n# vi phpcheck.php\r\n&lt;?php\r\n    phpinfo();\r\n?&gt;\r\n# chmod 755 phpcheck.php \r\nroot@118-27-109-28:\/var\/www\/html# ls -l\r\ntotal 16\r\n-rw-r--r-- 1 root root 10918 Jan 17 22:25 index.html\r\n-rwxr-xr-x 1 root root    24 Jan 17 23:13 phpcheck.php\r\n<\/pre>\n<p>http:\/\/<\u30b5\u30fc\u30d0\u306eIP\u30a2\u30c9\u30ec\u30b9>\/phpcheck.php\u3067\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3001PHP\u306e\u8a2d\u5b9a\u60c5\u5831\u304c\u51fa\u529b\u3055\u308c\u308c\u3070\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6210\u529f\u3067\u3059\u3002<\/p>\n<h2>HTTPS\u3092\u4f7f\u7528\u3059\u308b\uff01\uff08Let's Encript\uff09<\/h2>\n<p>HTTPS\u3092\u4f7f\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u3001Let's Encript\u3092apt\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# apt install certbot python3-certbot-apache\r\n<\/pre>\n<p>Apache\u3067SSL\u901a\u4fe1\u304c\u53ef\u80fd\u306b\u306a\u308b\u3088\u3046\u306b\u3001SSL\u306e\u6a5f\u80fd\u3092\u6709\u52b9\u5316\u3057\u307e\u3059\u3002HTTP\u3092HTTPS\u306b\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3059\u308b\u305f\u3081\u3001URL\u30ea\u30e9\u30a4\u30c8\u306e\u6a5f\u80fd\u3082\u6709\u52b9\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,5,16]; title: ; notranslate\" title=\"\">\r\n# a2ensite default-ssl\r\nEnabling site default-ssl.\r\nTo activate the new configuration, you need to run:\r\n  systemctl reload apache2\r\n# a2enmod ssl \r\nConsidering dependency setenvif for ssl:\r\nModule setenvif already enabled\r\nConsidering dependency mime for ssl:\r\nModule mime already enabled\r\nConsidering dependency socache_shmcb for ssl:\r\nEnabling module socache_shmcb.\r\nEnabling module ssl.\r\nSee \/usr\/share\/doc\/apache2\/README.Debian.gz on how to configure SSL and create self-signed certificates.\r\nTo activate the new configuration, you need to run:\r\n  systemctl restart apache2\r\n# a2enmod rewrite \r\nEnabling module rewrite.\r\nTo activate the new configuration, you need to run:\r\n  systemctl restart apache2\r\n<\/pre>\n<p>\u4eca\u56de\u306f\u3001Let's Encript\u3067\u7a3c\u50cd\u4e2d\u306e\u30b5\u30fc\u30d0\u306e\u79fb\u884c\u3067\u3042\u3063\u305f\u305f\u3081\u3001\u30b5\u30fc\u30d0\u8a3c\u660e\u66f8\u3092\u79fb\u884c\u3057\u307e\u3059\u3002\u300c\/etc\/letsencrypt\u300d\u914d\u4e0b\u306e\u8cc7\u6e90\u3092\u3059\u3079\u3066\u3001tar\u30b3\u30de\u30f3\u30c9\u7b49\u3067\u30a2\u30fc\u30ab\u30a4\u30d6\u3057\u3066\u3001\u305d\u306e\u307e\u307e\u79fb\u884c\u3057\u307e\u3059\u3002\u305d\u306e\u4ed6\u3001CA\u5c40\u306e\u8a3c\u660e\u66f8\u306f\u3001\u300c\/etc\/apache2\/ssl.crt\u300d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u3066\u5225\u9014\u79fb\u884c\u3057\u307e\u3059\u3002<\/p>\n<p>\u300c\/etc\/apache2\/sites-available\u300d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u300cdefault-ssl.conf\u300d\u306e\u8a2d\u5b9a\u3092\u5909\u66f4\u3057\u307e\u3059\u3002\u5f53\u30b5\u30a4\u30c8\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nSSLCertificateFile \/etc\/letsencrypt\/live\/lab4ict.com\/cert.pem\r\nSSLCertificateKeyFile \/etc\/letsencrypt\/live\/lab4ict.com\/privkey.pem\r\nSSLCertificateChainFile \/etc\/letsencrypt\/live\/lab4ict.com\/chain.pem\r\nSSLCACertificateFile \/etc\/apache2\/ssl.crt\/ca-lab4ict.pem\r\n<\/pre>\n<p>\u305d\u306e\u4ed6\u3001DocumentRoot\u3084\u3001Alias\u306e\u8a2d\u5b9a\u3092\u30b5\u30a4\u30c8\u306e\u69cb\u6210\u306b\u5408\u308f\u305b\u3066\u884c\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nDocumentRoot \/var\/www\/html\/wordpress\r\n...\r\n<\/pre>\n<p>\u30b5\u30fc\u30d0\u8a3c\u660e\u66f8\u306e\u81ea\u52d5\u66f4\u65b0\u306e\u305f\u3081\u3001\u30b5\u30fc\u30d0\u8a3c\u660e\u66f8\u3092\u81ea\u52d5\u66f4\u65b0\u3059\u308b\u30b3\u30de\u30f3\u30c9\u304c\u6b63\u5e38\u7d42\u4e86\u3059\u308b\u304b\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# certbot renew --pre-hook &quot;sudo systemctl stop apache2&quot; --post-hook &quot;sudo systemctl start apache2&quot;\r\n<\/pre>\n<p>\u30b5\u30fc\u30d0\u8a3c\u660e\u66f8\u3092\u81ea\u52d5\u66f4\u65b0\u3059\u308b\u305f\u3081\u3001\u4e0a\u8a18\u3067\u78ba\u8a8d\u3057\u305f\u30b3\u30de\u30f3\u30c9\u3092cron\u306b\u767b\u9332\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306f\u3001\u90311\u56de\u3001\u6708\u66dc\u65e5\u306e\u671d1:00\u306b\u5b9f\u884c\u3059\u308b\u4f8b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# crontab -e\r\n0 1 * * 1 certbot renew --pre-hook &quot;sudo systemctl stop apache2&quot; --post-hook &quot;sudo systemctl start apache2&quot;\r\n<\/pre>\n<p>HTTP\u3092HTTPS\u306b\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3059\u308b\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# vi \/etc\/apache2\/sites-available\/000-default.conf \r\n...\r\n#       DocumentRoot \/var\/www\/html\r\n        DocumentRoot \/var\/www\/html\/wordpress\r\n...\r\n        RewriteEngine On\r\n        RewriteCond %{HTTPS} off\r\n        RewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} &#x5B;R=301,L]\r\n<\/pre>\n<p>\u300c.htaccess\u300d\u3092\u6709\u52b9\u5316\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# vi \/etc\/apache2\/apache2.conf\r\n...\r\n&lt;Directory \/var\/www\/&gt;\r\n        Options Indexes FollowSymLinks\r\n#       AllowOverride None\r\n        AllowOverride All\r\n        Require all granted\r\n&lt;\/Directory&gt;\r\n...\r\n<\/pre>\n<p>\u8a2d\u5b9a\u304c\u4e00\u901a\u308a\u7d42\u308f\u3063\u305f\u3068\u3053\u308d\u3067\u3001Apache\u3092\u518d\u8d77\u52d5\u3057\u3066\u30b5\u30a4\u30c8\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# systemctl restart apache2\r\n<\/pre>\n<h2>Postfix\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\uff01<\/h2>\n<p>Postfix\u3092apt\u30b3\u30de\u30f3\u30c9\u3067\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002\u8a2d\u5b9a\u65b9\u6cd5\u3092\u304d\u304b\u308c\u307e\u3059\u304c\u3001\u3042\u3068\u3067\u624b\u52d5\u3067\u8a2d\u5b9a\u3059\u308b\u305f\u3081\u3001No Configuration\u3092\u9078\u629e\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# apt install postfix\r\n<\/pre>\n<p>\u4ee5\u4e0b\u3001\u57fa\u672c\u7684\u306a\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,2,3]; title: ; notranslate\" title=\"\">\r\n# cd \/etc\/postfix\r\n# cp main.cf.proto main.cf\r\n# vi main.cf\r\n\u301c\u4ee5\u4e0b\u3092\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3059\u308b\uff01\u301c\r\n#sendmail_path =\r\n#newaliases_path =\r\n#mailq_path =\r\n#setgid_group =\r\n#html_directory =\r\n#manpage_directory =\r\n#sample_directory =\r\n#readme_directory =\r\n\u301c\u4ee5\u4e0b\u3092\u8ffd\u52a0\u3059\u308b\uff01\u301c\r\nmail_owner = postfix\r\nmyhostname = mx.lab4ict.com\r\nmydomain = lab4ict.com\r\nmyorigin = $mydomain\r\ninet_interfaces = all\r\nmydestination = $myhostname, localhost.$mydomain, localhost, $mydomain\r\nalias_maps = hash:\/etc\/aliases\r\nsetgid_group = postdrop\r\n<\/pre>\n<p>newalias\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u3001postfix\u3092\u518d\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,2]; title: ; notranslate\" title=\"\">\r\n# newaliases\r\n# systemctl restart postfix \r\n<\/pre>\n<p>mail\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u3001\u300cmailutils\u300d\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# apt install mailutils\r\n<\/pre>\n<p>mail\u30b3\u30de\u30f3\u30c9\u3067\u81ea\u30b5\u30fc\u30d0\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u306b\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3067\u304d\u308b\u304b\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# mail root@lab4ict.com\r\nCc: \r\nSubject: TEST\r\nTEST\r\n&lt;ctrl-d&gt;\r\n<\/pre>\n<p>\u30e1\u30fc\u30eb\u304c\u53d7\u4fe1\u3067\u304d\u308c\u3070\u3001OK\u3067\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# mail\r\n&quot;\/var\/mail\/root&quot;: 1 message 1 new\r\n&gt;N   1 root               Sun Jan 24 19:33  13\/415   TEST\r\n? q\r\nSaved 1 message in \/root\/mbox\r\nHeld 0 messages in \/var\/mail\/root\r\n<\/pre>\n<h2>WordPress\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\uff01<\/h2>\n<p>WordPress\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<h3>WordPress\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\uff01<\/h3>\n<p>WordPress\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3001\u5c55\u958b\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u3067\u306f\u3001\u5c55\u958b\u3057\u305fwordpress\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u300csystem\u300d\u306b\u30ea\u30cd\u30fc\u30e0\u3057\u3066\u3044\u307e\u3059\u3002\u30b5\u30a4\u30c8\u306b\u5408\u308f\u305b\u3066\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,2,3,4,5,6]; title: ; notranslate\" title=\"\">\r\n# cd \/tmp\r\n# wget http:\/\/wordpress.org\/latest.tar.gz\r\n# cd \/var\/www\/html\r\n# tar -xzvf \/tmp\/latest.tar.gz\r\n# touch \/var\/www\/html\/wordpress\/.htaccess\r\n# chown -R www-data:www-data wordpress\r\n<\/pre>\n<h3>WordPress\u7528\u306eDB\u3092\u4f5c\u6210\u3059\u308b\uff01<\/h3>\n<p>WordPress\u7528\u306eDB\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# mysql -u root -p\r\nCREATE DATABASE db01;\r\nGRANT ALL PRIVILEGES ON db01.* TO &quot;db01admin&quot;@&quot;localhost&quot; IDENTIFIED BY &quot;password&quot;;\r\nFLUSH PRIVILEGES;\r\nEXIT\r\n<\/pre>\n<h3>DocumentRoot\u3092\u8abf\u6574\u3059\u308b\uff01<\/h3>\n<p>URL\u3092\u8abf\u6574\u3059\u308b\u305f\u3081\u306b\u3001\u5fc5\u8981\u306a\u5834\u5408DocumentRoot\u3092\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,2]; title: ; notranslate\" title=\"\">\r\n# cd \/etc\/apache2\/sites-available\r\n# vi 000-default.conf\r\n...\r\n#       DocumentRoot \/var\/www\/html\r\n        DocumentRoot \/var\/www\/html\/wordpress\r\n...\r\n<\/pre>\n<p>SSL\u5316\u304c\u5b8c\u4e86\u3057\u3066\u3044\u308b\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u7de8\u96c6\u3057\u3066\u3001\u5fc5\u8981\u306a\u5834\u5408DocumentRoot\u3092\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,2]; title: ; notranslate\" title=\"\">\r\n# cd \/etc\/apache2\/sites-available\r\n# vi default-ssl.conf\r\n...\r\n        DocumentRoot \/var\/www\/html\r\n\tAlias \/wordpress \/var\/www\/html\/wordpress\r\n...\r\n<\/pre>\n<p>Apache\u3092\u518d\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# systemctl restart apache2\r\n<\/pre>\n<h3>WordPress\u306e\u521d\u671f\u8a2d\u5b9a\u3092\u884c\u3046\uff01<\/h3>\n<p>WordPress\u306e\u521d\u671f\u8a2d\u5b9a\u3092\u958b\u59cb\u3057\u307e\u3059\u3002HTTP\u306e\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306eURL\u306b\u30a2\u30af\u30bb\u30b9\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nhttp:\/\/lab4ict.com\/wordpress\/wp-admin\/install.php\r\n<\/pre>\n<p>SSL\u5316\u304c\u5b8c\u4e86\u3057\u3066\u308b\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306eURL\u306b\u30a2\u30af\u30bb\u30b9\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nhttps:\/\/lab4ict.com\/wordpress\/wp-admin\/install.php\r\n<\/pre>\n<p>\u6700\u521d\u306b\u8a00\u8a9e\uff08\u65e5\u672c\u8a9e\uff09\u3092\u9078\u629e\u3057\u3066\u3001\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3092\u958b\u59cb\u3057\u307e\u3059\u3002DB\u63a5\u7d9a\u60c5\u5831\u3068\u3057\u3066\u3001\u4e8b\u524d\u306b\u6c7a\u3081\u3066\u304a\u3044\u305f\u4ee5\u4e0b\u7b49\u306e\u5024\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<td>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u540d<\/td>\n<td>db01<\/td>\n<\/tr>\n<tr>\n<td>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30e6\u30fc\u30b6\u30fc\u540d<\/td>\n<td>db01admin<\/td>\n<\/tr>\n<tr>\n<td>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30d1\u30b9\u30ef\u30fc\u30c9<\/td>\n<td>**********<\/td>\n<\/tr>\n<tr>\n<td>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30db\u30b9\u30c8<\/td>\n<td>localhost<\/td>\n<\/tr>\n<tr>\n<td>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u63a5\u982d\u8f9e<\/td>\n<td>wp_<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u30b5\u30a4\u30c8\u306e\u60c5\u5831\u3068\u3057\u3066\u3001\u4ee5\u4e0b\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<td>\u30b5\u30a4\u30c8\u306e\u30bf\u30a4\u30c8\u30eb<\/td>\n<td>LAB4ICT<\/td>\n<\/tr>\n<tr>\n<td>\u30b5\u30a4\u30c8\u306e\u30e6\u30fc\u30b6\u30fc\u540d<\/td>\n<td>wpsusr001<\/td>\n<\/tr>\n<tr>\n<td>\u30b5\u30a4\u30c8\u306e\u30e6\u30fc\u30b6\u30fc\u306e\u30d1\u30b9\u30ef\u30fc\u30c9<\/td>\n<td>**********<\/td>\n<\/tr>\n<tr>\n<td>\u30b5\u30a4\u30c8\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9<\/td>\n<td>lab4ict@gmail.com<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4f5c\u6210\u3057\u305f\u30e6\u30fc\u30b6\u3067\u3001WordPress\u306b\u30ed\u30b0\u30a4\u30f3\u3057\u307e\u3059\u3002<\/p>\n<p>\".htaccess\"\u306b\u30d1\u30fc\u30de\u30ea\u30f3\u30af\u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u306e\u8a2d\u5b9a\u304c\u8ffd\u52a0\u3055\u308c\u305f\u304b\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# cat \/var\/www\/html\/wordpress\/.htaccess\r\n<\/pre>\n<h2>SSH\u306b\u3088\u308broot\u3067\u306e\u30ed\u30b0\u30a4\u30f3\u3092\u4e0d\u53ef\u306b\u3059\u308b\uff01<\/h2>\n<p>OpenSSH\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u5909\u66f4\u3057\u3066\u3001root\u3067\u306e\u30ed\u30b0\u30a4\u30f3\u3092\u4e0d\u53ef\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# vi \/etc\/ssh\/sshd_config\r\n...\r\n#PermitRootLogin yes\r\nPermitRootLogin no\r\n...\r\n<\/pre>\n<p>OpenSSH\u3092\u518d\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# systemctl restart sshd\r\n<\/pre>\n<p>SSH\u3067root\u3067\u30ed\u30b0\u30a4\u30f3\u4e0d\u53ef\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n# root@vmswps11\r\nroot@vmswps11's password: \r\nPermission denied, please try again.\r\n<\/pre>\n<h2>\u304a\u308f\u308a\u306b<\/h2>\n<p>OS\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5f8c\u306e\u72b6\u614b\u304b\u3089WordPress\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u884c\u3044\u3001Web\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u30b5\u30a4\u30c8\u30a2\u30af\u30bb\u30b9\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<h2>\u95a2\u9023\u8a18\u4e8b<\/h2>\n<div class=\"sc_getpost\"><a class=\"clearfix\" href=\"https:\/\/lab4ict.com\/system\/archives\/15651\" ><div class=\"sc_getpost_thumb post-box-thumbnail__wrap\"><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODdhAQABAPAAAN3d3QAAACwAAAAAAQABAAACAkQBADs=\" width=\"150\" height=\"150\" alt=\"\u3010\u8a18\u4e8b\u4e00\u89a7\u3011\u516c\u958b\u7528\u306eWordPress\u30b5\u30fc\u30d0\u3092\u69cb\u7bc9\u3059\u308b\uff01\uff08Ubuntu 20.04\uff09\" loading=\"lazy\" data-src=\"https:\/\/lab4ict.com\/system\/wp-content\/uploads\/2022\/11\/eyecatch_serverapps_01-150x150.png\" class=\"lazyload\"><\/div><div class=\"title\">\u3010\u8a18\u4e8b\u4e00\u89a7\u3011\u516c\u958b\u7528\u306eWordPress\u30b5\u30fc\u30d0\u3092\u69cb\u7bc9\u3059\u308b\uff01\uff08Ubuntu 20.04\uff09<\/div><div class=\"substr\">Ubuntu 20.04\u3067\u3001\u516c\u958b\u7528\u306eWordPress\u30b5\u30fc\u30d0\u3092\u69cb\u7bc9\u3059\u308b\u305f\u3081\u306e\u8a18\u4e8b\u4e00\u89a7\u3092\u63b2\u8f09\u3057\u307e\u3059\u3002...<\/div><\/a><\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ubuntu Server 20.04\u3092\u4f7f\u7528\u3057\u3066\u3001\u516c\u958b\u7528\u306eWordPress\u30b5\u30fc\u30d0\u3092\u69cb\u7bc9\u3057\u307e\u3059\u3002\u4f5c\u696d\u306f\u3001root\u6a29\u9650\u3092\u4f7f\u7528\u3057\u3066\u884c\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":14987,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[232],"tags":[51,366,359,543,1268],"class_list":["post-15656","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server-applications","tag-ubuntu","tag-ubuntu-desktop-20-04","tag-ubuntu-server","tag-wordpress","tag-1268"],"_links":{"self":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts\/15656","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/comments?post=15656"}],"version-history":[{"count":30,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts\/15656\/revisions"}],"predecessor-version":[{"id":15802,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts\/15656\/revisions\/15802"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/media\/14987"}],"wp:attachment":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/media?parent=15656"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/categories?post=15656"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/tags?post=15656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}