无论我尝试什么,当我访问我的docker-machine ip时,我都会收到HTTP错误代码500.
我正在通过Docker工具箱(操作系统:Windows 10)运行laradock并运行默认VM。我按照视频中的说明设置了laradock。
我已成功将我需要的文件夹安装到VM中,并根据我在VM中的代码位置更改了docker-compose.yml:
这是我的docker-compose.yml文件:
版本:'2'
服务:
Nginx服务器容器
nginx: build: ./nginx volumes_from: - volumes_source volumes: - ./logs/nginx/:/var/log/nginx ports: - "80:80" - "443:443" links: - php-fpm
PHP-FPM容器
php-fpm: build: context: ./php-fpm dockerfile: Dockerfile-70 volumes_from: - volumes_source expose: - "9000" links: - workspace
MySQL容器
mysql: build: ./mysql volumes_from: - volumes_data ports: - "3306:3306" environment: MYSQL_DATABASE: homestead MYSQL_USER: homestead MYSQL_PASSWORD: secret MYSQL_ROOT_PASSWORD: root
PostgreSQL容器
postgres: build: ./postgres volumes_from: - volumes_data ports: - "5432:5432" environment: POSTGRES_DB: homestead POSTGRES_USER: homestead POSTGRES_PASSWORD: secret
MariaDB容器
mariadb: build: ./mariadb volumes_from: - volumes_data ports: - "3306:3306" environment: MYSQL_DATABASE: homestead MYSQL_USER: homestead MYSQL_PASSWORD: secret MYSQL_ROOT_PASSWORD: root
Neo4j容器
neo4j: build: ./neo4j ports: - "7474:7474" - "1337:1337" environment: - NEO4J_AUTH=homestead:secret volumes_from: - volumes_data
MongoDB容器
mongo: build: ./mongo ports: - "27017:27017" volumes_from: - volumes_data
Redis容器
redis: build: ./redis volumes_from: - volumes_data ports: - "6379:6379"
Memcached Container
memcached: build: ./memcached volumes_from: - volumes_data ports: - "11211:11211" links: - php-fpm
Beanstalkd容器
beanstalkd: build: ./beanstalkd ports: - "11300:11300" privileged: true links: - php-fpm
Beanstalkd控制台容器
beanstalkd-console: build: ./beanstalkd-console ports: - "2080:2080" links: - beanstalkd
Workspace Utilities Container
workspace: build: context: ./workspace args: - INSTALL_PRESTISSIMO=false volumes_from: - volumes_source tty: true
Laravel应用程序代码容器
volumes_source: build: ./volumes/application volumes: - /c/Users/pomodoro.xyz/code:/var/www/laravel
数据库数据容器
volumes_data: build: ./volumes/data volumes: - /var/lib/mysql:/var/lib/mysql - /var/lib/postgres:/var/lib/postgres - /var/lib/mariadb:/var/lib/mariadb - /var/lib/memcached:/var/lib/memcached - /var/lib/redis:/data - /var/lib/neo4j:/var/lib/neo4j/data - /var/lib/mongo:/data/db
在
下添加更多容器
当我登录工作区并更改文件时,它们会反映到主机上,所以我很擅长这方面。
这是我的工作容器中的文件夹结构(就像视频一样):
root@d463d55e545b:/var/www/laravel# ls -l
total 30
drwxrwxrwx 1 1000 staff 4096 Jul 20 19:58 app
-rwxrwxrwx 1 1000 staff 1646 Jul 20 19:58 artisan
drwxrwxrwx 1 1000 staff 0 Jul 20 19:58 bootstrap
-rwxrwxrwx 1 1000 staff 1272 Jul 20 19:58 composer.json
drwxrwxrwx 1 1000 staff 4096 Jul 20 19:58 config
drwxrwxrwx 1 1000 staff 4096 Jul 20 19:58 database
-rwxrwxrwx 1 1000 staff 503 Jul 20 19:58 gulpfile.js
-rwxrwxrwx 1 1000 staff 12 Jul 21 15:13 index.html
drwxrwxrwx 1 1000 staff 4096 Jul 23 09:24 laradock
-rwxrwxrwx 1 1000 staff 212 Jul 20 19:58 package.json
-rwxrwxrwx 1 1000 staff 1026 Jul 20 19:58 phpunit.xml
drwxrwxrwx 1 1000 staff 4096 Jul 23 10:39 public
-rwxrwxrwx 1 1000 staff 1918 Jul 20 19:58 readme.md
drwxrwxrwx 1 1000 staff 0 Jul 20 19:58 resources
-rwxrwxrwx 1 1000 staff 567 Jul 20 19:58 server.php
drwxrwxrwx 1 1000 staff 0 Jul 20 19:58 storage
drwxrwxrwx 1 1000 staff 0 Jul 20 19:58 tests
drwxrwxrwx 1 1000 staff 0 Jul 20 19:59 vendor
所有nginx.conf文件等都被加载到容器中,我可以从docker exec -it看到我的nginx容器。
供参考,这是我的laravel.conf
服务器{ listen 80 default_server; listen [::]:80 default_server ipv6only = on;
root /var/www/laravel/public; index index.php index.html index.htm;
server_name laravel.dev www.laravel.dev;
location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { try_files $uri /index.php =404; fastcgi_pass php-upstream; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; }
}
和nginx.conf:
用户www-data; worker_processes 4; pid /run/nginx.pid;
活动{ worker_connections 2048; multi_accept on; 使用epoll; }
http { server_tokens off; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 15; types_hash_max_size 2048; client_max_body_size 20M; 包括/etc/nginx/mime.types; default_type application / octet-stream; access_log on; error_log on; gzip on; gzip_disable“msie6”; include /etc/nginx/conf.d/.conf; 包括/ etc / nginx / sites-available / ; open_file_cache max = 100; }
守护进程关闭;
这是我的laravel根目录的.env文件:
APP_ENV =本地 APP_DEBUG =真 APP_KEY = SomeRandomString APP_URL = http://localhost
DB_CONNECTION = MySQL的 DB_HOST = 192.168.99.100 DB_PORT = 3306 DB_DATABASE =家园 DB_USERNAME =家园 DB_PASSWORD =秘密
CACHE_DRIVER =文件 SESSION_DRIVER =文件 QUEUE_DRIVER =同步
REDIS_HOST = 192.168.99.100 REDIS_PASSWORD = NULL REDIS_PORT = 6379
MAIL_DRIVER = SMTP MAIL_HOST = mailtrap.io MAIL_PORT = 2525 MAIL_USERNAME = NULL MAIL_PASSWORD = NULL MAIL_ENCRYPTION =空
我还通过登录工作区容器并键入:
来设置文件夹的权限chmod -R 777存储引导程序/缓存
但我仍然在docker-machine ip上遇到http 500错误。我错过了什么?
答案 0 :(得分:0)
我看到的一个潜在问题是您在.env中使用服务主机(DB_HOST,REDIS_HOST)的IP地址。这些IP地址可能会发生变化,因此使用容器名称作为主机地址更安全。在你的情况下,你想使用" DB_HOST = mysql"和" REDIS_HOST = redis"。
http 500意味着您的nginx配置可能没有任何问题,听起来更像是Laravel配置问题。我建议您检查一下您的laravel日志文件(storage/logs/laravel.log
)以获取更多信息。