In this project, you can find the information related to the configuration of a web server with Nginx and PhP for Wordpress.
- Docker Compose
- Linux or MacOs
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
- Run the
init.sh
with bash
sh init.sh
- Run the
docker-compose.yml
file
docker compose up --env-file .env -d
- See the result in
http://localhost:3000
- A virtual machine with Alma Linux installed, and wget, vim, unzip and tar installed.
-
Install httpd
sudo dnf install nginx -y
-
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
-
Install Wordpress on
/usr/share/nginx/html
and move the contents to the root directorycd /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
-
Remove unnecessary files
sudo rm -rf wordpress latest.tar.gz
-
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
-
Update the database name, username, and password in the wp-config.php file
-
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;
}
-
Update the firewall rules
sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https sudo firewall-cmd --reload
-
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
-
Set SELinux to permissive mode
sudo setenforce 0
-
Open the browser and navigate to
http://<IP_ADDRESS>