nginx를 통해 wordpress와 laravel 애플리케이션 모두 호스팅

nginx를 통해 wordpress와 laravel 애플리케이션 모두 호스팅

안타깝지만 워드프레스와 라라벨 애플리케이션이 공존할 뿐만 아니라 서로의 상태를 인지할 수 있도록 만들어야 합니다. 이 기능은 wordpress 플러그인, laravel 패키지 및 Apache 구성을 통해 작동하지만 이제 nginx를 웹 서버로 사용하려면 구성을 변환해야 합니다.

내 저장소는 다음과 같이 설정됩니다.

/src- /public 아래에 애플리케이션에 대한 index.php 진입점이 포함되어 있는 laravel 애플리케이션

/wordpress- 워드프레스 응용 프로그램

내가 필요한 작업을 정확히 수행하는 다음 Apache VirtualHost 구성이 있습니다.

<VirtualHost *:80>
    ServerName app.local
    DocumentRoot /var/www/vhosts/app.local/wordpress
    ErrorLog /var/www/vhosts/logs/app_local_error_log

     <Directory "/var/www/vhosts/app.local/wordpress">
         Options Indexes FollowSymlinks MultiViews
         AllowOverride All
         Require all granted
         DirectoryIndex index.php
    </Directory>

    <Directory /var/www/vhosts/app.local/src/public>
            DirectoryIndex index.php
            Options FollowSymLinks MultiViews
            AllowOverride All
    </Directory>

     Alias /xyz /var/www/vhosts/app.local/src/public

     <Location "/xyz">
         AllowOverride All
     </Location>
</VirtualHost>

/xyz 아래의 모든 항목은 구체적으로 laravel에 의해 처리됩니다. 루트를 포함한 다른 모든 것은 wordpress에서 처리됩니다.

내 nginx 구성은 다음과 같습니다(laravel/homestead 상자를 사용하여 로컬에서 테스트하고 있습니다).

server {
listen 80;
server_name .app.local;
root "/home/vagrant/code/app/wordpress";

index index.html index.htm index.php;

charset utf-8;

location /xyz/ {
    alias /home/vagrant/code/app/src/public/;
    try_files $uri $uri/ /index.php?$query_string;
}

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; }

access_log off;
error_log  /var/log/nginx/app.local-error.log error;

sendfile off;

client_max_body_size 100m;

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

location ~ /\.ht {
    deny all;
}
}

alias나는 매우 가깝다고 생각하지만, or 를 사용하는지 root, 경로에 후행 슬래시를 추가하는지, 위치 지시문을 재배치하는지 에 관계없이 wordpress가 여전히 요청을 처리하는 것으로 보입니다 . 나는 이것을 디버깅하기 위해 nginx에 대해 충분히 알지 못하거나 구성 측면에서 내 대안이 무엇인지 모릅니다. 어떤 도움이라도 대단히 감사하겠습니다!

또한 여기에서 볼 수 있듯이 특정 위치 지시문을 설정하고 fastcgi에 전달하는 매개변수를 사용자 정의해 보았지만 아무런 효과가 없는 것 같습니다.

https://gist.github.com/mnshankar/9642844

관련 정보