Give us a call: (800) 252-6164
Select your language
How to make your website load in under 2 seconds using Apache, Nginx, Redis, PHP7, MySQL, and WordPress

Load Times Under 2s: MySQL, Apache, PHP7 & Composer

May 6, 2018 | By PotentPages | Filed in: hosting.

Installing MySQL

Next we need to install MySQL. This will be our database of choice however you can easily use any database that you’re looking for. Use the latest “Red Hat” repository mentioned here: https://dev.mysql.com/downloads/repo/yum/. Click “Download”, then use the link “No thanks, just start my download”. Replace the wget and rpm lines with the link you selected here.

 

You should see “Active: active (running)” in the output if everything was successful. To secure your MySQL installation, run the following command.

Follow the instructions and set a root password, remove root accounts that are accessible from outside the local host, remove anonymous-user accounts, and remove the test database and privileges that permit anyone to access databases with names that start with test_. When you create your root password, I recommend keeping it to only numbers and letters (uppercase and lowercase, no symbols). This will make it easier to use the password later in shell commands. If you run into any issues, please read the second note below.

Keep the root MySQL password somewhere; we will need it later on.

Note: Your MySQL installation should have either a blank password (e.g. no value) or a temporary password. To find the temporary password, use:

Note: if you can’t log in when if it asks for your root password (either because you set the password, or you just can’t log in), add “skip-grant-tables” to the [mysqld] section of /etc/my.cnf , run systemctl restart mysqld; and log in again. Run: mysql -uroot -e “FLUSH PRIVILEGES;”;mysql -uroot -e “ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘[[Root MySQL Password]]’;”; When you’re done, edit the /etc/my.cnf file again (nano /etc/my.cnf), remove the “skip-grant-tables”, and restart the MySQL server again (systemctl restart mysqld).

Another Note: I recommend that you decrease the password validation policy to “LOW”. The reason for this is that it’s advantageous to have a password without any special characters, since entering them in the command line directly can prove difficult. Open the my.cnf file

… and add the following line in the “[mysqld]” section

Finally, restart your mysql service.

Install Apache

Now we need to install Apache.

 

And if you have SELinux, we will need to add another setting allowing Nginx to connect to Apache

 

At this point, if you go to http://[[your IP address]] you should see the Apache test page.

Installing PHP

To install PHP, run the following command. Feel free to upgrade the “71w” to the latest version of PHP that provides all of the packages that you’re looking for.

 

In my case, I needed to link the inotify .so file to the PHP modules folder. If you install other PHP packages, you may need to do the same with those as well.

 

Installing Composer

Composer is great for PHP package management. To install it and enable it, just run:

 

Automatic Installation?

If you like the result of the tutorial, but run into problems or would just like to have the work done automatically, we can help you with that. We have an automated script that can SSH into your server and run this tutorial from beginning to end (as long as it’s running CentOS 7). If you would like this done for you ($100), please contact us using the form below.

 

Get Started





 


Part 1: Introduction and Planning

Why it’s important to have your pages load in under 2 seconds, and a plan of how we will set up and configure the server.

Initial setup of the server, including installing CentOS7, installing tools, installing SSH and SSL, enabling repositories, and installing support packages.

Part 3: MySQL, Apache, PHP7, & Composer

Installation of MySQL database serverApache web serverPHP, and Composer package manager for PHP

How to download, install, and configure PHPMyAdmin; How to install and configure Redis

Part 5: SSL Certificate & Apache Configuration

How to create a self-signed SSL certificate; how to configure Apache as a PHP backend

Part 6: FTP & DNS

How to install and configure an FTP server with dynamic users; how to set up a DNS server

Part 7: Installing Nginx

How to download, build, and install Nginx with additional modules

Part 8: Configuring Nginx

How to set up Nginx configuration files including (with explanations): nginx.confGzip compression settingsvisitor browser caching settingsSSL settingsreverse proxy settings for sending data to the Apache serverreverse proxy connection configurationsfile access restrictions, and WordPress configuration settings

Part 9: Adding a WordPress Website

How to add a WordPress website to the server including configuring the DNS Server, adding a verified SSL certificate, either manually or for free using Let’s Encrypt, setting up FTP for your site, configuring Apache, configuring Nginx, uploading your WordPress site files, and importing your MySQL database.

Part 10: WordPress Website Speed Improvements

Speeding up your WordPress installation using a Redis plugin and a caching plugin.



Tags:

Comments are closed here.

Scroll To Top