Skip to content

Instantly share code, notes, and snippets.

@idembele70
Last active May 1, 2024 19:29
Show Gist options
  • Save idembele70/cbe267626cb53f29545539dfdf497020 to your computer and use it in GitHub Desktop.
Save idembele70/cbe267626cb53f29545539dfdf497020 to your computer and use it in GitHub Desktop.
Run wordpress locally on Ubuntu

install LAMP (Linux Apache Mysql Php)

Installing Apache 2

  1. Update package manager
sudo apt update
  1. Install Apache
sudo apt install apache2
  1. Go to http://localhost/
  2. You should be able to see this page image

Installing MySQL

  1. Install mysql
sudo apt install mysql-server
  1. Start MySQL interactive installation & follow the different steps to install it
sudo mysql_secure_installation
  1. Create an admin user on MySQL & grant all privileges on each database
sudo mysql
CREATE USER 'EXAMPLE_USER'@'%' IDENTIFIED BY 'CUSTOM_PASSWORD';
GRANT ALL ON *.* TO 'EXAMPLE_USER'@'%';
  1. To connect to MySQL with this new user
mysql -u EXAMPLE_USER -p

Installing PHP

  1. Install PHP
sudo apt install php libapache2-mod-php php-mysql
  1. Restart apache2
sudo systemctl restart apache2

Source

  1. https://www.digitalocean.com/community/tutorials/how-to-install-lamp-stack-on-ubuntu

Install PHP MY ADMIN

WARNING :phpmyadmin cannot be installed without LAMP

  1. Update package manager
sudo apt update
  1. Installing phpmyadmin & it's dependencies

    sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl
    • WARNING: when configuration prompts appears hit SPACE to select Apache2
    • Select YES when prompted to use dbconfig-common
    • If an error occur while installing the database, follow the step in this section
  2. Make Apache & Php work with PHPMyAdmin

sudo phpenmod mbstring
  1. Restart apache service
sudo systemctl restart apache2
  1. Go To http://localhost/phpmyAdmin
  2. You should be able to see this page
    image

Source 1.https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu

Run your Wordpress site locally on Ubuntu

  1. Download a Wordpress folder zip file from the official website
wget -c http://wordpress.org/latest.tar.gz
  1. Unzip this zip file to a location of your choice
tar -xzvf latest.tar.gz -C /path/to/destination
  1. remove the zip file
rm latest.tar.gz
  1. Go to your extracted folder location
cd /path/to/extracted/file/location
  1. If you wish, you can rename the extracted folder
mv EXTRACTED_FOLDER_NAME_OLD_NAME EXTRACTED_FOLDER_NAME_NEW_NAME
  1. Move the extracted folder to the Apache var/www/ folder
sudo mv EXTRACTED_FOLDER_NAME /var/www/
  1. Assign the user you're currently logged on to ownership of the directory
sudo chown -R $USER:$USER /var/www/EXTRACTED_FOLDER_NAME
  1. Give write permissions to the folder owner
sudo chmod -R 755 /var/www/EXTRACTED_FOLDER_NAME
  1. Create a new configuration file
sudo nano /etc/apache2/sites-available/EXTRACTED_FOLDER_NAME.conf
  1. Add the following configuration block to the configuration file
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName YOUR_DOMAIN
    ServerAlias www.YOUR_DOMAIN
    DocumentRoot /var/www/YOUR_DOMAIN
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
  1. Enable the configuration file
sudo a2ensite EXTRACTED_FOLDER_NAME.conf
  1. test the configuration
sudo apache2ctl configtest
  1. Expected outuput

Capture d’écran du 2024-05-01 14-12-06

  1. Restart Apache to implement your changes
sudo systemctl restart apache2
  1. Go To http://localhost/
  2. You should be able to see this page image

SOURCE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment