Apache fixes

This commit is contained in:
Andrei Condurachi 2020-11-23 20:35:46 +02:00
parent be25e9092b
commit e19579c5e4
2 changed files with 9 additions and 29 deletions

View File

@ -76,6 +76,8 @@ RUN \
# Make sure PHP-FPM executes as apache user # Make sure PHP-FPM executes as apache user
sed -i 's/user = nobody/user = apache/g' /etc/php7/php-fpm.d/www.conf && \ sed -i 's/user = nobody/user = apache/g' /etc/php7/php-fpm.d/www.conf && \
sed -i 's/group = nobody/group = apache/g' /etc/php7/php-fpm.d/www.conf && \ sed -i 's/group = nobody/group = apache/g' /etc/php7/php-fpm.d/www.conf && \
# Shortcut cli commands
echo 'alias l="ls -la"; alias s="cd .."' >> ~/.profile && \
# Prepare Apache log dir # Prepare Apache log dir
mkdir -p /var/log/apache2 && \ mkdir -p /var/log/apache2 && \
# Clean base directory # Clean base directory
@ -89,8 +91,6 @@ RUN \
RUN chown -R apache:apache /var/www RUN chown -R apache:apache /var/www
# Make sure apache can read&right to logs # Make sure apache can read&right to logs
RUN chown -R apache:apache /var/log/apache2 RUN chown -R apache:apache /var/log/apache2
# Apache access to creating pid
RUN chown -R apache:apache /run/apache2
### Continue execution as Apache user ### ### Continue execution as Apache user ###
USER apache USER apache
@ -136,7 +136,11 @@ RUN chown -R apache:apache /var/www
# Make sure apache can read&right to logs # Make sure apache can read&right to logs
RUN chown -R apache:apache /var/log/apache2 RUN chown -R apache:apache /var/log/apache2
# Allow apache user login # Allow apache user login
RUN sed -i 's/apache(.*)\/sbin\/nologin/apache\1\/bin\/ash/g' /etc/passwd RUN sed -i 's/apache(.*)\/sbin\/nologin/apache\\1\/bin\/ash/g' /etc/passwd
# Provide container inside image for data persistence # Provide container inside image for data persistence
VOLUME ["/var/www"] VOLUME ["/var/www"]
COPY run.sh /run.sh
RUN chmod u+x /run.sh
CMD ["/run.sh"]

28
run.sh
View File

@ -1,28 +1,4 @@
#!/bin/sh #!/bin/sh
# syslog option '-Z' was changed to '-t', change this in /etc/conf.d/syslog so that syslog (and then cron) actually starts # Allow Apache to create pid
# https://gitlab.alpinelinux.org/alpine/aports/-/issues/9279 RUN chown -R apache:apache /run/apache2
sed -i 's/SYSLOGD_OPTS="-Z"/SYSLOGD_OPTS="-t"/g' /etc/conf.d/syslog
# Restart the syslog
rc-service syslog restart
# Restart the kernel log deamon
rc-service klogd restart
# Start cron by default
rc-update add crond default && rc-service crond start
# Start Apache by default
rc-update add httpd default && rc-service httpd start
# default PHP-FPM by default
rc-update add php-fpm7 default && rc-service php-fpm7 start
# Create cron job for Grav maintenance scripts
(crontab -l; echo "* * * * * cd /var/www/html;/usr/bin/php bin/grav scheduler 1>> /dev/null 2>&1") | crontab -
# Cron requires that each entry in a crontab end in a newline character. If the last entry in a crontab is missing the newline, cron will consider the crontab (at least partially) broken and refuse to install it.
(crontab -l; echo "") | crontab -
# Make sure apache can read&right to docroot
chown -R apache:apache /var/www
# Make sure apache can read&right to logs
chown -R apache:apache /var/log/apache2
# Allow apache user login
sed -i 's/apache(.*)\/sbin\/nologin/apache\1\/bin\/ash/g' /etc/passwd