How do I install WordPress in a Lightsail instance instead of using the WordPress blueprint provided by Bitnami?
Last updated: 2021-10-25
I want to install the WordPress application in my Amazon Lightsail instance instead of using the Lightsail WordPress blueprint provided by Bitnami. How do I do that?
Amazon Lightsail provides WordPress blueprints that you can use to launch and start using the WordPress application. This WordPress application is packaged by Bitnami. Instead of using this Bitnami stack, you can install WordPress manually in your Lightsail OS instances, such as Amazon Linux 2, Ubuntu, CentOS, and so on. The following resolution covers the steps for installing WordPress in the major Linux distributions available in Lightsail.
Before you begin, be aware of the following:
- WordPress recommends using either Apache or NGINX as a preferred hosting service. The following resolution installs Apache.
- WordPress has minimum requirements for the PHP and MariaDB versions that are used for their latest packages. A minimum of PHP7.3 and MariaDB 10.2 are suggested. It's a best practice to use newer versions of these packages and to use the latest Linux distributions available in Amazon Lightsail.
For more information, see Server Environment on WordPress.org.
- The latest package and WordPress's minimum requirements are subject to change. The following resolution uses the configurations supported and recommended by WordPress as of October 2021.
- The following resolution provides the basic installation steps. You can personalize WordPress by adding plugins, modifying the OS level firewall, and so on.
For instructions on installing WordPress in Amazon Linux 2, see Host a WordPress blog on Amazon Linux 2.
Install a LAMP stack
For installing LAMP (Linux, Apache, MariaDB, and PHP) in your Lightsail instance, see How do I install a LAMP stack manually on my Lightsail instance?
Create the database and a user
WordPress is a database-oriented website. You must create a database and a user before the installing the WordPress application.
1. Run the following command to enter the MySQL shell as root:
sudo mysql -u root -p password: <insert-root-password>
Note: The password doesn't appear as you enter it so that it isn't visible to other users.
2. Create a database and user with a password, and then add privileges to the new database:
mysql> CREATE DATABASE databasename; mysql> GRANT ALL PRIVILEGES ON databasename.* TO 'wordpress_user'@'localhost' IDENTIFIED BY 'PASSWORD'; mysql> FLUSH PRIVILEGES; mysql> exit;
Note: Replace databasename with the name of the database that you want to create. Replace wordpress_user with the name of the user for WordPress. Replace PASSWORD with the desired password.
Install and configure the WordPress package
To download the latest WordPress package from the official website to the /tmp directory and extract the package to access the configuration files, do the following:
1. Download the latest WordPress package:
cd /tmp wget https://wordpress.org/latest.tar.gz
2. Run the following command to extract the package:
sudo tar -xzvf latest.tar.gz
3. Move the WordPress files to the /var/www/html directory so that they are accessible through Apache:
sudo cp -pr /tmp/wordpress/* /var/www/html/
4. Create the WordPress configuration file wp-config.php by renaming the file wp-config-sample.php:
cd /var/www/html sudo mv wp-config-sample.php wp-config.php
5. Run the following command to open the WordPress configuration file in the vi editor:
sudo vi wp-config.php
6. Add the DB credentials. The following is an example snippet:
// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', 'databasename' ); /** MySQL database username */ define( 'DB_USER', 'wordpress_user'); /** MySQL database password * define( 'DB_PASSWORD', 'PASSWORD' ); /** MySQL hostname */ define( 'DB_HOST', 'localhost' ); /** Database charset to use in creating database tables. */ define( 'DB_CHARSET', 'utf8' ); /** The database collate type. Don't change this if in doubt. */ define( 'DB_COLLATE', '' )
Note: Replace databasename, wordpress_user, and PASSWORD with the credentials that you created in the previous step.
7. Save the file by pressing esc, type :wq!, and then press ENTER.
8. (Optional) In some distributions such as Ubuntu and Debian, the Apache installation might have added a pre-existing file named index.html. This file causes conflicts with the WordPress index.php file. In this occurs, delete index.html or move it to a backup file:
$ sudo mv index.html backup_index.html
9. Restart the Apache service:
CentOS and Amazon Linux 2
$ sudo systemctl restart httpd
Ubuntu and Debian versions
$ sudo systemctl restart apache2
Verify that the port is open and listening
Port 80 is open by default when you launch a Lightsail instance. If you have SSL enabled for your website, then make sure to open port 443 so that the port is accessible over the internet. For information on adding a firewall rule to your instance, see Instance firewalls in Amazon Lightsail.
Access your instance's public IP address in your web browser, and then confirm that it goes to the page wp-admin/install.php. You can now create WP credentials in that page and then access the WordPress dashboard.
Did this article help?
Do you need billing or technical support?