質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Apache

Apacheは、Apache HTTP Serverの略で、最も人気の高いWebサーバソフトウェアの一つです。安定性が高いオープンソースソフトウェアとして商用サイトから自宅サーバまで、多くのプラットフォーム向けに開発・配布されています。サーバーソフトウェアの不具合(NCSA httpd)を修正するパッチ(a patch)を集積、一つ独立したソフトウェアとして開発されました。

nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

MediaWiki

MediaWikiは、Wikipediaを運営するウィキメディア財団が開発するコラボレーションツールです。複数ユーザーによるコンテンツ管理機能を備えるなど、Wikipediaと同じ操作性や編集機能を持ちます。PHPで記述されており、MySQLやPostgreSQLをデータベースに使用できます。

Q&A

解決済

1回答

569閲覧

Nginx初心者。confの構文がわからずShort URLの設定がわからない

imoimo

総合スコア12

Apache

Apacheは、Apache HTTP Serverの略で、最も人気の高いWebサーバソフトウェアの一つです。安定性が高いオープンソースソフトウェアとして商用サイトから自宅サーバまで、多くのプラットフォーム向けに開発・配布されています。サーバーソフトウェアの不具合(NCSA httpd)を修正するパッチ(a patch)を集積、一つ独立したソフトウェアとして開発されました。

nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

MediaWiki

MediaWikiは、Wikipediaを運営するウィキメディア財団が開発するコラボレーションツールです。複数ユーザーによるコンテンツ管理機能を備えるなど、Wikipediaと同じ操作性や編集機能を持ちます。PHPで記述されており、MySQLやPostgreSQLをデータベースに使用できます。

0グッド

1クリップ

投稿2019/07/10 06:55

ApacheからNginxへの移行組です。
様々なページを参考にconfの設定をしhttpsを使ったHPの公開には成功しています。

▶問題点
・必要or追加が必要な構文の選定ができない
.htaccessが使えないため解説ページを参考にconfを設定しているのですが、追加で入力が必要となる構文の選定ができず設定ができません。

▶参考サイト①
https://www.mediawiki.org/wiki/Manual:Short_URL/Nginx

server { # [...] # Location for wiki's entry points location ~ ^/w/(index|load|api|thumb|opensearch_desc).php$ { include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root/w/$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; # or whatever port your PHP-FPM listens on } # Images 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 assets (usually images) location ~ ^/w/resources/(assets|lib|src) { try_files $uri 404; add_header Cache-Control "public"; expires 7d; } # Assets, scripts and styles from skins and extensions location ~ ^/w/(skins|extensions)/.+.(css|js|gif|jpg|jpeg|png|svg)$ try_files $uri 404; add_header Cache-Control "public"; expires 7d; } # Favicon location = /favicon.ico { alias /w/images/6/64/Favicon.ico; add_header Cache-Control "public"; expires 7d; } ## 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/w/mw-config/$fastcgi_script_name; # fastcgi_pass 127.0.0.1:9000; # or whatever port your PHP-FPM listens on # } #} # Handling for the article path (pretty URLs) location /wiki/ { rewrite ^/wiki/(?<pagename>.*)$ /w/index.php; include /etc/nginx/fastcgi_params; # article path should always be passed to index.php fastcgi_param SCRIPT_FILENAME $document_root/w/index.php; fastcgi_param PATH_INFO $pagename; fastcgi_param QUERY_STRING $query_string; fastcgi_pass 127.0.0.1:9000; # or whatever port your PHP-FPM listens on } # 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 https://www.example.com/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; } }

▶参考サイト②
https://www.mediawiki.org/wiki/Manual:Short_URL/Page_title_-_nginx,_Root_Access,_PHP_as_a_CGI_module

server { server_name www.example.com example.com; listen 80; root /home/user/public_html; index index.php index.html index.htm; access_log /var/log/nginx/access-example.log; error_log /var/log/nginx/error-example.log; location ~ .ht { deny all; } location / { try_files $uri $uri/ @rewrite; } location @rewrite { rewrite ^/(.*)$ /index.php; } location ^~ /maintenance/ { return 403; } location ~ .php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; try_files $uri @rewrite; } }

▶現状
・nginx version: nginx/1.17.1(Centos7)
・var/www/html/test
・test.com

server { listen 80; server_name test.com; rewrite ^ https://$server_name$request_uri? permanent; } server { listen 443 ssl; server_name test.com; access_log /var/log/nginx/test.com-access.log main; error_log /var/log/nginx/test.com-error.log; root /var/www/html/test; ssl_certificate /etc/letsencrypt/live/test.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/test.com/privkey.pem; ssl_session_timeout 1d; ssl_session_cache shared:SSL:50m; ssl_session_tickets on; ssl_dhparam /etc/nginx/ssl/dhparam.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { index index.php index.html index.htm; } location ~ .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }

現状のConfと参考サイトのConfをどう組み合わせたらいいのかわかりません。
非常に申し訳ないのですが、ご享受頂けたら幸いです。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

yukikp

2019/07/10 09:54

これは、どのようなルールでURLを利用するかによるのではないでしょうか? 例えばWordPressなんかでは、 http://hogehoge.com/suriusuri/ というアクセスが来たら、 http://hogehoge.com/index.phpにアクセスし、surisuriをパラメーターとして処理するようにする書き方にしていますし、 単に.phpという拡張子を省略しても該当.phpファイルを呼び出したいという意味でのShort URLであれば、 location / { index index.php index.html; try_files $uri $uri.php $uri.html $uri/ 404.html=404; } みたいな書き方でいいんじゃないでしょうか。
imoimo

2019/07/10 11:50

返信有難うございます。 たしかにどのようなURLにしたいかを記載していませんでした。 Mediawikiの初期設定ではURLが ①http://test.com/index.php?title=メインページ になります。 これを参考サイトを参考にconfを設定すると ②http://test.com/wiki/メインページ に変更することができるとされています。 ここまででも良いのですが、過去Apacheで.htaccessを利用しできていたときは ③http://test.com/メインページ にしており希望は③です。 Nignxは難しいのか解説サイトが少ない・・・ URLについての参考サイトをもう一つ https://www.mediawiki.org/wiki/Manual:Short_URL
guest

回答1

0

自己解決

yukikpさん
大きなヒントをありがとうございます!!
参考にさせてもらいつつ設定してみたら解決しました。

投稿2019/07/10 12:10

imoimo

総合スコア12

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問