Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restart apache on Docker

I am trying to update my .htaccess file on a Docker container. After updating the file I need to restart Apache. Whenever I try to restart Apache: with the command service apache2 restart I get the following error:

(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down Unable to open logs Action 'start' failed. The Apache error log may have more information. ...fail!

When I got to the error log it doesn't have any new errors. This is what my Dockerfile looks like:

    FROM ubuntu:12.04

# Install dependencies
RUN apt-get update -y
RUN apt-get install -y git curl apache2 php5 libapache2-mod-php5 php5-mcrypt php5-mysql php5-curl vim

# Install app
RUN rm -rf /var/www/ *
ADD src /var/www

# Configure apache
RUN a2enmod rewrite
RUN chown -R www-data:www-data /var/www
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2

EXPOSE 80

CMD ["/usr/sbin/apache2", "-D",  "FOREGROUND"]
like image 231
Tyler Hilbert Avatar asked Dec 04 '22 00:12

Tyler Hilbert


1 Answers

Actually you don't need to restart Apache in order to apply changes defined in .htaccess - those are applied during runtime. If you're modifying apache config file (like virtual host definition or something in httpd.conf) you can also reload config without restarting apache using

sudo /etc/init.d/apache2 reload
like image 76
Rafal Kozlowski Avatar answered Dec 06 '22 15:12

Rafal Kozlowski