
이 스레드와 유사한 다른 스레드가 있다는 것을 알고 있지만 이미 며칠 동안 시도했지만 현재 Ubuntu 18의 아래 nginx 구성으로는 이 스레드를 통과할 수 없습니다.
server {
listen 80;
root /var/www/html/wordpress/public_html;
index index.php index.html;
server_name "example.com";
access_log /var/log/nginx/SUBDOMAIN.access.log;
error_log /var/log/nginx/SUBDOMAIN.error.log;
location /blog {
index index.php index.html index.htm;
try_files $uri $uri/ /blog/index.php?q=$uri&$args;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
}
location ~ /\.ht {
deny all;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}}
내 폴더의 현재 구조는 다음과 같습니다.
- /var/www/html/wordpress/public_html -> 블로그 폴더와 하나의 간단한 index.html 포함(워드프레스를 제공하지 않음)
- /var/www/html/wordpress/public_html/blog -> 내 WordPress 파일 위치입니다.
하지만, 해결해야 할 잘못된 부분이 두 가지 있습니다.
- "mysite.com/blog"가 표시되지만 블로그나 URL을 클릭하면 "example.com/?p=1"이 표시되므로 위치 /("example.com"에 있는 간단한 index.html로 연결됩니다. ")
- wp-admin에도 액세스할 수 없습니다. "example.com/blog/wp-admin" -> "http://example.com/wp-login.php?redirect_to=http%를 입력하면 wp-admin으로 리디렉션됩니다. 3A%2F%2Fexample.com%2Fblog%2Fwp-admin%2F&reauth=1 -> 404
매우 감사합니다.
업데이트 2: WP_SITEURL을 example.com으로 변경하고 WP_HOME을 example.com/blog로 변경하려고 시도했으며 mysql wp-options 테이블에서 이 2개의 레코드도 수정했습니다. 그러나 내가 /blog/wp-admin에 액세스하려고 시도했을 때 ->http://example.com/blog/wp-admin/example.com/blog/wp-login.php?redirect_to=http%3A%2F%2Fexample.com%2Fblog%2Fwp-admin%2F&reauth=1-> 404
답변1
확실히 당신이 필요합니다
root /var/www/html/wordpress/public_html/blog;
블록에location /blog {}
또한 블록은 location ~ \.php$
다음과 같아야 합니다.
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
또한 try_files 지시문을 다음으로 변경해야 합니다.
try_files $uri $uri/ /blog/index.php?$args;