{"id":3073,"date":"2019-05-04T02:55:58","date_gmt":"2019-05-04T02:55:58","guid":{"rendered":"https:\/\/robertjwallace.com\/\/\/?p=3073"},"modified":"2019-05-05T16:10:13","modified_gmt":"2019-05-05T16:10:13","slug":"setting-up-wordpress-on-aws","status":"publish","type":"post","link":"https:\/\/robertjwallace.com\/es\/setting-up-wordpress-on-aws\/","title":{"rendered":"Setting up WordPress on AWS"},"content":{"rendered":"<p>I just setup WordPress on Amazons EC2 service.  I didn&#8217;t find a good set of instructions on how to do it, but pieced together the following from various sources.  Note that my PC is Linux based.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Set up an Amazon EC2 account<\/h2>\n\n\n\n<p>Go to https:\/\/aws.amazon.com\/ and click on the signup button on the upper right of the screen.  Fill out the forms to create an account.  Select the free plan. After verifying your account (Amazon sends you an SMS message) you can then use the &#8220;My Account&#8221; drop-down menu to access the management console, or go to https:\/\/signin.aws.amazon.com\/ to sign in.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" data-src=\"https:\/\/robertjwallace.com\/\/\/wp-content\/uploads\/2019\/05\/awsconsole.png\" alt=\"\" class=\"wp-image-3081 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">AWS EC2<\/h2>\n\n\n\n<p>Now you are going to setup a virtual server that will be where you install WordPress.  Find the &#8220;Launch a virtual machine&#8221; link and click on it. Then in step one, select the Amazon Linux 2 AMI.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" data-src=\"https:\/\/robertjwallace.com\/\/\/wp-content\/uploads\/2019\/05\/awsami.png\" alt=\"\" class=\"wp-image-3082 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>Select the free tier instance.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"430\" height=\"199\" data-src=\"https:\/\/robertjwallace.com\/\/\/wp-content\/uploads\/2019\/05\/awsfreetier.jpg\" alt=\"\" class=\"wp-image-3075 lazyload\" data-srcset=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2019\/05\/awsfreetier.jpg 430w, https:\/\/robertjwallace.com\/wp-content\/uploads\/2019\/05\/awsfreetier-300x139.jpg 300w\" data-sizes=\"(max-width: 430px) 100vw, 430px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 430px; --smush-placeholder-aspect-ratio: 430\/199;\" \/><\/figure>\n\n\n\n<p>and click the &#8220;Review and Launch&#8221; button, and then click the &#8220;Launch&#8221; button.  You will next create a key pair for security.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"683\" height=\"508\" data-src=\"https:\/\/robertjwallace.com\/\/\/wp-content\/uploads\/2019\/05\/awsssl.jpg\" alt=\"\" class=\"wp-image-3076 lazyload\" data-srcset=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2019\/05\/awsssl.jpg 683w, https:\/\/robertjwallace.com\/wp-content\/uploads\/2019\/05\/awsssl-300x223.jpg 300w\" data-sizes=\"(max-width: 683px) 100vw, 683px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 683px; --smush-placeholder-aspect-ratio: 683\/508;\" \/><\/figure>\n\n\n\n<p>Use the drop-down to create a new pair and then give the key pair an easy name to remember.  Click the &#8220;Download key pair&#8221; button and save the downloaded .pem file to a location you can remember on your system. <\/p>\n\n\n\n<p>The click the &#8220;Launch Instances&#8221; button.<\/p>\n\n\n\n<p>You should now have a running virtual Linux machine.  The next steps are to SSH into it and begin to install the software. You need to identify the IP address of your instance.  Select the instance in the AWS Management Console, and look for the IPv4 Public IP in the instance description (bottom part of the screen).<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1031\" height=\"448\" data-src=\"https:\/\/i0.wp.com\/robertjwallace.com\/wp-content\/uploads\/2019\/05\/aswip.jpg?fit=960{f21b2e9c886449ccfd883f06fb77471a0806c5f3cb16ac6af4e8bda5ea93c311}2C417\" alt=\"\" class=\"wp-image-3077 lazyload\" data-srcset=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2019\/05\/aswip.jpg 1031w, https:\/\/robertjwallace.com\/wp-content\/uploads\/2019\/05\/aswip-300x130.jpg 300w, https:\/\/robertjwallace.com\/wp-content\/uploads\/2019\/05\/aswip-768x334.jpg 768w, https:\/\/robertjwallace.com\/wp-content\/uploads\/2019\/05\/aswip-1024x445.jpg 1024w\" data-sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1031px; --smush-placeholder-aspect-ratio: 1031\/448;\" \/><\/figure>\n\n\n\n<p>I use Putty for an SSH client.   You can also use your Linux terminal with ssh.  These instructions are for setting up Putty.  If you click on your instance in the aws management console, then click on the Connect button you can get the instructions for using ssh in a terminal window.<\/p>\n\n\n\n<p>First you need to convert the .pem key file to a format Putty can use: .ppk.  I used puttygen to that.  Instructions install puttygen are at<a rel=\"noreferrer noopener\" aria-label=\" https:\/\/tecadmin.net\/convert-ppk-to-pem-using-command\/. (opens in a new tab)\" href=\"https:\/\/tecadmin.net\/convert-ppk-to-pem-using-command\/\" target=\"_blank\"> https:\/\/tecadmin.net\/convert-ppk-to-pem-using-command\/.<\/a>  Ignore the part describing the conversion from ppk to pem since you need to convert the other direction.  To create the ppk file use the following format:<\/p>\n\n\n\n<p><strong><em>puttygen robertjwallace.pem -o robertjwallace.ppk<\/em><\/strong><\/p>\n\n\n\n<p>replacing &#8220;robertjwallace&#8221; with the name you gave you key file.<\/p>\n\n\n\n<p>Run Putty and on the Session screen enter the Public IP address for the virtual server.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" data-src=\"https:\/\/robertjwallace.com\/\/\/wp-content\/uploads\/2019\/05\/awsputty1.jpg\" alt=\"\" class=\"wp-image-3079 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>Then using the SSH\/Auth menu in Putty, browse to your .ppk file and select it.  Then go back to the main Putty session screen and type in a profile name and save it for future use.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"554\" height=\"354\" data-src=\"https:\/\/robertjwallace.com\/\/\/wp-content\/uploads\/2019\/05\/awssaveputty.jpg\" alt=\"\" class=\"wp-image-3078 lazyload\" data-srcset=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2019\/05\/awssaveputty.jpg 554w, https:\/\/robertjwallace.com\/wp-content\/uploads\/2019\/05\/awssaveputty-300x192.jpg 300w\" data-sizes=\"(max-width: 554px) 100vw, 554px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 554px; --smush-placeholder-aspect-ratio: 554\/354;\" \/><\/figure>\n\n\n\n<p>Now click the &#8220;Open&#8221; button in Putty to launch the SSL client.  The login name is &#8220;ec2-user&#8221; with no password.<\/p>\n\n\n\n<p>The first thing you should do is setup a password for ec2-user.  Use the following command:<\/p>\n\n\n\n<p><strong><em>sudo passwd ec2-user<\/em><\/strong><\/p>\n\n\n\n<p>You will be prompted for a new password.  Note that no characters will be echo&#8217;d back as you type in the password. <br><\/p>\n\n\n\n<p>You now have a running instance of a Linux VM.  The next steps are to install the software you will need.  The software you will install are: <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Apache2<\/li><li>PHP<\/li><li>mariadb<\/li><li>WordPress<\/li><\/ul>\n\n\n\n<p>In addition, you need to configure the Linux VM for FTP access.<\/p>\n\n\n\n<p>In your Putty session you are going to use the Linux command yum to install software.  <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Install LAMP<\/h3>\n\n\n\n<p>To install LAMP, type:<\/p>\n\n\n\n<p><strong><em>sudo yum update<\/em><\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><br><code><strong><em>sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2<\/em><\/strong><\/code><strong><em><br><br><\/em><\/strong><code><strong><em>sudo yum install -y httpd mariadb mariadb-server<\/em><\/strong><\/code><\/p>\n\n\n\n<p>Start the Apache Web Server:<br><code><strong><em>sudo systemctl start httpd<\/em><\/strong><\/code><\/p>\n\n\n\n<p>Create a page to test your PHP installation:<br><strong><em>cd \/var\/www\/html<br>sudo vi test.php<\/em><\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Type <strong>i<\/strong> to start the insert mode<\/li><li>Type <strong>&lt;?php phpinfo() ?&gt;<\/strong><\/li><li>Press esc to exit insert mode<\/li><li>Type <strong>:wq<\/strong> to write the file and quit vi<\/li><\/ol>\n\n\n\n<p>Before you can test the server you will need to allow http access to the VM. In the aws management console, select your instance and go down to the description area and click on the security group name.  In my case the name is &#8220;launch-wizard-3.&#8221;<\/p>\n\n\n\n<p>Click on the Add Rule button and select http from the drop-down list, then click on the save button.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" data-src=\"https:\/\/robertjwallace.com\/\/\/wp-content\/uploads\/2019\/05\/awsaddrule.png\" alt=\"\" class=\"wp-image-3084 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" data-src=\"https:\/\/robertjwallace.com\/\/\/wp-content\/uploads\/2019\/05\/awshttp.png\" alt=\"\" class=\"wp-image-3083 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>Then click on the Inbound tab and click on the Edit button.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" data-src=\"https:\/\/robertjwallace.com\/\/\/wp-content\/uploads\/2019\/05\/awshttp-1.png\" alt=\"\" class=\"wp-image-3085 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>Open a browser and access test.php to test your PHP installation: <a href=\"http:\/\/coenraets.org\/blog\/2012\/01\/setting-up-wordpress-on-amazon-ec2-in-5-minutes\/\">http:\/\/ec2-50-17-14-16.compute-1.amazonaws.com\/test.php<\/a> (Use your actual public DNS name or IP address).  <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 6: start mariadb<\/h3>\n\n\n\n<p>Start MySQL:<br><strong><em>sudo service mariadb start<\/em><\/strong><\/p>\n\n\n\n<p>Create your \u201cblog\u201d database:<br><strong><em>sudo mysqladmin -uroot create blog<\/em><\/strong><\/p>\n\n\n\n<p>Secure your database:<br><strong><em>cd \/usr\/bin<br>mysql_secure_installation<\/em><\/strong><\/p>\n\n\n\n<p>Answer the wizard questions as follows:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Enter current password for root: Press return for none<\/li><li>Change Root Password: Y<\/li><li>New Password: Enter your new password<\/li><li>Remove anonymous user: Y<\/li><li>Disallow root login remotely: Y<\/li><li>Remove test database and access to it: Y<\/li><li>Reload privilege tables now: Y<\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Step 7: Install WordPress<\/h3>\n\n\n\n<p>To install WordPress, type:<br><strong>cd \/var\/www\/html<br>sudo  wget http:\/\/wordpress.org\/latest.tar.gz<br>sudo tar -xzvf latest.tar.gz<br> <\/strong><\/p>\n\n\n\n<p>This will uncompress WordPress in its own \u201cwordpress\u201d directory. If you want to rename the directory do the following:<br><strong>sudo mv wordpress blog<\/strong><\/p>\n\n\n\n<p>Create the WordPress wp-config.php file: <br><strong>cd blog<br>sudo mv wp-config-sample.php wp-config.php<br>sudo vi wp-config.php<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Type <strong>i<\/strong> to start insert mode.<\/li><li>Modify the database connection parameters as follows:<br>\n<strong>define(\u2018DB_NAME\u2019, \u2018blog\u2019);<br>\ndefine(\u2018DB_USER\u2019, \u2018root\u2019);<br>\ndefine(\u2018DB_PASSWORD\u2019, \u2018YOUR_PASSWORD\u2019);<br>\ndefine(\u2018DB_HOST\u2019, \u2018localhost\u2019);<\/strong>\n<\/li><li>Type <strong>:wq<\/strong> to write the file and quit vi<\/li><\/ol>\n\n\n\n<p>Open a Browser and access your blog: <a href=\"http:\/\/coenraets.org\/blog\/2012\/01\/setting-up-wordpress-on-amazon-ec2-in-5-minutes\/\">http:\/\/ec2-50-17-14-16.compute-1.amazonaws.com\/blog<\/a> (Use your actual public DNS name). This should trigger the WordPress configuration process.<\/p>\n\n\n\n<p>Finally, setup WordPress to allow FTP access so you can add and delete plugins and upload images.<\/p>\n\n\n\n<p>Go back to AWS and add a new rule for FTP.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" data-src=\"https:\/\/robertjwallace.com\/\/\/wp-content\/uploads\/2019\/05\/awsftp-1.png\" alt=\"\" class=\"wp-image-3089 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>Edit your aws instance&#8217;s Inbound rules and add two custom rules as shown above.<\/p>\n\n\n\n<p><strong>To fix file permissions for the Apache web server<\/strong><\/p>\n\n\n\n<p>Some of the available features in WordPress require write access to the Apache  document root (such as uploading media though the Administration screens). If you  have not already done so, apply the following group memberships and permissions.                      <\/p>\n\n\n\n<p>Grant file ownership of <code>\/var\/www<\/code> and its contents to the<code>apache<\/code> user.  <\/p>\n\n\n\n<p><code><strong><code class=\"\"><em>sudo chown -R apache \/var\/www<\/em><\/code><\/strong><\/code><em>                            <\/em><\/p>\n\n\n\n<p>Change the directory permissions of <code>\/var\/www<\/code> and its                               sub-directories to add group write permissions and to set the group ID on future sub-directories.  <\/p>\n\n\n\n<p><code><strong><code class=\"\"><em>sudo chmod 2775 \/var\/www<\/em><\/code><\/strong> <\/code><\/p>\n\n\n\n<p><code><strong><code class=\"\"><em>find \/var\/www -type d -exec sudo chmod 2775 {} \\;<\/em><\/code><\/strong><\/code>                            <\/p>\n\n\n\n<p>Recursively change the file permissions of <code>\/var\/www<\/code> and its sub-directories to add group write permissions.    <\/p>\n\n\n\n<p><code><strong><code class=\"\"><em>find \/var\/www -type f -exec sudo chmod 0664 {} \\;<\/em><\/code><\/strong><\/code><em>      <\/em>                      <\/p>\n\n\n\n<p> Restart the Apache web server to pick up the new group and permissions.                                                        <\/p>\n\n\n\n<p><code><strong><code class=\"\"><em>sudo systemctl restart httpd<\/em><\/code><\/strong><\/code><em>     <\/em>                             <\/p>\n\n\n\n<p>You should now be able to login to your WordPress site and upload images, plugins, and themes.<br><\/p>","protected":false},"excerpt":{"rendered":"<p>I just setup WordPress on Amazons EC2 service. I didn&#8217;t find a good set of instructions on how to do it, but pieced together the following from various sources. Note that my PC is Linux based.<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_eb_attr":"","footnotes":""},"categories":[143],"tags":[],"class_list":["post-3073","post","type-post","status-publish","format-standard","hentry","category-computer-stuff"],"featured_image_src":null,"featured_image_src_square":null,"author_info":{"display_name":"Bob","author_link":"https:\/\/robertjwallace.com\/es\/author\/admin\/"},"_links":{"self":[{"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/posts\/3073","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/comments?post=3073"}],"version-history":[{"count":7,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/posts\/3073\/revisions"}],"predecessor-version":[{"id":3114,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/posts\/3073\/revisions\/3114"}],"wp:attachment":[{"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/media?parent=3073"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/categories?post=3073"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/tags?post=3073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}