매뉴얼:짧은 URL/Nginx

This page is a translated version of the page Manual:Short URL/Nginx and the translation is 100% complete.

이 안내서에서는 /w/ 폴더에 wiki 파일이 설치되어야 합니다. 문서는 /wiki/로 시작하는 URL로 출력됩니다.

nginx.conf

강조 표시된 설정을 서버 범위에 추가하고 nginx를 다시 로드합니다.

서버 범위가 nginx.conf에 없는 경우 conf.d/ 또는 sites-available/ 서브다이어에서 찾아야 합니다.

다른 루트 또는 문서 경로를 원하는 경우 the short URL service by Redwerks를 사용하여 자동으로 구성을 생성할 수 있습니다.

server {
	# [...]

	# Wiki의 진입점 위치
	location ~ ^/w/(index|load|api|thumb|opensearch_desc|rest|img_auth)\.php$ {
		include /etc/nginx/fastcgi_params;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		fastcgi_pass 127.0.0.1:9000; # or whatever port your PHP-FPM listens on
	}
	
	# 그림
	location /w/images {
		# Separate location for images/ so .php execution won't apply
	}
	location /w/images/deleted {
		# Deny access to deleted images folder
		deny all;
	}
	# MediaWiki의 에셋(일반적으로 이미지)
	location ~ ^/w/resources/(assets|lib|src) {
		try_files $uri =404;
		add_header Cache-Control "public";
		expires 7d;
	}
	# skin 및 extension 의 에셋, 스크립트 및 스타일
	location ~ ^/w/(skins|extensions)/.+\.(css|js|gif|jpg|jpeg|png|svg|wasm|ttf|woff|woff2)$ {
		try_files $uri =404;
		add_header Cache-Control "public";
		expires 7d;
	}
	# 파비콘
	location = /favicon.ico {
		alias /w/images/6/64/Favicon.ico;
		add_header Cache-Control "public";
		expires 7d;
	}

	# 라이센스 및 크레딧 파일
	location ~ ^/w/(COPYING|CREDITS)$ {
		default_type text/plain;
	}
	
	## Uncomment the following code if you wish to use the installer/updater
	## installer/updater
	#location /w/mw-config/ {
	#	# Do this inside of a location so it can be negated
	#	location ~ \.php$ {
	#		include /etc/nginx/fastcgi_params;
	#		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
	#		fastcgi_pass 127.0.0.1:9000; # or whatever port your PHP-FPM listens on
	#	}
	#}
	
	# Handling for Mediawiki REST API, see [[mw:API:REST_API]]
	location /w/rest.php/ {
		try_files $uri $uri/ /w/rest.php?$query_string;
	}

	## Uncomment the following code for handling image authentication
	## Also add "deny all;" in the location for /w/images above
	#location /w/img_auth.php/ {
	#	try_files $uri $uri/ /w/img_auth.php?$query_string;
	#}

	# Handling for the article path (pretty URLs)
	location /wiki/ {
		rewrite ^/wiki/(?<pagename>.*)$ /w/index.php;
	}

	# Allow robots.txt in case you have one
	location = /robots.txt {
	}
	# Explicit access to the root website, redirect to main page (adapt as needed)
	location = / {
		return 301 /wiki/Main_Page;
	}

	# Every other entry point will be disallowed.
	# Add specific rules for other entry points/images as needed above this
	location / {
		return 404;
	}
}

LocalSettings.php

$wgScriptPath = "/w";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;

같이 보기