「Install MediaWiki 1.35 on FreeBSD 12.2」修訂間的差異
跳至導覽
跳至搜尋
標籤:mobile web edit mobile edit |
|||
行 239: | 行 239: | ||
== 參考連結 == |
== 參考連結 == |
||
+ | |||
+ | * [https://xw.is/wiki/Installing_Mediawiki_1.27_on_FreeBSD_11.1] |
於 2021年1月1日 (五) 00:12 的修訂
安裝 MediaWiki 1.35 在 FreeBSD 12.2
安裝時間: 2020-12-30
安裝說明
本站安裝的環境
- FreeBSD 12.2
- Nginx 1.18.0
- PHP 7.4.13
- MediaWiki 1.35.0
- SQLite 3.33.0
先決條件
- 網址 - 本站使用
chevyne.at.tw
- 網址的 TLS憑證 (申請中, 所以目前沒有HTTPS)
- 已完成 FreeBSD 安裝後步驟
安裝套件
pkg install -y nginx mediawiki135-php74 git php74-pdo_sqlite php74-pecl-APCu php74-pecl-imagick php74-gd php74-openssl sysrc nginx_enable="YES" sysrc php_fpm_enable="YES"
配置 PHP
配置PHP,以使用unix domain socket而不是TCP/IP。
編輯 /usr/local/etc/php-fpm.conf
,並更改listen指令:
listen = /var/run/php-fpm.sock listen.owner = www listen.group = www listen.mode = 0660
啟動 PHP
service php-fpm start
測試 nginx & TLS
編輯 /usr/local/etc/nginx/nginx.conf
,使用以下測試配置:
worker_processes 1; events { worker_connections 1024; } http { server { listen 80; listen [::]:80; server_name chevyne.at.tw; return 301 https://$server_name$request_uri; } server { listen 443; listen [::]:443; server_name chevyne.at.tw; ssl on; ssl_certificate /usr/local/www/tls/chevyne.at.tw.crt; ssl_certificate_key /usr/local/www/tls/chevyne.at.tw.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { root /usr/local/www/nginx; index index.html index.htm; } } }
啟動 nginx:
service nginx start
確定一切正常。
啟用 wiki
一切正常後,建立 symlink:
ln -s /usr/local/www/mediawiki /usr/local/www/wiki/w
將下面加到 nginx.conf
location /w { root /usr/local/www/wiki; index index.php; location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $request_filename; include fastcgi_params; } }
現在連到 https://chevyne.at.tw/w 並完成安裝程序。
安裝程序將生成一個 LocalSettings.php
文件。
將其複製到服務器:
scp LocalSettings.php chevyne.at.tw:/usr/local/www/mediawiki
啟用短網址
要啟用短URL,請使用以下 nginx.conf
配置:
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; listen [::]:80; server_name chevyne.at.tw; return 301 https://$server_name$request_uri; } server { listen 443; listen [::]:443; server_name chevyne.at.tw; ssl on; ssl_certificate /usr/local/www/tls/chevyne.at.tw.crt; ssl_certificate_key /usr/local/www/tls/chevyne.at.tw.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; root /usr/local/www/wiki; index index.php; location / { rewrite ^/$ https://chevyne.at.tw/wiki permanent; } location /w { location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $request_filename; include fastcgi_params; } } location /w/images { location ~ ^/w/images/thumb/(archive/)?[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ { try_files $uri $uri/ @thumb; } } location /w/images/deleted { # Deny access to deleted images folder deny all; } location /w/cache { deny all; } location /w/languages { deny all; } location /w/maintenance { deny all; } location /w/serialized { deny all; } location ~ /.(svn|git)(/|$) { deny all; } location ~ /.ht { deny all; } location /wiki { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root/w/index.php; fastcgi_pass unix:/var/run/php-fpm.sock; } location @thumb { rewrite ^/w/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /w/thumb.php?f=$1&width=$2; rewrite ^/w/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /w/thumb.php?f=$1&width=$2&archived=1; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root/w/thumb.php; fastcgi_pass unix:/var/run/php-fpm.sock; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/local/www/nginx-dist; } } }
然後編輯 LocalSettings.php
以啟用短網址:
$wgScriptPath = "/w"; $wgScriptExtension = ".php"; $wgArticlePath = "/wiki/$1"; $wgUsePathInfo = true;
現在完成。
啟用移動支持
確定已安裝 wget:
pkg install -y wget
確定具有 mediawiki extensions 的權限:
chown root:staff /usr/local/www/mediawiki/extensions chmod g+w /usr/local/www/mediawiki/extensions
下載 MobileFrontend 並解壓縮:
wget https://extdist.wmflabs.org/dist/extensions/MobileFrontend-REL1_35-1421405.tar.gz tar -xzf MobileFrontend-REL1_35-1421405.tar.gz -C /usr/local/www/mediawiki/extensions
編輯 LocalSettings.php
以啟用(將其加在後面):
wfLoadExtension('MobileFrontend'); $wgMFAutodetectMobileView = true;