<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muhammad Ehsanullah</title>
    <description>The latest articles on DEV Community by Muhammad Ehsanullah (@mehsanullahx).</description>
    <link>https://dev.to/mehsanullahx</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1853831%2F50f5c336-8371-44e4-8357-40144bf8838d.jpeg</url>
      <title>DEV Community: Muhammad Ehsanullah</title>
      <link>https://dev.to/mehsanullahx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mehsanullahx"/>
    <language>en</language>
    <item>
      <title>How to Deploy a WordPress website on AWS Cloud(Elastic Compute Cloud).</title>
      <dc:creator>Muhammad Ehsanullah</dc:creator>
      <pubDate>Fri, 11 Oct 2024 09:28:42 +0000</pubDate>
      <link>https://dev.to/mehsanullahx/how-to-deploy-a-wordpress-website-on-aws-cloudelastic-compute-cloud-3jpd</link>
      <guid>https://dev.to/mehsanullahx/how-to-deploy-a-wordpress-website-on-aws-cloudelastic-compute-cloud-3jpd</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To Deploy a WordPress website first you have to understand What is LAMP Stack? A “LAMP” stack is a group of open source software that is typically installed together in order to enable a server to host dynamic websites and web applications written in PHP. The term is an acronym which represents the Linux operating system, Apache web server, MySQL database and PHP.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;br&gt;
In order to use the AWS, you will need to have an Amazon Web Services (AWS) account.&lt;/p&gt;

&lt;p&gt;Before proceeding to the first step first click the &lt;em&gt;Security groups&lt;/em&gt; under the &lt;em&gt;Network &amp;amp; Security&lt;/em&gt;. Then a list of security groups will be opened that are already created. Click on the option &lt;em&gt;Create Security Group&lt;/em&gt; at the top right corner of screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqgzgjsftl6i6nhiyu2hv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqgzgjsftl6i6nhiyu2hv.png" alt="Image description" width="800" height="394"&gt;&lt;/a&gt;&lt;br&gt;
Fill the above information accordingly and then scroll down.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhpplmwclc8lju3ct1j5y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhpplmwclc8lju3ct1j5y.png" alt="Image description" width="800" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above Image add the inbound rules that should contain the rules listed below:&lt;br&gt;
Type- SSH    | port-22   | Source Anywhere from IPv4- 0.0.0.0/0&lt;br&gt;
Type- HTTP   | port-80   | Source Anywhere from IPv4- 0.0.0.0/0&lt;br&gt;
Type- HTTPS  | port-443  | Source Anywhere from IPv4- 0.0.0.0/0&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjtdwdgtv7ekdh9jsbvh2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjtdwdgtv7ekdh9jsbvh2.png" alt="Image description" width="800" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt;&lt;br&gt;
Search for the EC2 Service at the search bar.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxea5vhc85wd03kxb5ofc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxea5vhc85wd03kxb5ofc.png" alt="Image description" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt;&lt;br&gt;
Click on the 'Launch an instance' and enter your server name, secondly select an AMI(Amazon Machine Image) like Linux, macOs, Windows for the configuration of server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwb5w6mlk0sre3yc9de75.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwb5w6mlk0sre3yc9de75.png" alt="Image description" width="800" height="503"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt;&lt;br&gt;
Then select the instance type, this is basically the resources we will use from our cloud. Under Instance type, from the Instance type list, you can select the hardware configuration for your instance. Choose the t2.micro instance type, which is selected by default. The t2.micro instance type is eligible for the free tier. In Regions where t2.micro is unavailable, you can use a t3.micro instance under the free tier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fza5qs3hpecsxprms61ug.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fza5qs3hpecsxprms61ug.png" alt="Image description" width="800" height="296"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt;&lt;br&gt;
Under the Key pair (login) click on the link at the bottom right &lt;u&gt;create new key pair&lt;/u&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbo868o93wf9t0l39m8q3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbo868o93wf9t0l39m8q3.png" alt="Image description" width="601" height="626"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above screenshot enter the Key Pair name like 'server-name'. Then select the Encryption technique that is RSA selected by Default &amp;amp; then select the .pem format for the Key File to be downloaded locally in order to access the server locally using SSH Protocol.&lt;br&gt;
At last click the Create Key Pair. After clicking it a file will be downloaded named 'server-name.pem' it is a text file containing the RSA key.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt;&lt;br&gt;
Under the Network Settings select existing Security groups and then select that specific security group you created at the start&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft7advg6mrybxao2qhkzm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft7advg6mrybxao2qhkzm.png" alt="Image description" width="778" height="536"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6:&lt;/strong&gt;&lt;br&gt;
Then at last on the right side check the summary of your configuration of instance and after a brief check, click Launch instance. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv40zg9em63c1sp1dyd7j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv40zg9em63c1sp1dyd7j.png" alt="Image description" width="397" height="867"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It will redirect to the page where the instances are listed including your new instance. Here you wait for 2-3 minutes for the initialization of instance and verify that Instance state is &lt;strong&gt;Running&lt;/strong&gt; and status check should be &lt;strong&gt;3/3&lt;/strong&gt;. Then select the instance you created and click on the connect at the top right corner of screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj0lg139u3f7oktmeihkb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj0lg139u3f7oktmeihkb.png" alt="Image description" width="800" height="809"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to configure it online using AWS CLI you can simply click connect and a tab will opened showing the CLI for the configuration.&lt;br&gt;
But if you want to access your instance locally then go on the &lt;strong&gt;SSH client&lt;/strong&gt; tab And here copy the command under the Example and paste it in the CLI of your localhost Windows/Linux and remember one thing you should be in the directory/folder where your Security Key file is saved.&lt;/p&gt;

&lt;p&gt;I will prefer online AWS CLI for the configuration:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm9tu8r1orfwdy5ymc6h3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm9tu8r1orfwdy5ymc6h3.png" alt="Image description" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7:&lt;/strong&gt;&lt;br&gt;
Now you have install the LAMP Stack here.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Perform a quick software update on your instance:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo dnf update -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Install the latest versions of Apache web server and PHP packages for Amazon Linux 2023:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo dnf install -y httpd wget php-fpm php-mysqli php-json php php-devel

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Install the MariaDB software packages. Use the dnf install command to install multiple software packages and all related dependencies at the same time:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo dnf install mariadb105-server 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Start the Apache web server:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl start httpd

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Use the systemctl command to configure the Apache web server to start at each system boot:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl enable httpd

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Secure the MariaDB installation: After the installation, run this command to secure your MariaDB:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mysql_secure_installation

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Download WordPress: Navigate to the web root directory and download the latest version of WordPress:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd /var/www/html
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xvzf latest.tar.gz
sudo mv wordpress/* ./
sudo rm -rf wordpress latest.tar.gz
sudo chown -R apache:apache /var/www/html
sudo chmod -R 755 /var/www/html

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Create a Database for WordPress: Log in to MariaDB and create a database for WordPress:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mysql -u root -p

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Inside the MariaDB shell, run the following SQL commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE DATABASE wordpress;
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'your-password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Configure Apache: Open the Apache configuration file and add the following configuration:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /etc/httpd/conf/httpd.conf

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ensure that the DocumentRoot is set to /var/www/html.&lt;br&gt;
Modify the Directory Permissions for /var/www/html: In the httpd.conf file, look for the section that refers to /var/www/html (or you can add it if it doesn't exist):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Directory "/var/www/html"&amp;gt;
    AllowOverride All
    Require all granted
&amp;lt;/Directory&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restart Apache to apply changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl restart httpd

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Then go on the new tab and type : &lt;a href="http://here-enter-public-ip" rel="noopener noreferrer"&gt;http://here-enter-public-ip&lt;/a&gt;
Replace here-enter-public-ip with your actual public IP.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foe302jm77isphu2a6ai8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foe302jm77isphu2a6ai8.jpg" alt="Image description" width="800" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And here your wordPress is successfully deployed on your server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 8:&lt;/strong&gt;&lt;br&gt;
Update Domain and DNS Settings&lt;br&gt;
&lt;strong&gt;Point Domain to AWS:&lt;/strong&gt; If you're using a custom domain, update the DNS settings with your domain registrar:&lt;/p&gt;

&lt;p&gt;Set an A record pointing to your EC2 instance's public IP address.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 9:&lt;/strong&gt;&lt;br&gt;
Secure Your Website with SSL (Optional), So that it can be accessible at HTTPS.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install Certbot for SSL: Install Certbot, which is a tool to easily set up SSL for your site:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo yum install -y certbot python2-certbot-apache

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Obtain an SSL Certificate: Run Certbot to obtain an SSL certificate:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo certbot --apache -d yourdomain.com

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Test SSL Auto-Renewal: Certbot automatically renews SSL certificates, but you can test it by running:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo certbot renew --dry-run

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the End Test Your Website&lt;br&gt;
Visit Your Site: Navigate to your domain or your EC2 instance's public IP address. Your website should now be live and functional.&lt;br&gt;
Check SSL (if applied): If you installed SSL, ensure that your site is accessible via https://.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>cloudcomputing</category>
      <category>devops</category>
      <category>wordpress</category>
    </item>
  </channel>
</rss>
