machine
machine copied to clipboard
403 forbidden - permission to access / on this server issue
For hours I have been searching everywhere and trying LOTS of suggestions to get this working and nothing is working, so forgive if I am posting something that has been said before.
Using Docker Toolbox on my Windows 10 machine
Dockerfile: FROM php:7-apache EXPOSE 80
docker-compose.yml: version: '2' services: webserver: build: ./docker/webserver image: dcebooks1 ports: - "80:80" - "443:443" volumes: - /DockerImage/www:/var/www/html links: - db
db: image: mysql:5.7 ports: - "3306:3306" volumes: - ./db:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=docker - MYSQL_DATABASE=db_runwaytest
The container loads just fine. I can see them running when I do a docker ps -a. And when I hit it with the web server, I can see it responding, so I know it is making the connection at the standard docker IP 192.168.99.100. But on my browser (Chrome) I get this error:
You don't have permission to access / on this server. Apache/2.4.25 (Debian) Server at 192.168.99.100 Port 80
And on the actual docker web server I can see this: AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive
In my /DockerImage/www directory which should point to /var/www/html, I have an index.php file that simply calls phpinfo().
I wanted to try to put a .conf file in the /etc/httpd/conf.d directory but there isn't an httpd directory for some reason. And I can't find where I should put the .conf file so I can get around the Options directive or even where the httpd.conf file is located so it can be altered.
I sure hope someone can help as I really don't know where to go next. Thanks in advance.
Hi Same issue here How can we fix it ?
Any news about this? I'm facing this issue using docker-compose. I'm using Ubuntu for Windows Pro by the Hyper-v.
Please. I really don't know what to do
DOCKER FILE
FROM php:7.1-apache
Setup timezone
ENV TZ=Europe/Dublin RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN echo "date.timezone=$TZ" >> /usr/local/etc/php/conf.d/default.ini
Update sources
RUN apt-get update -y
Enable "mod_rewrite" – http://httpd.apache.org/docs/current/mod/mod_rewrite.html
RUN a2enmod rewrite
Enable "mod_headers" – http://httpd.apache.org/docs/current/mod/mod_headers.html
RUN a2enmod headers
Enable "mod_expires" – http://httpd.apache.org/docs/current/mod/mod_expires.html
RUN a2enmod expires
Install "Git" – https://git-scm.com/
RUN apt-get install -y git
Install "Composer" – https://getcomposer.org/
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
Install Midnight Commander, Vim, Nano
RUN apt-get install -y mc vim nano
Install "mysql-client" – https://dev.mysql.com/doc/refman/5.7/en/mysql.html
RUN apt-get install -y mariadb-client
Install "ImageMagick" executable – https://www.imagemagick.org/script/index.php
RUN apt-get install -y imagemagick
Install PHP "gd" extension
RUN apt-get install -y libjpeg-dev libpng-dev RUN docker-php-ext-configure gd --with-jpeg-dir=/usr/include/ RUN docker-php-ext-install gd
Install PHP "curl" extension – http://php.net/manual/en/book.curl.php
RUN apt-get install -y zlib1g-dev libicu-dev g++ RUN apt-get install -y libcurl4-openssl-dev RUN docker-php-ext-install curl
Install PHP "intl" extension – http://php.net/manual/en/book.intl.php
RUN docker-php-ext-configure intl RUN docker-php-ext-install intl
Install PHP "xsl" extension – http://php.net/manual/en/book.xsl.php
RUN apt-get install -y libxslt-dev RUN docker-php-ext-install xsl
Install PHP "exif" extension – http://php.net/manual/en/book.exif.php
RUN apt-get install -y libexif-dev RUN docker-php-ext-install exif
Install PHP "mysqli" extension – http://php.net/manual/pl/book.mysqli.php
RUN docker-php-ext-install mysqli
Install PHP "pdo" extension with "mysql", "pgsql", "sqlite" drivers – http://php.net/manual/pl/book.pdo.php
RUN apt-get install -y libpq-dev libsqlite3-dev RUN docker-php-ext-install pdo pdo_mysql pdo_sqlite
Install PHP "opcache" extension – http://php.net/manual/en/book.opcache.php
RUN docker-php-ext-install opcache
Install PHP "zip" extension – http://php.net/manual/en/book.zip.php
RUN apt-get install -y zlib1g-dev RUN docker-php-ext-install zip
Install PHP "memcached" extension – http://php.net/manual/en/book.memcached.php
RUN apt-get install -y libmemcached-dev
&& cd /tmp
&& git clone -b php7 https://github.com/php-memcached-dev/php-memcached.git
&& cd php-memcached
&& phpize
&& ./configure
&& make
&& echo "extension=/tmp/php-memcached/modules/memcached.so" > /usr/local/etc/php/conf.d/memcached.ini
Install PHP "mcrypt" extension
RUN apt-get update && apt-get install -y libmcrypt-dev RUN docker-php-ext-install mcrypt
Cleanup the image
RUN rm -rf /var/lib/apt/lists/* /tmp/*
docker-compose.yml
version: "2" services: www: container_name: my-app image: my-image restart: unless-stopped ports: - "80:80" volumes: - .:/var/www/html/ - ./docker/config/custom.ini:/usr/local/etc/php/conf.d/custom.ini networks: - default environment: PHP__display_errors: 'On' PHP_php5enmod: 'php_mysql' PHP__date.timezone: '"Europe/Dublin"' PHP__short_open_tag: 'On'
portainer: container_name: portainer-installers image: portainer/portainer:latest restart: unless-stopped ports: - 9000:9000 volumes: - /var/run/docker.sock:/var/run/docker.sock - portainer-data:/data networks: - default volumes: portainer-data:
docker build -t installersphp .
sudo docker logs db-metrics-sistema
mysql -uroot -p
GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY 'root';
I got the same issue.
I also got the same issue.
I had the same problem today. In my case, the folder shared with the docker container also was shared with the VirtualBox host. Inside the VM and the docker container all files were owned by root, and I wasn't able to grant read access to anyone else (guess because of rights management by Virtual Box). In effect the apache user (webmaster) was denied read access to the files in /var/www/html
I finally solved the problem by copying the whole folder into another folder inside the VM and granting read access with
chmod -R 755
This may be old though if anyway is still looking for an answer @ehoetzer is correct with other Virtual Machines being the issue. I was stumped for ages and finally 'killed' all the services related to VMware (or any other virtual machine in use) and my 403 error was resolved after flushing DNS. Just a heads up for anyone that may come across this.