mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
add mediawiki in native nginx
This commit is contained in:
parent
374c63c27f
commit
f9adf21540
4 changed files with 95 additions and 3 deletions
|
@ -25,5 +25,5 @@ mediawiki_site_name: Community Wiki
|
|||
mediawiki_install_path: "{{ content_base }}" # /library
|
||||
mediawiki_abs_path: "{{ mediawiki_install_path }}/mediawiki-{{ mediawiki_version }}"
|
||||
|
||||
mediawiki_url: /mediawiki
|
||||
mediawiki_full_url: "http://{{ iiab_hostname }}.{{ iiab_domain }}{{ mediawiki_url }}" # http://box.lan/mediawiki
|
||||
mediawiki_url: /wiki
|
||||
mediawiki_full_url: "http://{{ iiab_hostname }}.{{ iiab_domain }}{{ mediawiki_url }}" # http://box.lan/wiki
|
||||
|
|
|
@ -17,6 +17,24 @@
|
|||
daemon_reload: yes
|
||||
state: restarted
|
||||
|
||||
- name: Install {{ nginx_config_dir }}/mediawiki-nginx.conf from template, for http://box{{ mediawiki_url }}
|
||||
template:
|
||||
src: mediawiki-nginx.conf.j2
|
||||
dest: "{{ nginx_config_dir }}/mediawiki-nginx.conf"
|
||||
when: mediawiki_enabled
|
||||
|
||||
- name: Remove mediawiki-nginx.conf if not mediawiki_enabled (debuntu)
|
||||
file:
|
||||
path: "{{ nginx_config_dir }}/mediawiki-nginx.conf"
|
||||
state: absent
|
||||
when: not mediawiki_enabled and is_debuntu
|
||||
|
||||
- name: Restart nginx service to enable/disable http://box{{ mediawiki_url }}
|
||||
systemd:
|
||||
name: nginx
|
||||
daemon_reload: yes
|
||||
state: restarted
|
||||
|
||||
- name: Add 'mediawiki' variable values to {{ iiab_ini_file }}
|
||||
ini_file:
|
||||
path: "{{ iiab_ini_file }}"
|
||||
|
|
|
@ -25,6 +25,12 @@
|
|||
mode: 0755
|
||||
keep_newer: yes
|
||||
|
||||
- name: Create symlink mwlink from docroot to {{ mediawiki_abs_path }}
|
||||
file:
|
||||
src: "{{ mediawiki_abs_path }}"
|
||||
dest: "{{ doc_root }}/mwlink"
|
||||
state: link
|
||||
|
||||
- name: Start MySQL service, so we can create db
|
||||
service:
|
||||
state: started
|
||||
|
@ -51,7 +57,7 @@
|
|||
--installdbpass={{ mediawiki_db_user_password }}
|
||||
--dbuser={{ mediawiki_db_user }}
|
||||
--dbpass={{ mediawiki_db_user_password }}
|
||||
--scriptpath=/mediawiki
|
||||
--scriptpath=/mwlink
|
||||
--lang=en
|
||||
--pass={{ mediawiki_admin_user_password }}
|
||||
"{{ mediawiki_site_name }}"
|
||||
|
@ -60,11 +66,25 @@
|
|||
chdir: "{{ mediawiki_abs_path }}"
|
||||
creates: "{{ mediawiki_abs_path }}/LocalSettings.php"
|
||||
|
||||
- name: Configure wgArticlePath variable in {{ mediawiki_abs_path }}/LocalSettings.php
|
||||
lineinfile:
|
||||
dest: "{{ mediawiki_abs_path }}/LocalSettings.php"
|
||||
line: '$wgArticlePath = "/wiki/$1";'
|
||||
create: yes
|
||||
|
||||
- name: Configure wgUsePathInfo variable in {{ mediawiki_abs_path }}/LocalSettings.php
|
||||
lineinfile:
|
||||
dest: "{{ mediawiki_abs_path }}/LocalSettings.php"
|
||||
line: '$wgUsePathInfo = true;'
|
||||
create: yes
|
||||
|
||||
- name: Install /etc/{{ apache_config_dir }}/mediawiki.conf from template, for http://box{{ mediawiki_url }}
|
||||
template:
|
||||
src: mediawiki.conf.j2
|
||||
dest: "/etc/{{ apache_config_dir }}/mediawiki.conf"
|
||||
|
||||
# Install {{ nginx_config_dir }}/mediawiki-nginx.conf from template in enable.yml
|
||||
|
||||
- name: Add 'mediawiki_installed' variable values to {{ iiab_state_file }}
|
||||
lineinfile:
|
||||
dest: "{{ iiab_state_file }}"
|
||||
|
|
54
roles/mediawiki/templates/mediawiki-nginx.conf.j2
Normal file
54
roles/mediawiki/templates/mediawiki-nginx.conf.j2
Normal file
|
@ -0,0 +1,54 @@
|
|||
# this works if (docroot)/mwlink links to install
|
||||
# and LocalSettings.php has
|
||||
# $wgScriptPath = "/mwlink";
|
||||
# $wgArticlePath = "/wiki/$1";
|
||||
# $wgUsePathInfo = true;
|
||||
|
||||
location ~ ^/mwlink/(index|load|api|thumb|opensearch_desc)\.php$ {
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_pass php; # or whatever port your PHP-FPM listens on
|
||||
}
|
||||
|
||||
# Images
|
||||
location /mwlink/images {
|
||||
# Separate location for images/ so .php execution won't apply
|
||||
}
|
||||
location /mwlink/images/deleted {
|
||||
# Deny access to deleted images folder
|
||||
deny all;
|
||||
}
|
||||
# MediaWiki assets (usually images)
|
||||
location ~ ^/mwlink/resources/(assets|lib|src) {
|
||||
try_files $uri 404;
|
||||
add_header Cache-Control "public";
|
||||
expires 7d;
|
||||
}
|
||||
# Assets, scripts and styles from skins and extensions
|
||||
location ~ ^/mwlink/(skins|extensions)/.+\.(css|js|gif|jpg|jpeg|png|svg)$ {
|
||||
try_files $uri 404;
|
||||
add_header Cache-Control "public";
|
||||
expires 7d;
|
||||
}
|
||||
|
||||
|
||||
## Uncomment the following code if you wish to use the installer/updater
|
||||
## installer/updater
|
||||
#location /mwlink/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/mwlink/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 {{ mediawiki_url }}/ {
|
||||
rewrite ^{{ mediawiki_url }}/(?<pagename>.*)$ /mwlink/index.php;
|
||||
}
|
||||
|
||||
# Explicit access to the root website, redirect to main page (adapt as needed)
|
||||
location = {{ mediawiki_url }} {
|
||||
return 301 {{ mediawiki_url }}/Main_Page;
|
||||
}
|
Loading…
Add table
Reference in a new issue