Skip to content

Instantly share code, notes, and snippets.

@ttodua
Created June 1, 2021 11:06
Show Gist options
  • Save ttodua/82e2acdbc4965fef1cc1dad0ade96671 to your computer and use it in GitHub Desktop.
Save ttodua/82e2acdbc4965fef1cc1dad0ade96671 to your computer and use it in GitHub Desktop.
WP & php 7.4 (zts) & docker
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
docker build -t wordpress-php80zts .
pause 8888
FROM ubuntu:20.04
RUN apt-get update
RUN apt-get -y install php-cli curl
ARG WPVERSION='5.7.2'
#Install phpbrew
RUN curl -L -O https://github.com/phpbrew/phpbrew/releases/latest/download/phpbrew.phar
RUN chmod +x phpbrew.phar
RUN mv phpbrew.phar /usr/local/bin/phpbrew
#Init phpbrew
RUN mkdir -p /opt/phpbrew
RUN phpbrew init --root=/opt/phpbrew
RUN echo "source ~/.phpbrew/bashrc" >> /root/.bashrc
RUN bash -c "source ~/.phpbrew/bashrc"
#Install necessary libs
RUN apt-get -y install apache2 autoconf build-essential apache2-dev \
libxml2-dev libssl-dev sqlite3 libsqlite3-dev libmysqlclient-dev libz3-dev libbz2-dev libzip-dev \
libcurl4-openssl-dev libonig-dev libpspell-dev libreadline-dev libsodium-dev libxslt-dev libgd-dev curl zip
#Compile PHP 7.4
RUN phpbrew --debug install 7.4 +default +mysql +sqlite +mb +debug +fpm +intl +zip +mbstring +pcntl +mbregex \
+openssl=/usr/local/opt/openssl +bz2=/usr/local/opt/bzip2 +zlib=/usr/local/opt/zlib \
+apxs2=/usr/bin/apxs2 -- --enable-maintainer-zts
#sudo chmod -R 777 ~/.phpbrew/
#Switch to PHP 7.4
RUN bash -c "source ~/.phpbrew/bashrc; phpbrew switch php-7.4.19"
RUN bash -c "source ~/.phpbrew/bashrc; phpbrew ext install parallel -- --enable-parallel-coverage --enable-parallel-dev"
RUN a2enmod rewrite
RUN sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf
WORKDIR /var/www/html
RUN curl -o wordpress.tar.gz -fL "https://wordpress.org/wordpress-$WPVERSION.tar.gz";
RUN tar -xzf wordpress.tar.gz -C /usr/src/; rm wordpress.tar.gz;
COPY .htaccess /usr/src/wordpress/.htaccess
RUN chown -R www-data:www-data /usr/src/wordpress;
#RUN cp -rp /usr/src/wordpress/./ /var/www/html/
EXPOSE 80 443
#VOLUME [/var/www/html]
COPY .htaccess /usr/src/.htaccess
COPY entrypoint.sh /bin/entrypoint.sh
#ENTRYPOINT ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
ENTRYPOINT ["/bin/bash", "/bin/entrypoint.sh"]
#!/bin/bash
#
echo "Running entrypoint.sh"
if [ ! -d /var/www/html/wp-content ]; then
echo ">> Init wordpress"
cp -rp /usr/src/wordpress/./ /var/www/html/
echo "<?php phpinfo(); ?>" > /var/www/html/info.php
fi
if [ ! -f /var/www/html/.htaccess ]; then
echo <<< EOT
option +Indexes
AllowOverride all
# BEGIN WordPress
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
EOT > /var/www/html/.htaccess
fi
apachectl -D FOREGROUND
docker run -d -p 80:80 -v d:\\sample-www:/var/www/html wordpress-php74zts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment