Home » Php » php – Change Apache directory to show WordPress homepage

php – Change Apache directory to show WordPress homepage

Posted by: admin February 25, 2020 Leave a comment

Questions:

I have WordPress installed using an AWS EC2 instance. The public IP is as here. I used LetsEncrypt to get SSL, that worked fine. But after that, my homepage now shows the ‘Apache2 Ubuntu Default Page’. It should be showing me the WordPress homepage. I still have ssh access to the EC2 (Bitnami WordPress), so my data is supposedly still there.

I’ve been doing some research at it seems that I need to change something with Apache so it direct to the WordPress directory/page.

Any help in the matter would be most appreciated 🙂

How to&Answers:

The fact that you’re getting the Apache default page is a good sign, it means everything from a networking standpoint is working correctly. Now, you just need to show Apache where to serve your files.

Apache stores their default configuration typically in /etc/httpd/httpd.conf or /etc/apache2/sites-available/default and looks something like below.

<VirtualHost *:80>
        ServerAdmin [email protected]

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

Before making changes to this file (whenever you find it), you will also need to know where the DocumentRoot is. This is essentially the directory that your index.php is located. In the example above it’s located in /var/www, and that’s typically a good place to start looking.

If you’re having a hard time finding your root directory, you can do something like find / -type f -name "index.php".

Assuming your index.php is in /var/www/wordpress your configuration could look as simple as this.

<VirtualHost *:80>
        ServerAdmin [email protected]
        ServerName example.com
        ServerAlias www.example.com
        DocumentRoot /var/www/wordpress
</VirtualHost>

Answer:

Bitnami Engineer here,

It seems you installed the Apache2 system’s service in the machine and it got started at boot time. The Bitnami apps don’t use the system’s services. That’s why the Bitnami’s Apache service can’t be started because other service is already running in the 80 port. In order to stop and disable it, please run these commands

sudo service apache2 stop
sudo service apache2 disable
sudo /opt/bitnami/ctlscript.sh start apache

Happy to help!