Setup apache – wordpress (CLI only) for LAN

sudo apt install apache2 mariadb-server php libapache2-mod-php php-mysql
sudo apt-get install php php-mysql php-gd php-curl php-mbstring php-xml

After installation, Apache should start automatically. To verify its status, use:

sudo systemctl status apache2

Secure MySQL/MariaDB: Run the security script to harden the database setup:

sudo mysql_secure_installation

And do not forget to save the root password for mariadb in a secure place!

Create WordPress Database and User:

Log in to the MySQL/MariaDB shell:

sudo mysql -u root -p

Create a new database, user, and grant privileges (replace placeholders with your preferred values):

CREATE DATABASE wp_database;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wp_database.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Download and Extract WordPress: Navigate to Apache’s web root directory: cd /var/www/html and extract the “wordpress” folder.

sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzvf latest.tar.gz
sudo mv wordpress/* .
sudo rm -rf wordpress latest.tar.gz

Configure WordPress:
Make a copy of the sample config file in the root directory of wordpress and set it up by typing the details of wordPress database you previously configured.

sudo cp wp-config-sample.php wp-config.php
sudo nano wp-config.php

Fill in the database details (DB_NAME, DB_USER, DB_PASSWORD), and save the file.

Ensure proper file permissions for WordPress:

sudo chown -R www-data:www-data /var/www/wordpress
sudo chmod -R 755 /var/www/wordpress

We can use the default apache file to manage incoming connections to port 80. Lets edit the contents to fit our purpose. You can create a new file if you wish to do so.

sudo nano /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
	ServerName LAN-WP

	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/wordpress

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Ensure that the DocumentRoot directive points to the WordPress directory.

Lets enable the site by typing:

sudo a2ensite 000-default.conf

Restart the apache server

sudo systemctl reload apache2

Open a web browser and navigate to your server’s IP address or domain.
Follow the WordPress installation prompts to complete the setup (e.g., select language, set up admin user, etc.).

Complete Installation:

Log in to the WordPress admin dashboard and start configuring your site. That should get WordPress up and running on your Debian server with Apache and MariaDB. Adjust configurations as needed and follow WordPress best practices for security and optimization.