<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>OracleCloud  |  塞翁失馬</title>
	<atom:link href="https://hbirds.mydns.jp/tag/oraclecloud/feed/" rel="self" type="application/rss+xml" />
	<link>https://hbirds.mydns.jp</link>
	<description>禍福は糾える縄の如し</description>
	<lastBuildDate>Mon, 26 Dec 2022 10:48:38 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.2</generator>

<image>
	<url>https://hbirds.mydns.jp/wp-content/uploads/2022/12/cropped-akaza-32x32.png</url>
	<title>OracleCloud  |  塞翁失馬</title>
	<link>https://hbirds.mydns.jp</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>OCIでWordPressサイト構築</title>
		<link>https://hbirds.mydns.jp/oci%e3%81%a7wordpress%e3%82%b5%e3%82%a4%e3%83%88%e6%a7%8b%e7%af%89/</link>
		
		<dc:creator><![CDATA[hbirds]]></dc:creator>
		<pubDate>Wed, 21 Dec 2022 20:39:49 +0000</pubDate>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[ORACLE]]></category>
		<category><![CDATA[OracleCloud]]></category>
		<guid isPermaLink="false">http://hbirds.mydns.jp/?p=46</guid>

					<description><![CDATA[OCIでwordpressサイトを構築してみた際のメモ]]></description>
										<content:encoded><![CDATA[
<p>Create compute instance</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="873" height="203" src="https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-21-04-04-40.png" alt="" class="wp-image-47" srcset="https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-21-04-04-40.png 873w, https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-21-04-04-40-300x70.png 300w, https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-21-04-04-40-768x179.png 768w" sizes="(max-width: 873px) 100vw, 873px" /></figure>



<p>以上の画面からEditをクリック</p>



<p>次のパブリックIPが設定された　168.138.40.123</p>



<p>usernameは、ubuntuになっている。</p>



<p>秘密鍵をノートPCのhomeディレクトリにコピーしてchmod 0600でパーミッション変更して次のコマンドでアクセス</p>



<pre class="wp-block-code"><code>hbirds@hbirds-Lenovo-G580:~$　ssh -p 22 ubuntu@168.138.40.123 -i ssh-key-2022-12-20.key</code></pre>



<p>/etc/hostname と /etc/hosts の確認</p>



<p>ubuntu@instance-20221221-0718:~$ cat /etc/hostname<br>instance-20221221-0718</p>



<p>ubuntu@instance-20221221-0718:~$ cat /etc/hosts<br>127.0.0.1 localhost</p>



<p>#The following lines are desirable for IPv6 capable hosts<br>::1 ip6-localhost ip6-loopback<br>fe00::0 ip6-localnet<br>ff00::0 ip6-mcastprefix<br>ff02::1 ip6-allnodes<br>ff02::2 ip6-allrouters<br>ff02::3 ip6-allhosts<br>127.0.1.1 instance-20221221-0431 instance-20221221-0431</p>



<p>UFWは使ってはいけない。</p>



<p>iptables と管理画面からConpute&gt;instances&gt;<a class="" href="https://cloud.oracle.com/compute/instances/ocid1.instance.oc1.ap-osaka-1.anvwsljrmhn225icgxxvvmqmfxrn3khykpvib5mveix33mgaukltlwtmmtza">instance-20221221-0718</a>&gt;<strong>Virtual cloud network:</strong>&nbsp;<a class="" href="https://cloud.oracle.com/networking/vcns/ocid1.vcn.oc1.ap-osaka-1.amaaaaaamhn225ianvln5eue276iop3wa6cmukwcq7qps5gtn2o7v2eaqs6a">vcn-20221221-0719</a>&gt;Security Lists(1)&gt;subnet-20221221-0719&gt;<a class="" href="https://cloud.oracle.com/networking/vcns/ocid1.vcn.oc1.ap-osaka-1.amaaaaaamhn225ianvln5eue276iop3wa6cmukwcq7qps5gtn2o7v2eaqs6a/security-lists/ocid1.securitylist.oc1.ap-osaka-1.aaaaaaaadt6g4a5zrzi2nzrilpxwwtxomqvrjy7ecynjs7gyykofcizgxd3q">Default Security List for vcn-20221221-0719</a>&gt;Add Ingress Rulesで、以下のようにIngress Ruleを追加する。</p>



<figure class="wp-block-image size-full"><img decoding="async" width="867" height="444" src="https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-21-14-02-24.png" alt="" class="wp-image-53" srcset="https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-21-14-02-24.png 867w, https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-21-14-02-24-300x154.png 300w, https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-21-14-02-24-768x393.png 768w" sizes="(max-width: 867px) 100vw, 867px" /></figure>



<p>/etc/nginx/sites-available/defaut は、以下の通り。とりあえずSSLは後回しにした。</p>



<pre class="wp-block-code"><code>##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or WordPress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
	listen 80 default_server;
	listen &#91;::]:80 default_server;

	# SSL configuration
	#
	# listen 443 ssl default_server;
	# listen &#91;::]:443 ssl default_server;
	#
	# Note: You should disable gzip for SSL traffic.
	# See: https://bugs.debian.org/773332
	#
	# Read up on ssl_ciphers to ensure a secure configuration.
	# See: https://bugs.debian.org/765782
	#
	# Self signed certs generated by the ssl-cert package
	# Don't use them in a production server!
	#
	# include snippets/snakeoil.conf;

	root /var/www/html;

	# Add index.php to the list if you are using PHP
	index index.html index.htm index.nginx-debian.html;

	server_name _;

	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		try_files $uri $uri/ =404;
	}

	# pass PHP scripts to FastCGI server
	#
	#location ~ \.php$ {
	#	include snippets/fastcgi-php.conf;
	#
	#	# With php-fpm (or other unix sockets):
	#	fastcgi_pass unix:/run/php/php7.4-fpm.sock;
	#	# With php-cgi (or other tcp sockets):
	#	fastcgi_pass 127.0.0.1:9000;
	#}

	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#
	#location ~ /\.ht {
	#	deny all;
	#}
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#	listen 80;
#	listen &#91;::]:80;
#
#	server_name example.com;
#
#	root /var/www/example.com;
#	index index.html;
#
#	location / {
#		try_files $uri $uri/ =404;
#	}
#}

server {
    server_name hbirds.ddns.net;
    root /var/www/html/wordpress;
    index  index.php index.html index.htm;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    client_max_body_size 100M;
    location ~ \.php$ {
         include snippets/fastcgi-php.conf;
         fastcgi_pass unix:/var/run/php/php-fpm.sock;
#         fastcgi_pass unix:/run/php/php8.1-fpm.sock 
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         include fastcgi_params;
    }
#    listen &#91;::]:443 ssl ipv6only=on; # managed by Certbot
#    listen 443 ssl; # managed by Certbot
#    ssl_certificate /etc/letsencrypt/live/techlog.mydns.jp/fullchain.pem; # managed by Certbot
#    ssl_certificate_key /etc/letsencrypt/live/techlog.mydns.jp/privkey.pem; # managed by Certbot
#    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
#    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

#server {
#    if ($host = hbirds.ddns.net) {
#        return 301 https://$host$request_uri;
#    } # managed by Certbot
#        listen 80 ;
#        listen &#91;::]:80 ;
#    server_name hbirds.ddns.net;
#    return 404; # managed by Certbot
#}</code></pre>



<p>ブラウザでhttp://168.138.40.123にアクセスすると</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-21-13-48-09-1024x525.png" alt="" class="wp-image-52" width="646" height="331" srcset="https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-21-13-48-09-1024x525.png 1024w, https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-21-13-48-09-300x154.png 300w, https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-21-13-48-09-768x394.png 768w, https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-21-13-48-09.png 1366w" sizes="(max-width: 646px) 100vw, 646px" /></figure>



<pre class="wp-block-code"><code>sudo apt install -y mariadb-server mariadb-client
sudo systemctl start mariadb
sudo systemctl enable mariadb</code></pre>



<p>ubuntu@instance-20221221-0718:~$ sudo mysql -u root -p<br>Enter password:<br>Welcome to the MariaDB monitor. Commands end with ; or \g.<br>Your MariaDB connection id is 31<br>Server version: 10.6.11-MariaDB-0ubuntu0.22.04.1 Ubuntu 22.04</p>



<p>Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.</p>



<p>Type &#8216;help;&#8217; or &#8216;\h&#8217; for help. Type &#8216;\c&#8217; to clear the current input statement.</p>



<p>MariaDB [(none)]&gt; CREATE DATABASE wordpress;<br>Query OK, 1 row affected (0.000 sec)</p>



<p>MariaDB [(none)]&gt; CREATE USER &#8216;wordpress&#8217; IDENTIFIED BY &#8216;ZQAHLLOL&#8217;;<br>Query OK, 0 rows affected (0.002 sec)</p>



<p>MariaDB [(none)]&gt; GRANT ALL ON wordpress.* TO &#8216;wordpress&#8217; WITH GRANT OPTION;<br>Query OK, 0 rows affected (0.001 sec)</p>



<p>MariaDB [(none)]&gt; FLUSH PRIVILEGES;<br>Query OK, 0 rows affected (0.000 sec)</p>



<p>MariaDB [(none)]&gt; EXIT<br>Bye</p>



<ul class="wp-block-list">
<li>DATABASE：wordpress</li>



<li>USER：wordpress</li>



<li>PASSWORD：ZQAHLLOL</li>
</ul>



<p>sudo apt install -y php-dom php-simplexml php-ssh2 php-xml php-xmlreader php-curl php-exif php-ftp php-gd php-iconv php-imagick php-json php-mbstring php-posix php-sockets php-tokenizer php-fpm php-mysql php-gmp php-intl php-cli</p>



<pre class="wp-block-code"><code>sudo nano /etc/php/8.1/fpm/php.ini</code></pre>



<pre class="wp-block-code"><code>upload_max_filesize = 100M←変更
memory_limit = 256M←変更
max_execution_time = 360　←変更
date.timezone = Asia/Tokyo←変更</code></pre>



<pre class="wp-block-code"><code>sudo systemctl restart php*-fpm.service</code></pre>



<p>sudo nano /etc/nginx/sites-available/default</p>



<p>http://hbirds.ddns.net/wp-admin/setup-config.php にアクセスして以下のようにwordpressのインストール画面が表示できた。</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="525" src="https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-22-05-36-35-1024x525.png" alt="" class="wp-image-76" srcset="https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-22-05-36-35-1024x525.png 1024w, https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-22-05-36-35-300x154.png 300w, https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-22-05-36-35-768x394.png 768w, https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-22-05-36-35.png 1366w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>ブラウザで http://hbirds.ddns.net にアクセスすると以下のようにサンプルページが表示できた。</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="525" src="https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-22-06-35-37-1024x525.png" alt="" class="wp-image-78" srcset="https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-22-06-35-37-1024x525.png 1024w, https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-22-06-35-37-300x154.png 300w, https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-22-06-35-37-768x394.png 768w, https://hbirds.mydns.jp/wp-content/uploads/2022/12/Screenshot-from-2022-12-22-06-35-37.png 1366w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>次にSSL化に取り組みます。</p>



<pre class="wp-block-code"><code>sudo apt install certbot python3-certbot-nginx</code></pre>



<pre class="wp-block-code"><code>ubuntu@instance-20221221-0718:~$ sudo certbot
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): hbirds1104@gmail.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at

<a rel="noopener" href="https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf." title="404 Page not found -  Let&#039;s Encrypt" class="blogcard-wrap external-blogcard-wrap a-wrap cf" target="_blank"><div class="blogcard external-blogcard eb-left cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img loading="lazy" decoding="async" src="https://s.wordpress.com/mshots/v1/https%3A%2F%2Fletsencrypt.org%2Fdocuments%2FLE-SA-v1.3-September-21-2022.pdf.?w=160&#038;h=99" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="99" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">404 Page not found -  Let&#39;s Encrypt</div><div class="blogcard-snippet external-blogcard-snippet">Let&#039;s Encrypt is a free, automated, and open certificate authority brought to you by the nonprofit I...</div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf." alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">letsencrypt.org</div></div></div></div></a> You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: N
Account registered.

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: hbirds.ddns.net
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 
Requesting a certificate for hbirds.ddns.net

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/hbirds.ddns.net/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/hbirds.ddns.net/privkey.pem
This certificate expires on 2023-03-21.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

Deploying certificate
Successfully deployed certificate for hbirds.ddns.net to /etc/nginx/sites-enabled/default
Congratulations! You have successfully enabled HTTPS on https://hbirds.ddns.net

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
</code></pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
