Andy Tran

Install WordPress with LAMP on Ubuntu

by | Feb 7, 2022 | Wordpress

How to install Wp with LAMP on ubuntu

What is WordPress

WordPress is one of the most popular content management systems (CMS). It is a free and open-source platform.

Requirements:

To install WordPress on the local machine, should have the following requirements

  1. Apache2.4 or above version
  2. MySQL5.7 or above version
  3. PHP7.1 or above version
  4. WordPress latest version zip file

Apache Installation

Apache: It is a fast and secure web server, to install Apache in Ubuntu, run the following commands in the command prompt.

sudo apt-get update

sudo apt-get install

apache2 -y apache2 -v

Start the Apache server with the following command.

systemctl start apache2.service

To check the status of the Apache server use the following command and make sure it is up and running.

Start the Apache server with the following command.

sudo service apache2 status

To verify that Apache is running, you can also open your web browser and enter your server IP address,

http://your-ip-address/ or http://localhost

If Apache is successfully installed you should be able to see the Apache default welcome page in the browser as shown below.

Apache default page

MySQL Installation

Download the MySQL files by using the following commands.

wget http://repo.mysql.com/mysql-apt-config_0.8.9-1_all.deb

sudo dpkg -i mysql-apt-config_0.8.9-1_all.deb

This will prompt you to select the MySQL version to be installed. So that pkg can configure the apt repository accordingly.

sudo apt-get update

sudo apt-get install mysql-server

The installation process will prompt for the default password of the root user and also confirm the password.

MySql password config

To start MySQL server using the following command

service mysqld start

Now run the mysql_secure_installation command. This will prompt for the configuration of variable security changes.

mysql_secure_installation

Run the below command to check the MySQL version

mysql -V

Finally, log in to the MySQL server using the following command. Enter the password created during installation.

mysql -u root -p

PHP Installation

PHP is a programming language used to develop dynamic websites. WordPress is a PHP-based CMS, so it needs PHP for processing the dynamic content of WordPress sites.

Run the following commands to install PHP.

sudo apt-get install -y python-software-properties

sudo add-apt-repository -y ppa:ondrej/php

The following command will update the software.

sudo apt-get update -y

sudo apt-get install -y php7.1

Include some additional modules, in order to help PHP to connect with our Apache and MySQL, as well as some additional modules which will be required by our WordPress site.

sudo apt-get install -y libapache2-mod-php7.1 php7.1-mbstring php7.1-gd php7.1-xml php7.1-mysql php7.1-mcrypt php7.1-zip

In order to test if PHP is working properly, we can create a PHP file which will show us the current PHP configuration.  Path of the file is  /var/www/html/phpinfo.php. Insert the following code in the file:

<?php phpinfo(); ?>

Need to restart Apache so it can see the changes you just made and run PHP

service apache2 restart

Finally save the file by pressing Esc and “:wq“. Now to verify that your PHP code is properly executed or not, open this url http://your-ip-address/phpinfo.php in browser. You should see the following page:

PHP Installaiton page

WordPress Installation

Download the WordPress package to your local computer with this link  https://wordpress.org/download/. Move the downloaded zip to default web server document root directory (/var/www/html).

cd /var/www/html

Unzip the wordpress zip file

unzip folder_name

Assign the correct ownership and permissions to WordPress files and folders. This will increase security to WordPress directory. To do this, we’ll use chown to grant ownership to Apache’s user and group.

chown -R www-data:www-data folder_name

Create database for WordPress. First, login to MySQL and run the below command.

mysql -u root -p

To create a new database for our WordPress installation, run the following command

create database database_name;

Once the database is created, we will need to add this information to the WordPress configuration file. And update the database settings, replacing database_name_here, username_here, and password_here with your own details. To edit the wp-config file using the following command.

vi wp-config.phpx

Wp config modifications

Complete Installation Through the Web Interface

Open a new browser window and go to the installation page to run the installation script.

http://IP/wordpess_foldernane/wp-admin/install.php

select the language that you would like to install WordPress with, After selecting a language and click on Continue.

It will be presented with the WordPress initial configuration page, where you will create an initial administrator account. Once finished filling in the details, click on the Install WordPress button at the bottom to continue.

Wordpress installation page

WordPress will confirm the installation, with the following image

Wordpress installation success page

To continue, click on the Login button at the bottom, then fill out your administrator account information:

Wordpress login page

Finally, it will present your new WordPress dashboard

Wordpress Dashboard

 

Refer this https://www.eruditeworks.com/category/wordpress/ to know more about WordPress

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *