Editing Nginx/MediaWiki
From Bibliotheca Anonoma
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
== PHP-FPM Nginx Config == | |||
To make it easy to switch all our present or future PHP apps between TCP ports and UNIX sockets, we use a specific `php-fpm.conf` file which can be called with {{ic|fastcgi_pass php-fpm;}}. Create this file: | To make it easy to switch all our present or future PHP apps between TCP ports and UNIX sockets, we use a specific `php-fpm.conf` file which can be called with {{ic|fastcgi_pass php-fpm;}}. Create this file: | ||
Line 29: | Line 9: | ||
upstream php-fpm { | upstream php-fpm { | ||
#server 127.0.0.1:9000; | #server 127.0.0.1:9000; | ||
server unix:/var/run/php5-fpm.sock; | |||
} | } | ||
</nowiki>}} | </nowiki>}} | ||
== MediaWiki Nginx Config == | |||
This is the Nginx Config that we use when when setting up MediaWiki for the first time over conventional HTTP, with PHP-FPM: | This is the Nginx Config that we use when when setting up MediaWiki for the first time over conventional HTTP, with PHP-FPM: | ||
Line 150: | Line 129: | ||
Nginx can be optimized to make image serving more efficient, and block hotlinking. Since the settings for static images often differ greatly from that of dynamic text, it is recommended that you create a specific subdomain just for images (such as <code>img.bibanon.org</code>) and serve your image folder from there. | Nginx can be optimized to make image serving more efficient, and block hotlinking. Since the settings for static images often differ greatly from that of dynamic text, it is recommended that you create a specific subdomain just for images (such as <code>img.bibanon.org</code>) and serve your image folder from there. | ||
Here is the Nginx config we used (without SSL) | Here is the Nginx config we used (without SSL), with our image folder under a custom dir set by <code></code>: <code>/storage/mw-img/</code>: | ||
<pre> | |||
server { | server { | ||
listen 80; | listen 80; | ||
server_name img.bibanon.org; | server_name img.bibanon.org; | ||
# images stored here | # images stored here | ||
root / | root /storage/mw-img/; | ||
# let's encrypt SSL dir | # let's encrypt SSL dir | ||
Line 189: | Line 163: | ||
} | } | ||
} | } | ||
</ | </pre> | ||
After setting this up, just add this line to LocalSettings: | After setting this up, just add this line to LocalSettings: | ||
Line 196: | Line 170: | ||
$wgUploadBaseUrl = 'https://img.bibanon.org'; | $wgUploadBaseUrl = 'https://img.bibanon.org'; | ||
</nowiki>}} | </nowiki>}} | ||