How to install WordPress in Ubuntu 22.04
- 00:33 lsb_release -a
- 00:47 apt install apache2
- 01:31 apt install -y php php-{common,mysql,xml,xmlrpc,curl,gd,imagick,cli,dev,imap,mbstring,opcache,soap,zip,intl}
- 02:03 php -v
- 02:29 apt install mariadb-server mariadb-client
- 03:22 systemctl status mariadb
- 03:45 mysql_secure_installation
- 06:03 wget https://wordpress.org/latest.zip
- 06:18 unzip latest.zip
- 06:54 chown www-data:www-data -R /var/www/html/wordpress/
- 07:11 chmod -R 755 /var/www/html/wordpress/
- 07:50 vim /etc/apache2/sites-available/wordpress.conf
- 08:19 a2ensite wordpress.conf
- 08:29 a2enmod rewrite
- 08:43 a2dissite 000-default.conf
- 09:01 systemctl restart apache2
To Install WordPress CMS on Ubuntu 22.04
Introduction:
WordPress is a content management system (CMS) that allows you to host and build websites. WordPress contains plugin architecture and a template system, so you can customize any website to fit your business, blog, portfolio, or online store.
Installation Procedure:
Step 1: Check the OS version by using the below command
root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.2 LTS
Release: 22.04
Codename: jammy
Step 2: Install Apache web server by using the below command
root@linuxhelp:~# apt install apache2
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libflashrom1 libftdi1-2 libllvm13
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3
libaprutil1-ldap
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3
libaprutil1-ldap
0 upgraded, 8 newly installed, 0 to remove and 22 not upgraded.
Need to get 1,917 kB of archives.
After this operation, 7,706 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Processing triggers for ufw (0.36.1-4build1) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
Step 3: Install PHP by using the below command
root@linuxhelp:~# apt install -y php php-{common,mysql,xml,xmlrpc,curl,gd,imagick,cli,dev,imap,mbstring,opcache,soap,zip,intl}
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'php8.1-opcache' instead of 'php-opcache'
The following packages were automatically installed and are no longer required:
libflashrom1 libftdi1-2 libllvm13
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
autoconf automake autopoint autotools-dev binutils binutils-common binutils-x86-64-linux-gnu
build-essential debhelper debugedit dh-autoreconf dh-strip-nondeterminism dpkg-dev dwz fakeroot
php8.1-readline php8.1-soap php8.1-xml php8.1-xmlrpc php8.1-zip pkg-config pkg-php-tools
po-debconf rpcsvc-proto shtool
0 upgraded, 120 newly installed, 0 to remove and 22 not upgraded.
Need to get 80.1 MB of archives.
After this operation, 290 MB of additional disk space will be used.
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for install-info (6.8-4build1) ...
Processing triggers for fontconfig (2.13.1-4.2ubuntu5) ...
Processing triggers for php8.1-cli (8.1.2-1ubuntu2.11) ...
Processing triggers for libapache2-mod-php8.1 (8.1.2-1ubuntu2.11) ...
Step 4: Check the PHP version by using the below command
root@linuxhelp:~# php -v
PHP 8.1.2-1ubuntu2.11 (cli) (built: Feb 22 2023 22:56:18) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
with Zend OPcache v8.1.2-1ubuntu2.11, Copyright (c), by Zend Technologies
Step 5: Install mariaDB server amd mariadb client by using the below command
root@linuxhelp:~# apt install mariadb-server mariadb-client
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libflashrom1 libftdi1-2 libllvm13
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
galera-4 gawk libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdaxctl1
libdbd-mysql-perl libdbi-perl libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-template-perl
libmariadb3 libmysqlclient21 libndctl6 libpmem1 libsnappy1v5 libterm-readkey-perl liburing2
mariadb-client-10.6 mariadb-client-core-10.6 mariadb-common mariadb-server-10.6
mariadb-server-core-10.6 mysql-common socat
Suggested packages:
gawk-doc libmldbm-perl libnet-daemon-perl libsql-statement-perl libipc-sharedcache-perl mailx
mariadb-test
The following NEW packages will be installed:
galera-4 gawk libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdaxctl1
libdbd-mysql-perl libdbi-perl libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-template-perl
libmariadb3 libmysqlclient21 libndctl6 libpmem1 libsnappy1v5 libterm-readkey-perl liburing2
mariadb-client mariadb-client-10.6 mariadb-client-core-10.6 mariadb-common mariadb-server
mariadb-server-10.6 mariadb-server-core-10.6 mysql-common socat
0 upgraded, 28 newly installed, 0 to remove and 22 not upgraded.
Need to get 18.7 MB of archives.
After this operation, 165 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu jammy/main amd64 gawk amd64 1:5.1.0-1build3 [447 kB]
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /lib/systemd/system/m
ariadb.service.
Setting up mariadb-server (1:10.6.12-0ubuntu0.22.04.1) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
Step 6: Check the status of the MariaDB by using the below command
root@linuxhelp:~# systemctl status mariadb
● mariadb.service - MariaDB 10.6.12 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-05-24 08:17:19 IST; 4h 55min ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Process: 20372 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=>
Process: 20373 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code>
Process: 20375 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd >
Process: 20417 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (cod>
Process: 20419 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
Main PID: 20404 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 8 (limit: 4573)
Memory: 61.5M
CPU: 7.163s
CGroup: /system.slice/mariadb.service
└─20404 /usr/sbin/mariadbd
May 24 08:17:19 linuxhelp mariadbd[20404]: Version: '10.6.12-MariaDB-0ubuntu0.22.04.1' socket: '/>
May 24 08:17:19 linuxhelp systemd[1]: Started MariaDB 10.6.12 database server.
May 24 08:17:19 linuxhelp /etc/mysql/debian-start[20421]: Upgrading MySQL tables if necessary.
May 24 08:17:19 linuxhelp /etc/mysql/debian-start[20424]: Looking for 'mariadb' as: /usr/bin/maria>
May 24 08:17:19 linuxhelp /etc/mysql/debian-start[20424]: Looking for 'mariadb-check' as: /usr/bin>
May 24 08:17:19 linuxhelp /etc/mysql/debian-start[20424]: This installation of MariaDB is already >
May 24 08:17:19 linuxhelp /etc/mysql/debian-start[20424]: There is no need to run mysql_upgrade ag>
May 24 08:17:19 linuxhelp /etc/mysql/debian-start[20424]: You can use --force if you still want to>
May 24 08:17:19 linuxhelp /etc/mysql/debian-start[20432]: Checking for insecure root accounts.
May 24 08:17:19 linuxhelp /etc/mysql/debian-start[20438]: Triggering myisam-recover for all MyISAM>
Step 7: Secure the MySQL Database Installation by using the below command
root@linuxhelp:~# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
... Success!
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
Step 8: Create a user, database and grant privileges to the user to access database by using the below command
root@linuxhelp:~# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 53
Server version: 10.6.12-MariaDB-0ubuntu0.22.04.1 Ubuntu 22.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> CREATE USER 'word_user'@'linuxhelp' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.011 sec)
MariaDB [(none)]> create database word_db;
Query OK, 1 row affected (0.014 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON word_db.* TO 'word_user'@'linuxhelp';
Query OK, 0 rows affected (0.009 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.010 sec)
MariaDB [(none)]> \q
Bye
Step 9: Download wordpress using wget command by using the below command
root@linuxhelp:~# wget https://wordpress.org/latest.zip
--2023-05-24 13:23:31-- https://wordpress.org/latest.zip
Resolving wordpress.org (wordpress.org)... 198.143.164.252
Connecting to wordpress.org (wordpress.org)|198.143.164.252|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 24498824 (23M) [application/zip]
Saving to: ‘latest.zip’
latest.zip 100%[=================================>] 23.36M 7.34MB/s in 3.9s
2023-05-24 13:23:36 (6.06 MB/s) - ‘latest.zip’ saved [24498824/24498824]
Step 10: Extract wordpress file by using unzip command
root@linuxhelp:~# unzip latest.zip
Archive: latest.zip
creating: wordpress/
inflating: wordpress/xmlrpc.php
inflating: wordpress/wp-blog-header.php
inflating: wordpress/readme.html
inflating: wordpress/wp-signup.php
inflating: wordpress/index.php
inflating: wordpress/wp-cron.php
inflating: wordpress/wp-config-sample.php
inflating: wordpress/wp-login.php
inflating: wordpress/wp-settings.php
inflating: wordpress/license.txt
creating: wordpress/wp-content/
creating: wordpress/wp-content/themes/
creating: wordpress/wp-content/themes/twentytwentythree/
inflating: wordpress/wp-content/themes/twentytwentythree/theme.json
creating: wordpress/wp-content/themes/twentytwentythree/parts/
inflating: wordpress/wp-content/themes/twentytwentythree/parts/footer.html
inflating: wordpress/wp-content/themes/twentytwentythree/parts/comments.html
inflating: wordpress/wp-content/themes/twentytwentythree/parts/header.html
inflating: wordpress/wp-content/themes/twentytwentythree/parts/post-meta.html
creating: wordpress/wp-content/themes/twentytwentythree/patterns/
inflating: wordpress/wp-content/themes/twentytwentythree/patterns/hidden-404.php
inflating: wordpress/wp-content/themes/twentytwentythree/patterns/post-meta.php
Step 11: Move the file to Apache document root directory by using the below command
root@linuxhelp:~# mv wordpress/ /var/www/html/
Step 12: Change the ownership and permission by using the below command
root@linuxhelp:~# chown www-data:www-data -R /var/www/html/wordpress/
root@linuxhelp:~# chmod -R 755 /var/www/html/wordpress/
Step 13: Create a configuration file for wordpress by using the below command
root@linuxhelp:~# vim /etc/apache2/sites-available/wordpress.conf
<VirtualHost *:80>
ServerAdmin admin@linuxhelp.com
DocumentRoot /var/www/html/wordpress
ServerName linuxhelp.com
ServerAlias www.linuxhelp.com
<Directory /var/www/html/wordpress/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Step 14: Enable virtual host by using the below command
root@linuxhelp:~# a2ensite wordpress.conf
Enabling site wordpress.
To activate the new configuration, you need to run:
systemctl reload apache2
Step 15: Enable rewrite module by using the below command
root@linuxhelp:~# a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run:
systemctl restart apache2
Step 16: Disable the default Apache test page by using the below command
root@linuxhelp:~# a2dissite 000-default.conf
Site 000-default disabled.
To activate the new configuration, you need to run:
systemctl reload apache2
Step 17: Restart the Apache webserver to apply changes by using the below command
root@linuxhelp:~# systemctl restart apache2
Conclusion:
This is the procedure to install the Wordpress CMS in ubuntu 22.04. Now, you can host PHP-based web applications on your server.
Comments ( 0 )
No comments available