Wordpress - NGINX - PHP

In this project, you can find the information related to the configuration of a web server with Nginx and PhP for Wordpress.

Docker

Requirements

  • Docker Compose
  • Linux or MacOs

Usage

Before running the project, you need to create a .env file with the following variables:

MYSQL_ROOT_PASSWORD=your_root_password
MYSQL_DATABASE=your_database
MYSQL_USER=your_user
MYSQL_PASSWORD=your_password
  1. Run the init.sh with bash
sh init.sh
  1. Run the docker-compose.yml file
docker compose up --env-file .env -d
  1. See the result in http://localhost:3000

Virtual Machine (Alma Linux)

Requirements

  • A virtual machine with Alma Linux installed, and wget, vim, unzip and tar installed.
  1. Install httpd

    sudo dnf install nginx -y
  2. Install PHP extensions

    sudo dnf install php php-mysqlnd php-fpm php-gd php-xml php-mbstring php-json php-opcache php-zip php-curl -y
  3. Install Wordpress on /usr/share/nginx/html and move the contents to the root directory

    cd /usr/share/nginx/html
    sudo wget https://wordpress.org/latest.tar.gz
    sudo tar -xvzf latest.tar.gz
    sudo mv wordpress/* /usr/share/nginx/html
  4. Remove unnecessary files

    sudo rm -rf wordpress latest.tar.gz
  5. Copy the wp-config-sample.php file to wp-config.php

    sudo cp /usr/share/nginx/html/wp-config-sample.php /usr/share/nginx/html/wp-config.php
  6. Update the database name, username, and password in the wp-config.php file

  7. Verify if the file is present, otherwise create and add the following config for the server to read PHP files

  • /etc/nginx/conf.d/php-fpm.conf
upstream php-fpm {
  server unix:/run/php-fpm/www.sock;
}
  1. Update the firewall rules

    sudo firewall-cmd --permanent --add-service=http
    sudo firewall-cmd --permanent --add-service=https
    sudo firewall-cmd --reload
  2. Start and enable the httpd and php-fpm services

    sudo systemctl start nginx
    sudo systemctl enable nginx
    sudo systemctl start php-fpm
    sudo systemctl enable php-fpm
  3. Set SELinux to permissive mode

    sudo setenforce 0
  4. Open the browser and navigate to http://<IP_ADDRESS>