Search code examples
wordpressamazon-web-servicesubuntuamazon-ec2http-status-code-504

WordPress website is not properly working on AWS EC2 ubuntu instance


We have a WordPress blog website that only consists of 50 posts, and we just hosted the website on an AWS EC2 Ubuntu instance. The website was working fine for some time, but after some time the website went down and gave 504 Gateway errors!

AWS Spec:- Region: Virginia (us-east-1b) Type: t2.micro SSD: 8 GB

The WordPress website has a DB size of 3 MB when it is compressed and a file size of 150 MB when compressed. The website is hosted on the LAMP stack on Ubuntu AWS. The website is not working properly.

We installed all the stacks (Apache, MySQL, and phpMyAdmin) manually. However, the site is not working properly. It worked for a short time when it was hosted, but after that, it is giving 504 errors! We need the website to work fine and properly.

Does anyone know a solution to fix this issue or how to solve it? Did we do anything wrong? Please let us know!

Thank you in advance

We changed the ownership of the var/www/html/ folder to www-data and added a new site config file (WordPress.conf) with the below code and enabled it after disabling the default "000-defualt.conf" file.

<VirtualHost *:80>
ServerAdmin webmaster@your_domain.com
DocumentRoot /var/www/html
ServerName 0.0.0.0(Public IP)
ServerAlias www.your_domain.com

<Directory /var/www/html/>
    Options FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

Solution

  • We fixed the issue by upgrading the server to the next level. Initially, we hosted the website on a t2.micro EC2 instance, and the site was not working properly at that time. It only works fine for the first 10–20 minutes after hosting the website, and after that, the site will go down with a timeout, gateway error, or server error. Then we considered upgrading the EC2 instance to the next level, which is t2.small, and now everything works fine till today without any timeout, gateway, or server errors. You can check the specs of each EC2 instance below. Our website needed t2.small specs to work properly, and it is working fine now. PFAAWS EC2 Instance types

    You can check different types of EC2 Instances from the below URL

    AWS EC2 All Instance Types

    Thank you