The ease is in the understanding

for those that want the quick script copy and paste scenario at the end of the article I have the copy and paste script but I highly recommend reading first.

Installing WordPress on Ubuntu Server 22.04 involves several steps, including setting up a LAMP (Linux, Apache, MySQL, PHP) stack, creating a MySQL database, configuring Apache, and installing WordPress itself. Here’s a step-by-step guide:

Step 1: Update and Upgrade System Packages

Open a terminal and update the package list to ensure you have the latest available versions:

bashCopy code

sudo apt update sudo apt upgrade

Step 2: Install Apache Web Server

Install Apache using the following command:

bashCopy code

sudo apt install apache2

After installation, start the Apache service and enable it to start on boot:

bashCopy code

sudo systemctl start apache2 sudo systemctl enable apache2

Step 3: Install MySQL Database Server

Install MySQL by running:

bashCopy code

sudo apt install mysql-server

During installation, you’ll be prompted to set a MySQL root password. Follow the instructions and secure the MySQL installation:

bashCopy code

sudo mysql_secure_installation

Step 4: Install PHP and Required Modules

Install PHP and necessary modules:

bashCopy code

sudo apt install php libapache2-mod-php php-mysql php-curl php-gd php-xml php-mbstring

Step 5: Create a MySQL Database and User for WordPress

Log into the MySQL shell:

bashCopy code

sudo mysql -u root -p

Create a database for WordPress:

sqlCopy code

CREATE DATABASE wordpress;

Create a MySQL user and grant privileges to the WordPress database:

sqlCopy code

CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost'; FLUSH PRIVILEGES; EXIT;

Replace 'password' with a strong password.

Step 6: Download and Configure WordPress

Download the latest WordPress release:

bashCopy code

cd /tmp wget https://wordpress.org/latest.tar.gz tar -zxvf latest.tar.gz sudo mv wordpress /var/www/html/ sudo chown -R www-data:www-data /var/www/html/wordpress

Step 7: Configure Apache for WordPress

Create an Apache configuration file for WordPress:

bashCopy code

sudo nano /etc/apache2/sites-available/wordpress.conf

Add the following configuration:

apacheCopy code

<VirtualHost *:80> ServerAdmin admin@example.com DocumentRoot /var/www/html/wordpress ServerName example.com ServerAlias www.example.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>

Enable the new virtual host and restart Apache:

bashCopy code

sudo a2ensite wordpress.conf sudo a2enmod rewrite sudo systemctl restart apache2

Step 8: Complete WordPress Installation via Browser

Open a web browser and navigate to your server’s IP address or domain name (http://your_server_ip/wordpress). Follow the WordPress installation wizard, enter the database details (database name, username, password), and complete the setup.

Once done, you’ll have a fresh WordPress installation ready for customization!

Please ensure to replace placeholder values (like example.com, admin@example.com, password, and your_server_ip) with your actual domain, email, password, and server IP accordingly.

In Linux

sudo mkdir -p /var/www/{yoursitename}
sudo chown www-data:www-data /var/www/{yoursitename}
curl https://wordpress.org/latest.tar.gz | sudo -u www-data tar zx -C /var/www/{yoursitename}
cd /var/www/{yoursitename}/wordpress
sudo mv * ../
sudo vi /etc/apache2/sites-available/{yoursitename}.conf

#In the VI editor Hit “i” to enter insert mode then paste the following from start of input to end of input
#pasting can be done by right clicking the mouse then hit (escape) then hit (Shift 🙂 then hit (wq) and enter to save and #exit editor
#start of input
<VirtualHost *:80>
    DocumentRoot /var/www/{yoursitename}
    <Directory /var/www/{yoursitename}>
        Options FollowSymLinks
        AllowOverride Limit Options FileInfo
        DirectoryIndex index.php
        Require all granted
    </Directory>
    <Directory /var/www/{yoursitename}/wp-content>
        Options FollowSymLinks
        Require all granted
    </Directory>
</VirtualHost>
#end of input

cd /etc/apache2/sites-available/
sudo a2ensite {yoursitename}.conf
sudo systemctl reload apache2
sudo mysql -u root -p

CREATE DATABASE {yoursitename};
CREATE USER {yoursitename}@localhost IDENTIFIED BY ‘NMCClean1!’;
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON {yoursitename}.* TO {yoursitename}@localhost;
FLUSH PRIVILEGES;
exit

If you need to remove table in MySql type… drop database {yoursitename};
If you need to remove user in MySql type…DROP USER ‘{yoursitename}’@’localhost’;

sudo -u www-data cp /var/www/{yoursitename}/wp-config-sample.php /var/www/{yoursitename}/wp-config.php
sudo -u www-data sed -i ‘s/database_name_here/{yoursitename}/’ /var/www/{yoursitename}/wp-config.php
sudo -u www-data sed -i ‘s/username_here/{yoursitename}/’ /var/www/{yoursitename}/wp-config.php
sudo -u www-data sed -i ‘s/password_here/NMCClean1!/’ /var/www/{yoursitename}/wp-config.php

#get new keys copy them

https://api.wordpress.org/secret-key/1.1/salt/

#Open config file in vi scroll down to the existing key and delete them to delete a line hit dd then paste the keys

sudo -u www-data vi /var/www/{yoursitename}/wp-config.php

Go to your site and start Word pressing

By truekoioscom

I am Sasha Amow, the resident data wrangler, the Sherlock Holmes of spreadsheets, and the maestro behind the scenes transforming raw data into actionable insights – all while sipping copious amounts of coffee. As a recent graduate stepping into the thrilling world of data science, I’m on a mission to make sense of this chaotic data jungle, armed only with my trusty laptop and an insatiable curiosity... Objective is to gain as much knowledge as possible

Related Post