I've installed Laradock but can not setup multiple projects on localhost for development.
1) Cloning Laradock git repo
git clone https://github.com/Laradock/laradock.git
2) Creating several project folders
- laradock
- new-project
﹂index.php
- test-project
﹂index.php
3) Setting up Nginx config files for each project
laradock/nginx/sites/new-project.conf
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name ~^(?<project>.+)\.laradock\.dev$;
root /var/www/$project;
index index.php index.html index.htm;
...
}
And the same config for laradock/nginx/sites/test-project.conf
4) Compose
docker-compose up -d nginx mysql phpmyadmin
As the result Nginx container fails:
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3189cee03979 laradock_nginx "/bin/bash /opt/star…" 6 seconds ago Exited (1) 4 seconds ago laradock_nginx_1
b078751511b4 laradock_php-fpm "docker-php-entrypoi…" 6 seconds ago Up 5 seconds 9000/tcp laradock_php-fpm_1
e4c2eab1cd2b laradock_phpmyadmin "/docker-entrypoint.…" 8 seconds ago Up 6 seconds 0.0.0.0:8081->80/tcp laradock_phpmyadmin_1
d2f5ce2fdda4 laradock_workspace "/sbin/my_init" 8 seconds ago Up 6 seconds 0.0.0.0:3000-3001->3000-3001/tcp, 0.0.0.0:8080->8080/tcp, 0.0.0.0:2222->22/tcp, 0.0.0.0:8001->8000/tcp laradock_workspace_1
40da6b9cfdd5 laradock_mysql "docker-entrypoint.s…" 8 seconds ago Up 7 seconds 0.0.0.0:3306->3306/tcp, 33060/tcp laradock_mysql_1
7963bf244ca6 docker:19.03-dind "dockerd-entrypoint.…" 8 seconds ago Up 7 seconds 2375-2376/tcp laradock_docker-in-docker_1
But if I remove config file from nginx/sites
and leave just one of them working ie test-project.conf
it works fine as for one project. I enter localhost
in address bar and it loads the page correctly just in case if there is one config file in nginx/sites
but not two of or more.
How to setup Nginx config files properly to handle multiple projects on localhost? Is there any way to hardcode server_name
value instead of using variable $project
?
I copied the default.conf file for every new config. In every new created conf file i needed to remove the ssl ipv6only=on part
from this:
listen 443 ssl;
listen [::]:443 ssl ipv6only=on;
to this:
listen 443 ssl;
listen [::]:443;
I found it out because of this thread on reddit: https://www.reddit.com/r/laravel/comments/9ubn31/laradock_nginx_issue_for_multi_site_configuration/
Now it works fine. Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.