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:
Os: Ubuntu 20.04 x64
IP Address: 18.104.22.168
Connect to server by SSH and install required modules.
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:
sudo apt-get update
sudo apt-get install apache2
sudo a2enmod rewrite
systemctl restart apache2
After installation, we need to allow HTTP traffic on your UFW firewall like below:
sudo ufw allow "Apache Full"
sudo apt-get update
sudo apt install mysql-server
After installation we can see start, stop, restart mysql.service.
systemctl start mysql.service
systemctl restart mysql.service
systemctl stop mysql.service
systemctl status mysql.service
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.
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;
You can see newly created database. Now we don't need Mysql console, to exit from Mysql console type exit; then press enter.
Database name: sampledb2022
DB user: root
DB password: nutan12345
DB Host: localhost
sudo apt-get update
sudo apt -y install php7.4
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
Go to the following directory and download latest wordpres.
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.
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/
mv wordpress/ sample-website/
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
sudo chmod -R 775 /var/www/sample-website
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.
ServerAdmin firstname.lastname@example.org 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>
Save and exit sample-website.conf file. To save vi editor press Esc key then type :wq after that press enter.
cd .. sudo a2ensite sample-website.conf
cd sites-enabled ll
systemctl reload apache2
cp wp-config-sample.php wp-config.php
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:
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.