This tutorial assumes you have created the Amazon Linux 2 instance with an operational web server that has PHP and databases (either MySQL or MariaDB) support. Follow the steps listed in Installing LAMP with Amazon Linux for Installing the LAMP application on Amazon Linux 2 for Amazon Linux 2. This tutorial also provides steps to configure the security group to permit traffic through HTTP, HTTPS traffic, and HTTPS traffic, as well as a few steps to make sure that permissions to files are correctly set on your server. To learn more about the addition of the rules for your group to be added, refer to add rules to the security group.
We suggest you connect the Elastic IP address (EIP) to the WordPress instance that you are using to host your WordPress blog. This will prevent the publicly accessible DNS address of your blog from changing and causing problems with the installation. If you are the owner of a domain and want to use it to host your blog, you are able to change the DNS entry for that domain’s name so it will connect to the EIP address (for assistance, ask your domain name’s registrar). You can get one EIP address linked to a running instance for free cost. For more details, visit EIP addresses that are elastic.
If you don’t have a domain name registered for your blog, you may create a domain with Route 53 and link your account’s EIP address to your domain’s name. For more details, refer to the process of registering domain names with Amazon Route 53 in the Amazon Route 53 Developer Guide.
Install WordPress
Option: Follow this tutorial by automating
To finish this tutorial, you must use AWS Systems Manager Automation in lieu of other tasks to start the automation script.
Connect to your WordPress instance and install your WordPress Installation package.
Download and extract the WordPress installation package.
- Download the most recent WordPress installation package by using the WGET command. The following command must always download the most current version of WordPress.
- [ec2-user ~]$ wget https://wordpress.org/latest.tar.gz
- Unzip and dearchive your installation file. The installation folder has been unzipped to a folder named WordPress.
- [ec2-user ~]$ tar -xzf latest.tar.gz
Create a database user and database that you can use for your WordPress installation.
Your WordPress installation should be able to save information, such as blog posts and user-generated comments and user comments, in databases. This method helps you create your blog’s database as well as users who are authorized to read and save data to it.
- Create the Database Server.
- [ec2-user ~]$ sudo systemctl start mariadb
- Log into your database’s server using the user named root user. Input the password for the database root password when asked for it, and it could be different from the password for your root account password. Or even be blank if you did not secure the database server.
- If you haven’t secured your database server in the past, it is imperative to do it. For more information, go to How to connect the MariaDB server (Amazon Linux 2).
- [ec2-user”$ mysql root -u –p
- Create a password and user to access the MySQL database. Your WordPress installation makes use of these values to connect to your MySQL database.
- Be sure to make a secure password to protect your account. Don’t use the one quotation mark ( ‘ ) in your password, as it will make it impossible to execute the command before it. For more information about creating a secure password, go to http://www.pctools.com/guides/password/. Don’t reuse an existing password, and be sure that you save your password in a safe place.
- Use the command below to replace an individual username and password.
- CREATE USER ‘wordpress-user’@’localhost’ IDENTIFIED BY ‘your_strong_password’;
- Create your database. Make sure that your database has a clear and meaningful name, for example, WordPress-DB.
- The punctuation marks around the database’s name within the below command are referred to as backticks. A backtick ( `) key is normally situated over that of the tab keys on a normal keyboard. Backticks do not have to be used all the time. However, they do allow users to use unconstitutional characters, like hyphens in database names.
- CREATE A DATABASE wordpress-db;
- You can grant full privileges to your WordPress database for the WordPress user you created earlier.
- All privileges are granted on WordPress-db. * TO “wordpress-user”@”localhost”;
- Cleanse the database to take in all your modifications.
- FLUSH PRIVILEGES;
- It would help if you exited your MySQL client.
- Exit
To edit and create the wp-config.php file.
The WordPress installation folder contains a sample configuration file called wp-config-sample.php. This is how you can copy the file and modify it to match the specific configuration you want to use.
- Transfer the wp-config-sample.php file to the file wp-config.php. This creates a brand new configuration file while keeping the original sample file for backup.
- [ec2-user ~]$ cp wordpress/wp-config-sample.php wordpress/wp-config.php
- Modify this wp-config.php file with the editor you prefer (such as Vim, Nano, or vim) and input the appropriate details for your installation. If you don’t have a text editor you like, Nano is ideal for novices.
- [ec2-user ~]$ nano wordpress/wp-config.php
- Look for the section that describes the term DB_NAME and then change the name of your database here to the name of the database that you made in step 4. of creating an account in a database and the database to use with Your WordPress install.
- define(‘DB_NAME’, ‘wordpress-db’);
- Locate the lines that define the DB_USER and then change the username here into the username of your database that has been created in step 3. to create the database user and the database to use with the WordPress setup.
- define(‘DB_USER,’ ‘WordPress-user’);
- Locate the text that is the DB_PASSWORD and then change your password to the password you set up in step 3. of creating an account in a database and a database that you will use in Your WordPress setup.
- define(‘DB_PASSWORD’, ‘your_strong_password’);
- Check out the section entitled Authentication Keys Unique and Salts. These key AND Salt values offer the security layer for the browser cookies WordPress users save on their personal computers. Adding long, random numbers can make your site more secure. Visit https://api.wordpress.org/secret-key/1.1/salt/ to randomly generate a set of key values that you can copy and paste into your wp-config.php file. To copy text into the PuTTY terminal, put your cursor in the area you wish to paste the text. Then press the right button within your PuTTY terminal.
- For more information about security keys, go to https://wordpress.org/support/article/editing-wp-config-php/#security-keys.
- Note
- The following values are intended only for illustration purposes; don’t use them to build your installation.
- Save the file, then exit the text editor.
In order to install the WordPress files, you must do so under your document root, the Apache document root.
- Once you’ve de-zipped the folder for installation, set up a MySQL Database and User, and modified your WordPress installation file to your liking, you’re prepared to transfer your WordPress installation files into the document root of your web server to start the script for installation that finishes the installation. The location of these files depends on whether you want your WordPress blog to be available at the actual root of your web server (for example, my.public.dns.amazonaws.com) or in a subdirectory or folder under the source (for example, my.public.dns.amazonaws.com/blog).
- If you would like WordPress to run on the root of your document, copy the contents of the WordPress installation directory (but it is not necessary to copy the entire directory) according to the following steps:
- [ec2-user$ CCP -R wordpress* /var/www/html/
- If you would like WordPress to run in a different directory within the document root, you must first create the directory and then copy the documents into it. In this instance, WordPress will run from the blog directory: blog:
- [ec2-user”$ mkdir http://var/www/html/blog [ec2-user$ cp –r wordpress* /var/www/html/blogwww.
Important
To protect yourself, If you’re not able to move on to the next process immediately, shut down your Apache webserver ( httpd) immediately. Once you have moved your WordPress installation to your Apache document root, The WordPress installation script is not protected, and a malicious attacker might gain entry to the blog If you were to let the Apache web server be in operation. To stop this Apache webserver, type this command: sudo systemctl end httpd. If you’re going to the next process, there is no need to shut down the Apache web server.
In order to allow WordPress to utilize permalinks
WordPress permalinks must use the Apache .htaccess files to be functional. However, this isn’t enabled as a default feature on Amazon Linux. Follow this method to allow all overrides to the Apache document root.
- Navigate to your httpd.conf file with your preferred text editor (such as the Nano as well as Vim). If you don’t have a preferred text editor, Nano is appropriate for novices.
- [ec2-user ~]$ sudo vim /etc/httpd/conf/httpd.conf
Leave a Reply