Laravel Apache和Docker权限被拒绝

问题描述 投票:2回答:1

嗨,

我遇到此错误

“权限被拒绝”

我不明白,我检查了Apache和docker-compose中的路径。我检查有关laravel输入php artisan的正确安装

“就可以了”我正确打开了phpinfo(blog / info.php)文件和test2.php(blog / public / test2.php)文件我试图将权限777设置到我的docker容器内的所有文件和目录,但什么也没有。“目录树”我想查看laravel安装的正确基础页面,并开始研究此框架。

这是我的Apache配置文件:

    <VirtualHost *:80>
    ServerName foxsimracing
    DocumentRoot /var/www/html/public
    ErrorLog /var/log/httpd/error.log
    Options Indexes FollowSymLinks
    ServerAdmin [email protected]

    <Directory /var/www/html/public>
        AllowOverride all

        <IfVersion < 2.4>
            Allow from all
        </IfVersion>

        <IfVersion >= 2.4>
            Require all granted
        </IfVersion>
    </Directory>
</VirtualHost>

这是我的Dockerfile

FROM php:7.2-apache
RUN apt-get update
RUN apt-get install -y apt-utils zip unzip
RUN apt-get install -y vim
RUN docker-php-ext-install pdo_mysql mysqli bcmath

# Installing xdebug
RUN pecl install xdebug
RUN docker-php-ext-enable xdebug

# Installing composer
RUN curl -sS https://getcomposer.org/installer | php

RUN useradd -o -u 1000 -g www-data -m -s /bin/bash www
RUN chown -R www-data:www-data /var/www

# Clean up APT when done.
RUN apt-get autoremove -y
WORKDIR /var/www/html/
EXPOSE 80

这是我的docker-compose文件

version: '3'

services:
foxsimracing_app:
    build:
        context: ./foxsimracing_app
        dockerfile: Dockerfile
    container_name: foxsimracing_app
    ports:
        - "8080:80"
    volumes:
        - ./foxsimracing_app/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
        - ./foxsimracing_app/custom.conf:/etc/apache2/sites-available/custom.conf
        - ../../repo/foxsimracinghardware/blog:/var/www/html
    networks:
        - laravel
    depends_on:
        - mysql

mysql:
    image: mysql:5.7.29
    container_name: foxsimracing_mysql
    restart: unless-stopped
    tty: true
    ports:
        - 3306:3306
    volumes:
        - ./mysql:/var/lib/mysql
    environment:
        MYSQL_DATABASE: foxsimracing
        MYSQL_USER: simracing
        MYSQL_PASSWORD: simracing
        MYSQL_ROOT_PASSWORD: root
    networks:
        - laravel

phpmyadmin:
    container_name: foxsimracing_phpmyadmin
    image: phpmyadmin/phpmyadmin
    ports:
        - "8088:80"
    environment:
        PMA_HOST: mysql
        MYSQL_ROOT_PASSWORD: root
    depends_on:
        - mysql
    networks:
        - laravel

networks:
laravel:

laravel应用中的我的.env文件

APP_NAME=foxsimracing
APP_ENV=local
APP_KEY=base64:/JPnIdjIdzyxw4N85h2Bl13K3m9qHoO//SPoMxqBfq4=
APP_DEBUG=true
APP_URL=http://localhost

有人可以帮我吗?

laravel docker permission-denied
1个回答
3
投票

我终于发现问题出在apache配置中。我将其放在/ etc / apache2 / sites-available中,这是错误的,因为我不得不将其放入/ etc / apache2 / sites-enabled。我搬入/ etc / apache2 / sites-enabled,它可以正常工作!我希望这对其他人有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.