Skip to content

Instantly share code, notes, and snippets.

@preda-bogdan
Last active June 18, 2024 11:10
Show Gist options
  • Save preda-bogdan/b646c22c918788eaf696ca208ed40792 to your computer and use it in GitHub Desktop.
Save preda-bogdan/b646c22c918788eaf696ca208ed40792 to your computer and use it in GitHub Desktop.
Neve Debian 10 Nginx Debug

Use the following structure:

./
|_ nginx
| |_ default
|_ Dockerfile
|_ entrypoint.sh

Copy the contents from nginx-default to nginx/default Run docker build -t wordpress-nginx-mariadb-debian . Run docker run -d -p 8887:80 --name wordpress-container-neve wordpress-nginx-mariadb-debian

You can visit https://localhost8887 and run the WP install.

# Use the official Debian 10 base image
FROM debian:10
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y wget curl tar unzip
RUN apt -y install lsb-release apt-transport-https ca-certificates
RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
# Install necessary packages
RUN apt-get update && \
apt-get install -y nginx && \
apt-get install -y mariadb-server php8.2-fpm php8.2-mysql && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install WordPress
RUN wget https://wordpress.org/wordpress-6.1.6.tar.gz && \
tar -xzf wordpress-6.1.6.tar.gz && \
mv wordpress /var/www/html && \
chown -R www-data:www-data /var/www/html
# Install Neve
RUN wget https://downloads.wordpress.org/theme/neve.3.8.7.zip && \
unzip neve.3.8.7.zip && \
mkdir -p /var/www/html/wordpress/wp-content/themes/neve && \
cp -r neve/* /var/www/html/wordpress/wp-content/themes/neve && \
chown -R www-data:www-data /var/www/html/wordpress/wp-content/themes/neve
# Configure Nginx
RUN rm /etc/nginx/sites-enabled/default
COPY nginx/default /etc/nginx/sites-available/default
RUN ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/
# Configure PHP-FPM
RUN sed -i 's/listen = \/run\/php\/php8.2-fpm.sock/listen = 127.0.0.1:9000/' /etc/php/8.2/fpm/pool.d/www.conf
# Configure MariaDB
RUN service mysql start && \
mysql -e "CREATE DATABASE wordpress;" && \
mysql -e "CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'password';" && \
mysql -e "GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost';" && \
mysql -e "FLUSH PRIVILEGES;"
# Copy entrypoint script
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Expose the port for Nginx
EXPOSE 80
# Start all services
CMD ["/entrypoint.sh"]
#!/bin/bash
# Start MySQL service
service mysql start
if [ ! -f /var/lib/mysql/ibdata1 ]; then
mysql_install_db
service mysql start
mysql -e "CREATE DATABASE wordpress;"
mysql -e "CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'password';"
mysql -e "GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost';"
mysql -e "FLUSH PRIVILEGES;"
fi
# Start PHP-FPM service
service php8.2-fpm start
# Start Nginx service
service nginx start
# Keep the container running
tail -f /var/log/nginx/access.log /var/log/nginx/error.log
server {
listen 80;
server_name localhost;
root /var/www/html/wordpress;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass 127.0.0.1:9000;
}
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment