Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

按照教程docker里面的nginx配置该怎么做? #69

Closed
LF-Wow opened this issue Dec 3, 2020 · 2 comments
Closed

按照教程docker里面的nginx配置该怎么做? #69

LF-Wow opened this issue Dec 3, 2020 · 2 comments

Comments

@LF-Wow
Copy link

LF-Wow commented Dec 3, 2020

现在前置都完成了,迁移什么的都做好了,访问网址一直是404
image
image
还有个问题发现通过脚本创建的mysql容器,无法进入mysql,没有密码,这里的mysql是自己重启的一个

@LF-Wow
Copy link
Author

LF-Wow commented Dec 3, 2020

已经解决了。是我不懂PHP配置的原因贴一下解决办法吧。

docker ps 查看一下laradock_php-fpm_1的ID

然后docker inspect containerID (可查看container内部IP以及port信息) 查看laradock_php-fpm_1在IP地址,填在下面的配置中

server {
    listen 80;
    server_name example.com; # 因为我这里是Ubuntu下的docker,所以填的是Ubuntu的地址,在局域网访问,本机随意
    root /var/www/laradock/dsshop/api/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;填laradock_php-fpm_1 的地址,默认端口9000
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

还要一个问题,需要给storage文件夹777权限

chmod -R 777 /dsshop/api/storage
chmod -R 777 /dsshop/api/bootstrap

mysql容器问题

我通过手动运行mysql解决的密码问题,因为docker小白,没有root密码,面向百度编程也没找到进入mysql建库的方法,索性手动新建一个mysql容器,指定root密码

  docker run -d -it --name=laradock_mysql_1 -e MYSQL_ROOT_PASSWORD=zhang123 laradock_mysql

@LF-Wow LF-Wow closed this as completed Dec 3, 2020
@dspurl
Copy link
Owner

dspurl commented Dec 3, 2020

了解下laradock和docker-compose,你会发现另一片天空

@LF-Wow LF-Wow reopened this Dec 4, 2020
@dspurl dspurl closed this as completed Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants