WordPress is one of the most popular content management systems (CMS) used by millions of websites worldwide. Although many web hosts offer automatic WordPress installations, manual installation provides greater control and understanding of the components involved in running a WordPress site. This comprehensive guide will walk you through the process of manually installing WordPress on your local machine or web server using MySQL, Apache, and PHP.
In this tutorial, we will cover the steps required to manually install WordPress using the LAMP (Linux, Apache, MySQL, PHP) stack on your Linux machine or web server. We will install PHP, Apache, and MySQL, configure the necessary settings, and set up a WordPress site.
Note: Manual installation of WordPress can be difficult for beginners. This lesson could be omitted if you choose one of our plans. We will install WordPress and MySQL database automatically on our servers and make the initial configuration.
PHP (Hypertext Preprocessor) is a server-side scripting language that powers WordPress. To install PHP on your system, use the following command:
sudo apt install php libapache2-mod-php php-mysql
Verify that PHP has been successfully installed by running:
php -v
You should see output similar to the following:
PHP 7.4.3 (cli) (built: Oct 6 2020 15:47:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
Next, install additional PHP modules such as Curl, XML, and XMLRPC to ensure smooth operation of WordPress:
sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
Apache is a widely used web server that powers millions of websites. To install the latest version of Apache (Apache2) on your system, use the following command:
sudo apt install apache2
Verify that Apache has been successfully installed by running:
apache2 -v
You should see output similar to the following:
Server version: Apache/2.4.41 (Ubuntu)
Now, configure Apache virtual hosts for your WordPress site by creating a new configuration file:
sudo nano /etc/apache2/sites-available/wordpress.conf
Use the following template for the new configuration file, replacing /var/www/wordpress
with the location of your WordPress installation:
<VirtualHost *:80>
ServerName yourdomain.name
<Directory /var/www/wordpress>
AllowOverride All
DirectoryIndex index.php
</Directory>
</VirtualHost>
Enable the Apache rewrite module and check the configuration syntax:
sudo a2enmod rewrite
sudo apache2ctl configtest
If the syntax is correct, you should see the following output:
Syntax OK
Note: If you see an error message before “Syntax OK,” it is likely due to your system using the localhost address. This is normal and can be ignored for local installations.
MySQL is a popular open-source relational database management system. To install MySQL on your system, use the following command:
sudo apt install mysql-server
Verify that MySQL has been successfully installed by running:
mysql -V
You should see output similar to the following:
mysql Ver 8.0.25-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
Now, log in to MySQL and change the mysql_native_password
:
sudo mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'secure password';
FLUSH PRIVILEGES;
EXIT;
Log in to MySQL using the root user and the new password, then create a new database for your WordPress site:
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Create a new MySQL user and grant them all access to the WordPress database:
CREATE USER 'wordpressuser'@'%' IDENTIFIED WITH mysql_native_password BY 'secure password';
GRANT ALL ON wordpress.* TO 'wordpressuser'@'%';
FLUSH PRIVILEGES;
EXIT;
If you’re using Ubuntu, you can install WordPress directly from the package manager:
sudo apt install wordpress
Alternatively, you can download the latest version of WordPress from the official repository:
cd /tmp
curl -O https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
Create the Apache .htaccess
file and copy the sample WordPress configuration file to the working configuration file. Also, create an “upgrade” directory to ensure that WordPress won’t encounter permission issues during updates:
touch /tmp/wordpress/.htaccess
cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
mkdir /tmp/wordpress/wp-content/upgrade
Copy the extracted WordPress files to /var/www
for Apache to serve:
sudo cp -a /tmp/wordpress/. /var/www/wordpress
Adjust the files and directory permissions for your WordPress installation. The www-data
user and group are used by the Apache web server, which needs read and write access to WordPress files in order to serve the website and perform automatic updates:
sudo chown -R www-data:www-data /var/www/wordpress
sudo find /var/www/wordpress/ -type d -exec chmod 750 {} \;
sudo find /var/www/wordpress/ -type f -exec chmod 640 {} \;
Generate secure keys for your WordPress installation by making a request to the WordPress API:
curl -s https://api.wordpress.org/secret-key/1.1/salt/
Note: Do not copy the keys shown here. Make sure you generate your own unique keys.
Open the WordPress configuration file and add the keys, along with the database details:
sudo nano /var/www/wordpress/wp-config.php
Replace the existing database name, user, and password with the values you created while configuring MySQL. Also, replace the salt keys with the ones you generated from the WordPress API. Optionally, you can change the table prefix from “wp_” to something else, such as “blog_”.
Start the Apache2 server and visit your WordPress installation:
sudo service apache2 start
Navigate to http://127.0.0.1/wordpress
in your web browser to access the WordPress setup process. First, select the user language, then configure the WordPress user details (this will be the default admin user). After clicking “Install WordPress,” your WordPress installation should be complete, and you will be directed to a success screen.
Log in to the WordPress dashboard using your login details to access your new WordPress site.
By following this tutorial, you have successfully manually installed WordPress using the LAMP (Linux, Apache, MySQL, PHP) stack on your Linux machine or web server. This process provides you with a greater understanding of the components involved in running a WordPress site and allows you to better troubleshoot issues if they arise.
Remember, manual installation of WordPress can be difficult for beginners. If you choose one of our plans, we will install WordPress and MySQL database automatically on our servers and make the initial configuration for you.
Go4Them 2020 is provided by Machine Mind Ltd - Company registered in United Kingdom - All rights reserved
Recent Comments