我正在尝试使用Apple上的终端(使用PHP)连接到我的MySQL数据库.
昨天它工作正常,现在我突然得到标题中的错误.
当我使用浏览器运行它时(我安装了XAMPP),脚本可以工作,但终端拒绝连接到数据库.
这是我包含连接的文件(当我不包含此脚本时脚本工作,但它不连接到DB):
<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("FNB1C_data") or die(mysql_error());
?>
Run Code Online (Sandbox Code Playgroud)
这应该工作,因为它适用于我的浏览器.
我在终端使用的命令是php scriptname.php.
这是我的docker-compose.yml
version: '2'
services:
nginx:
image: nginx:1.11.8-alpine
ports:
- "8081:80"
volumes:
- ./code:/usr/share/nginx/html
- ./html:/myapp
- ./site.conf:/etc/nginx/conf.d/site.conf
- ./error.log:/var/log/nginx/error.log
- ./nginx.conf:/etc/nginx/nginx.conf
Run Code Online (Sandbox Code Playgroud)
这是site.conf
server {
listen 8081;
index index.html index.php;
server_name localhost;
error_log /var/log/nginx/error.log;
location /html {
root /myapp;
}
}
Run Code Online (Sandbox Code Playgroud)
http://nginx-php-docker.local:8081 /这是工作,显示文件index.html里面/代码文件夹
但它无法使用http://nginx-php-docker.local:8081/html
错误日志是:2017/01/13 08:50:27 [错误] 7#7:*4打开()"/ usr/share/nginx/html/html"失败(2:没有这样的文件或目录),客户端:172.19.0.1,server:localhost,request:"GET/html HTTP/1.1",host:"nginx-php-docker.local:8081"
请告诉我哪里错了.