How to Setup Wordpress Website Step by Step in Ubuntu VPS

How to Setup Wordpress Website Step by Step in Ubuntu VPS

In this blog, we will setup wordpress website in Ubuntu server. We will install each packages step by step which is required for wordpress website.

I have deployed one Ubuntu server and my server detail is given below:

My server detail

Os: Ubuntu 20.04 x64

IP Address: 45.77.111.118

User: root

Password: xxxxxxxxxxxx

Connect to server by SSH and install required modules.

Install Apache

We need to install Apache webserver. With this command "sudo apt-get install apache2", we can install Apache webserver.

For more details, you can follow link below:

Install Apache2 Web Server in Ubuntu Virtual Server

sudo apt-get update

sudo apt-get install apache2

Enable the Rewrite Module

sudo a2enmod rewrite

systemctl restart apache2

Open firewall for HTTP traffic

After installation, we need to allow HTTP traffic on your UFW firewall like below:

sudo ufw allow "Apache Full"

Install Mysql

Install MySql Server

sudo apt-get update

sudo apt install mysql-server

After installation we can see start, stop, restart mysql.service.

Mysql service start, restart, stop and status commands

systemctl start mysql.service

systemctl restart mysql.service

systemctl stop mysql.service

systemctl status mysql.service

Connect to Mysql and change root user password

Change password of root mysql user to 'nutan12345'. You can choose password according to your choice.

sudo mysql -u root -p

Press enter, it will go to mysql console. Then type below command to change password of root user.

ALTER USER root@localhost IDENTIFIED WITH mysql_native_password BY 'nutan12345';

Now changed the root user password. Type exit; It will exit from mysql console.

Let us create one database, which we are going to use for wordpress.

Create a one database

mysql -u root -p

It will ask to enter password, type password and press enter. Then type following command to create a database.

create database sampledb2022;

View created a new database

show databases;

You can see newly created database. Now we don't need Mysql console, to exit from Mysql console type exit; then press enter.

Mysql database details, which we will use in wordpress

Database name: sampledb2022

DB user: root

DB password: nutan12345

DB Host: localhost

Install PHP

sudo apt-get update

sudo apt -y install php7.4

Check php version

php -v

Install libapache2-mod-php php-mysql packages

We need php-mysql, a PHP module that allows PHP to communicate with MySQL-based databases. We will also need libapache2-mod-php to enable Apache to handle PHP files.

sudo apt install php libapache2-mod-php php-mysql

Download latest WordPress

Go to the following directory and download latest wordpres.

cd /var/www

mkdir temp

cd temp

Download the latest wordpress zip

Using -O (uppercase) option, downloads files with the different file names. In this example changing file name from latest.tar.gz to wordpress.tar.gz.

wget -O wordpress.tar.gz https://wordpress.org/latest.tar.gz

Untar the wordpress.tar.gz in /var/www/ folder

On Unix-like operating systems, the tar command creates, maintains, modifies, and extracts files that are archived in the tar format. We have listed some option of tar command, we are using in this blog.

x – extract files from the given tar file.

v – list out the files as they get extracted.

z – The z tells tar that the archive will be compressed with gzip.

f – helps to specify the filename which needs to be worked on for the untar process.

C : untar the specified files to a particular path location

sudo tar -xzvf /var/www/temp/wordpress.tar.gz -C /var/www/

View the untar wordpress

cd /var/www/

cd wordpress

ll

Rename wordpress folder and change ownership of the folder

Rename wordpress folder

cd /var/www/

mv wordpress/ sample-website/

ll

Change www-data:www-data Apache user ownership to the sample-website folder

Now set appropriate permissions on the website (/var/www/html/mysite.com) directory. It should be owned by the Apache2 user and group called www-data.

sudo chown -R www-data:www-data /var/www/sample-website

Change permission

sudo chmod -R 775 /var/www/sample-website

Create virtual hosts for new wordpress website

Go to the following directory and create Apache configuration file

cd /etc/apache2/sites-available

vi sample-website.conf

It will open vi editor, you need to press i to insert in code in vi editor. Then paste following line of virtual host in sample-website.conf file.

<VirtualHost *:80>

ServerAdmin webmaster@www.sample-website.com

DocumentRoot /var/www/sample-website

ServerName www.sample-website.com    


<Directory /var/www/sample-website>
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

</VirtualHost>

Save and exit sample-website.conf file. To save vi editor press Esc key then type :wq after that press enter.

Enable the Apache configuration file

cd .. sudo a2ensite sample-website.conf

cd sites-enabled ll

Restart Apache

systemctl reload apache2

Install wordpress

Create a copy of this file wp-config-sample.php

cd /var/www/sample-website/

ll

cp wp-config-sample.php wp-config.php

Open wp-config file and write your database details in that

vi wp-config.php

Make hosts entry in your local system

Open command prompt as administrator

cd drivers/etc

notepad hosts

45.77.111.118 www.sample-website.com

Install and run the Wordpress website

Type server name in your browser. In this server name is http://www.sample-website.com.

You will get wordpress installation page like below. If you are not getting installation page, you just restart your apache webserver once.

Click on Continue, next will show like below:

You have to type Site Title, username, password and your email then click on Install Wordpress.

Successfully we have installed wordpress. Now need to login to wordpress admin panel.

Enter admin user and password then click on Log In.

After login admin dashboard will show like below:

You can visit website by http://www.sample-website.com.

We have successfully setup wordpress website in Ubuntu server. After wordpress setup you can beautify your website. You can install new wordpress theme according to your requirement.

In [ ]:
 

Machine Learning

  1. Deal Banking Marketing Campaign Dataset With Machine Learning

TensorFlow

  1. Difference Between Scalar, Vector, Matrix and Tensor
  2. TensorFlow Deep Learning Model With IRIS Dataset
  3. Sequence to Sequence Learning With Neural Networks To Perform Number Addition
  4. Image Classification Model MobileNet V2 from TensorFlow Hub
  5. Step by Step Intent Recognition With BERT
  6. Sentiment Analysis for Hotel Reviews With NLTK and Keras
  7. Simple Sequence Prediction With LSTM
  8. Image Classification With ResNet50 Model
  9. Predict Amazon Inc Stock Price with Machine Learning
  10. Predict Diabetes With Machine Learning Algorithms
  11. TensorFlow Build Custom Convolutional Neural Network With MNIST Dataset
  12. Deal Banking Marketing Campaign Dataset With Machine Learning

PySpark

  1. How to Parallelize and Distribute Collection in PySpark
  2. Role of StringIndexer and Pipelines in PySpark ML Feature - Part 1
  3. Role of OneHotEncoder and Pipelines in PySpark ML Feature - Part 2
  4. Feature Transformer VectorAssembler in PySpark ML Feature - Part 3
  5. Logistic Regression in PySpark (ML Feature) with Breast Cancer Data Set

PyTorch

  1. Build the Neural Network with PyTorch
  2. Image Classification with PyTorch
  3. Twitter Sentiment Classification In PyTorch
  4. Training an Image Classifier in Pytorch

Natural Language Processing

  1. Spelling Correction Of The Text Data In Natural Language Processing
  2. Handling Text For Machine Learning
  3. Extracting Text From PDF File in Python Using PyPDF2
  4. How to Collect Data Using Twitter API V2 For Natural Language Processing
  5. Converting Text to Features in Natural Language Processing
  6. Extract A Noun Phrase For A Sentence In Natural Language Processing