Setting Up WordPress with LAMP Stack: A Step-by-Step Guide


Configuring LAMP Stack for Hosting Websites: A Comprehensive Guide

# Update package information
sudo apt update
# Install Apache2 web server
sudo apt install apache2
# Start Apache2
sudo systemctl start apache2
# Check Apache2 status
sudo systemctl status apache2
# Once Apache2 is installed, test it by accessing your server’s IP in your browser:
# http://server_ip/
# For local testing: http://127.0.0.1/ or http://localhost/
# Install MariaDB server and client
sudo apt install mariadb-server mariadb-client
# Start MariaDB
sudo systemctl start mysql
# Check MariaDB status
sudo systemctl status mysql
# Secure MariaDB installation
sudo mysql_secure_installation
# Install PHP and required modules
sudo apt install php libapache2-mod-php php-opcache php-cli php-gd php-curl php-mysql
# Restart Apache2 after PHP installation
sudo systemctl restart apache2
# Create a PHP info file
echo "
<?php
phpinfo ();
?>
" | sudo tee /var/www/html/phpinfo.php
# Open a browser and type in your IP address/phpinfo.php
# http://server_ip/phpinfo.php
# Install phpMyAdmin and required PHP modules
sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl
# Restart Apache2 after phpMyAdmin installation
sudo systemctl restart apache2
# If phpMyAdmin page is not found, include its configuration and restart Apache2
# echo "Include /etc/phpmyadmin/apache.conf" | sudo tee -a /etc/apache2/apache2.conf
# If you encounter login problems, reset the root password for MySQL
# Access MySQL as root
# sudo mysql
# Then run the following SQL command to change the password
# ALTER USER root@localhost IDENTIFIED BY "yourpassword";


Installing WordPress with MariaDB: A Complete Walkthrough

# Update package information
sudo apt update
# Create a directory to store website files
sudo mkdir -p /var/www/html/
# Navigate to the website directory
cd /var/www/html/
# Download the latest version of WordPress
wget https://wordpress.org/latest.zip
# Install the 'unzip' utility
sudo apt install unzip
# Extract the downloaded WordPress zip file
sudo unzip latest.zip -d /var/www/html/
# Rename the extracted WordPress folder to the desired website root folder name
sudo mv wordpress/ website_root_folder_name/
# Access MariaDB as root user
sudo mariadb -u root -p
# Inside MariaDB, create a new database
# Replace 'database_name', 'database_username', and 'database_password' with your desired values
create database database_name;
# Grant privileges to the database user
grant all privileges on database_name.* to database_username@localhost identified by 'database_password';
# Refresh privileges and exit MariaDB
flush privileges;
exit;
# Navigate to the WordPress root directory
cd website_root_folder_name/
# Create a copy of the WordPress configuration file
sudo cp wp-config-sample.php wp-config.php
# Edit the WordPress configuration file
sudo nano wp-config.php
# Modify the database credentials in the configuration file
# Change the following lines to match your database details
# define('DB_NAME', 'database_name');
# define('DB_USER', 'database_username');
# define('DB_PASSWORD', 'database_password');
# Change ownership of the website files to the web server user
sudo chown -R www-data:www-data /var/www/html/website_root_folder_name/*


Comments

Popular Posts