how to install wordpress on ubuntu

How to Install WordPress on Ubuntu 20.04

First of all we will setup a LAMP server after which we will install WordPress in it. For this tutorial we have used ubuntu 20.04 LTS. If you want to install your WordPress in your localhost i.e. in XAMPP then click on this link – Install WordPress in xampp Here I showed in detail how you can run WordPress by installing it in xampp.

Update

First of all we will update the index packages for which we will use this command which will update it.

sudo apt update

Install NGINX

After the update is complete, now we will install nginx which is an open source web server in which we will install WordPress later. To install nginx, you have to type the command given below.

sudo apt install nginx -y

It will take some time to install, it depends on your internet connection how long it will take to install it. After nginx is installed, you can type the command given below to check its status.

sudo systemctl status nginx

By typing this command you will see the status of nginx in terminal whether it is working or not. You can also check this by going to your web browser whether nginx is installed or not, for this you will need the IP address of your server, to get which you can use the command given below.

ip a

Enter this ip address in your browser and if the landing page of nginx appears in your browser it means it is well installed and working.

Install MySQL Database

Now we will install MySQL database in this server which is a very important component to run WordPress. To install it, we will type the command given below.

sudo apt install mysql-server mysql-client -y

We are installing MySQL client because we need MySQL client to connect to our database. It will take you 2 – 5 minutes to install MySQL, it depends on your internet speed.

After MySQL is installed, we have to start it, to start you have to type this command –

sudo systemctl start mysql

Enable MySQL and NGINX

Now we will enable MySQL and nginx. By enabling this, if you ever reboot your system, then MySQL and nginx will start automatically, which if you do not enable then you have to start them manually. To enable MySQL and nginx, type this command –

sudo systemctl enable mysql
sudo systemctl enable nginx

Configure MySQL Database

Now we will deploy our MySQL server for which we will type the below command so that it will be deployed securely.

sudo mysql_secure_installation

After typing this command, it will ask you to set a password, for which you will first have to select “y” then you will have to select number 2, after which you can enter any good password of your choice in it.

After this, you will have to select ” y ” in all the options that come after which your MySQL server will be deployed.

Connect to MySQL database

After the MySQL server is deployed, now we have to connect to it with the role of a root user. For which we will type the command given below so that we can connect to the database with the role of a root user.

sudo mysql -u root -p

Now it will ask you for your database password which you set during database configuration. After typing the password we will be logged in to our MySQL server after which we will have to create a database in it.

create database wordpress;

And you will also have to create a user.

create user “yourusername”@”localhost” identified by “yourpassword”; 

Keep in mind that your password must be good, it must be strong, it must contain a capital letter, small letter, a symbol and number.

Now we will give all those privileges of this database to our user for which we will use this command.

grant all privileges on wordpress.* to ‘yourusername’@’yourpassword’;
flush privileges;
exit;

Install PHP

Now we will install PHP in our web server because this is something that we need to install and run WordPress in an ubuntu web server. Type this command to install PHP.

sudo apt install php7.4 php7.4-gd php7.4-mysql php7.4-zip php7.4-fpm -y

Now all the requirements are downloaded and this means that our LAMP server is also ready to install WordPress. So let us now see how we can install WordPress in ubuntu.

Install WordPress in Ubuntu

Now we will install WordPress in our ubuntu for which we will copy this link “https://wordpress.org/latest.zip” and after that we will type this command in the terminal of our server so that latest WordPress version will be installed in our web server.

sudo apt install wget
wget https://wordpress.org/latest.zip

Now we have to unzip the downloaded WordPress zip file, for which we will first install unzip, for which we will use this command.

sudo apt install unzip -y

Unzip will now be installed in our system. After this we will unzip the zip file of WordPress.

ls
unzip latest.zip

After WordPress is unzipped, a new folder will now appear in your directory, which will be named WordPress. Now change your working directory to WordPress.

cd wordpress/
ls

Now we will copy all the files in this folder to /var/www/html/ for which we will use this command.

sudo cp -r * /var/www/html/

After this we will change the permissions of this folder which we need to install any plugins or anything in WordPress.

sudo chown -R www-data:www-data /var/www/html/

After this we will restart our nginx server –

sudo systemctl restart nginx

Configure WordPress

Now we have to do some configuration in the default files of WordPress. For this, first we will change our directory and go to the directory given below.

cd  /etc/nginx/sites-enabled/
ls

Now we will move the default file that is in it to WordPress by default. For which we will type this command.

sudo mv default wordpress

Now we will edit this WordPress file for which we will use Nano editor.

sudo nano wordpress

Here you will have to edit some lines, whose image is below, which you will have to change.

install wordpress in ubuntu lines to change (2)

We’ll go down a bit after that and uncomment these things there because we’re using PHP.

install wordpress in ubuntu change lines

After all the editing is complete, we will hit exit from our Nano editor, save it and then type the command given below.

sudo nginx -t 

With the help of the above comment, it happens that it checks the syntax of the file we just saved, whether it is right or wrong. After the check is successful, we will now restart our nginx server.

sudo systemctl restart nginx

WordPress is now installed in our ubuntu server and you can now do the rest of the configuration in it by going to your chrome browser. For this, you have to type your server IP address in your browser and then it will redirect you to WordPress configuration.

ip a

Final WordPress Configuration

After typing the IP address in the browser, when the configuration page will open, we will have to select your language here and then click on continue. After clicking on continue, we will have to type the user name of the database in this and the password of the database and then we will have to click on submit.

After that we will click on run the installation. After this we will have to give a name to our website and to log in to the website, we will have to give a username and a password and the email address you have so that if you ever forget the password, you can reset it.

And finally we will click on Install WordPress which will install our WordPress completely. Now you can login to your WordPress site from its admin panel. If you want to install SSL in your website then you can also see this post “Install SSL certificate in ubuntu” here You will get complete details of installing ssl in ubuntu.

Install Theme in WordPress

Now we will see how we can install a theme in WordPress so that the look of your website looks very good.

To install the theme, you must first login to your WordPress admin dashboard through your username and password that you gave during installation.

After login to the dashboard, you will get the option of appearance below on the left side, above which if you hover your mouse, then you will get the option of themes, on which you will have to click. Here you will get the add new option on which you have to click.

Here now you can install it by hovering over any theme, on hovering over any theme, you will see the option of install, which you have to click, after clicking it, it will be installed. After installation, you will get an activate button, which you have to click, so that the theme will now be activated on your website.

If you have already purchased a theme and want to install it, then you will first have to go to the appearance and then to the themes where you have to click on the button of add new, there you will get the option of upload theme. But you have to click.

Now you have to select your theme which is in your computer by clicking on the option of choose file and then click on the option of install now, now it will have to be uploaded and after uploading you will have to activate it and by which it will be activated in your website.

Install Plugin in WordPress

If you want to install a plugin, then you have to first go to the option of plugins from the menu then click on the add new option there, after clicking on add new you can search for any plugin and install it.

If you have purchased and downloaded a plugin, then you can activate it by uploading it by clicking on the upload button and in the same way you can install both the theme and the plugins.

Conclusion -

And just like that you can easily install WordPress on your ubuntu server and create a website. If you have to install SSL certificate in your website then I have given its link in the article. Click on it and if you want to host the WordPress site on your localhost, then I have also given its link.

If you liked this post, then do share it with your friends and do comment below. If I have made any mistake here, then definitely tell it in the comment and I will correct it.

Leave a Comment

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