我有两个Laravel项目
with 664 user:www-data permission with 664 user:www-data permission 注意: moduletwo是在这个虚拟主机中用来指向Laravel 5文件的别名。 我正在尝试在本地机器上configurationLaravel 4作为主项目,而Laravel 5将作为Nginx虚拟主机中的别名。
Laravel 4运行良好,没有问题。
但是当我尝试访问Laravel 5模块时,它说File not found. 这里是日志 :
access.log的:
GET `/moduletwo/index.php/LFiveRoute HTTP/1.1" 404 27 "http://www.Laravel.dev/LFourRoute`
error.log中:
FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.22.0.1, server: www.Laravel.dev, request: "GET /moduletwo/index.php/LFiveRoute HTTP/1.1", upstream: "fastcgi://172.22.0.5:9000", host: "www.Laravel.dev", referrer: "http://www.Laravel.dev/LFourRoute
script.log:
/var/www/Laravel4/public/moduletwo/index.php > GET /moduletwo/index.php/LFiveRoute HTTP/1.1
Nginx容器中的进程
Nginx主/工作进程
ps -ef | grep 'nginx' root 1 0 0 06:15 ? 00:00:00 nginx: master process nginx -g daemon off; www-data 7 1 0 06:16 ? 00:00:00 nginx: worker process root 19 8 0 07:45 ? 00:00:00 grep nginx
fpm过程
ps -ef | grep 'fpm' root 21 8 0 07:47 ? 00:00:00 grep fpm
PHP71容器中的进程
Nginx主/工作进程
none
fpm过程
ps -ef | grep fpm root 1 0 0 06:15 ? 00:00:00 php-fpm: master process (/usr/local/etc/php-fpm.conf) www-data 8 1 0 06:16 ? 00:00:01 php-fpm: pool www www-data 9 1 0 06:17 ? 00:00:01 php-fpm: pool www www-data 10 1 0 06:22 ? 00:00:01 php-fpm: pool www root 22 13 0 07:49 ? 00:00:00 grep fpm
Docker撰写文件:
version: '2' services: nginx: container_name: Laravel-nginx restart: always build: context: ./ dockerfile: deploy/web.docker volumes: - ./:/var/www/Laravel4 - ./../Laravel_5:/var/www/Laravel5 - ./app/storage/logs/nginx:/var/log/nginx ports: - "80:80" links: - php71 networks: Laravel_net: ipv4_address: 172.22.0.2 database: container_name: Laravel-db restart: always image: mysql:5.7 environment: - "MYSQL_ROOT_PASSWORD=secret" - "MYSQL_ROOT_USER=root" - "MYSQL_DATABASE=laravel_4" ports: - "3309:3306" networks: Laravel_net: ipv4_address: 172.22.0.3 redis: container_name: Laravel-redis image: redis:3.2 ports: - "6372:6379" networks: Laravel_net: ipv4_address: 172.22.0.4 php71: container_name: Laravel-php-71 restart: always build: context: ./ dockerfile: deploy/app.docker volumes: - ./:/var/www/Laravel4 - ./../Laravel_5:/var/www/Laravel5 links: - database - redis environment: - "DB_PORT=3306" - "DB_HOST=database" networks: Laravel_net: ipv4_address: 172.22.0.5 networks: Laravel_net: driver: bridge ipam: driver: default config: - subnet: 172.22.0.0/16 gateway: 172.22.0.1
web.docker文件:
FROM nginx:1.10 EXPOSE 80 EXPOSE 443 ADD ./deploy/vhost.conf /etc/nginx/conf.d/default.conf ADD ./deploy/nginx.conf /etc/nginx/nginx.conf WORKDIR /var/www
app.docker文件:
FROM php:7.0-fpm RUN apt-get update && apt-get install -y libmcrypt-dev mysql-client \ && docker-php-ext-install mcrypt pdo_mysql WORKDIR /var/www
nginx.conf文件
user www-data; worker_processes 1; pid /var/run/nginx.pid; error_log /var/log/nginx/error.log warn; events { # A single worker process can handle 1024 connections worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; log_format scripts '$document_root$fastcgi_script_name > $request'; access_log /var/log/nginx/scripts.log scripts; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; # Load config files from the /etc/nginx/conf.d directory # The default server is in conf.d/default.conf include /etc/nginx/conf.d/*.conf; }
vhost.conf文件:
server { listen 80; server_name www.laravel.dev; charset utf-8; sendfile off; client_max_body_size 100m; index index.php; root /var/www/Laravel4/public; location ~ ^/moduletwo/(.+(?:css|js|woff|woff2|ttf))$ { include fastcgi_params; alias /var/www/Laravel5/public/$1; #access_log off; } #moduletwo code in laravel5 location /moduletwo/ { include fastcgi_params; alias /var/www/Laravel5/public; ## Check for file existing and if there, stop ## if (-f $request_filename) { break; } ## Check for file existing and if there, stop ## if (-d $request_filename) { break; } index index.php; try_files $uri $uri/ @moduletwo; # try_files $uri $uri/ /index.php?$query_string; } location @moduletwo { include fastcgi_params; rewrite /moduletwo/(.*)$ /moduletwo/index.php?/$1 last; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass php71:9000; fastcgi_index index.php; set $php_root /var/www/Laravel4/public; if ($request_uri ~ /moduletwo) { set $php_root /var/www/Laravel5/public; } fastcgi_param PATH_TRANSLATED $php_root/index.php; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_param REMOTE_ADDR $http_x_real_ip; include fastcgi_params; fastcgi_intercept_errors off; fastcgi_buffer_size 128k; fastcgi_buffers 256 16k; fastcgi_max_temp_file_size 0; fastcgi_read_timeout 310; } location / { try_files $uri $uri/ /index.php?$query_string; } location ~ /\.ht { deny all; } }
那么,有人在吗? 请仔细研究并帮助我解决问题。 非常感谢。