How To Install MediaWiki On Ubuntu 18.04 With Nginx MariaDB And PHP: Perbedaan antara revisi
kTidak ada ringkasan suntingan |
kTidak ada ringkasan suntingan |
||
Baris 20: | Baris 20: | ||
php7.3-opcache php7.3-sqlite3 php7.3-xml php7.3-zip php7.3-snmp php7.3-json php7.3-imap php7.3-common php7.3-tidy | php7.3-opcache php7.3-sqlite3 php7.3-xml php7.3-zip php7.3-snmp php7.3-json php7.3-imap php7.3-common php7.3-tidy | ||
Edit php.ini sesuai dengan versi php yang di install : | '''Edit php.ini sesuai dengan versi php yang di install :''' | ||
sudo nano /etc/php/7.1/fpm/php.ini | sudo nano /etc/php/7.1/fpm/php.ini | ||
file_uploads = On | file_uploads = On | ||
Baris 30: | Baris 30: | ||
date.timezone = Asia/Jakarta | date.timezone = Asia/Jakarta | ||
Restart Service nginx dan MariaDb : | '''Restart Service nginx dan MariaDb :''' | ||
systemctl start nginx mariadb | systemctl start nginx mariadb | ||
systemctl enable nginx mariadb | systemctl enable nginx mariadb | ||
Konfigurasi Mariadb : | '''Konfigurasi Mariadb :''' | ||
mysql_secure_installation | mysql_secure_installation | ||
mysql -u root -p | mysql -u root -p | ||
'''Masukkan password : 12345678''' | |||
CREATE DATABASE '''mediawikidb''' CHARACTER SET utf8 COLLATE utf8_bin; | |||
CREATE USER 'mediawikidb'@'%' IDENTIFIED BY PASSWORD '12345678'; | |||
Beri izin akses user database : | '''Beri izin akses user database :''' | ||
GRANT ALL PRIVILEGES ON mediawikidb.* TO 'mediawikiuser'@'localhost' IDENTIFIED BY PASSWORD'12345678'; | |||
FLUSH PRIVILEGES; | |||
exit | |||
Download Mediawiki dengan wget : | '''Download Mediawiki dengan wget :''' | ||
wget https://releases.wikimedia.org/mediawiki/1.33/mediawiki-1.33.0.tar.gz | Linux$/home/user/wget https://releases.wikimedia.org/mediawiki/1.33/mediawiki-1.33.0.tar.gz | ||
Ekstrak file : | '''Ekstrak file :''' | ||
tar -xvzf mediawiki-1.33.0.tar.gz | tar -xvzf mediawiki-1.33.0.tar.gz | ||
Copy mediawiki hasil ekstrakan pada direktory nginx : | '''Copy mediawiki hasil ekstrakan pada direktory nginx :''' | ||
cp -r mediawiki-1.33.0 /var/www/html/mediawiki | cp -r mediawiki-1.33.0 /var/www/html/mediawiki | ||
Ubah kepemilikan file : | '''Ubah kepemilikan file dan beri akses attribut file:''' | ||
chown -R www-data:www-data /var/www/html/mediawiki | chown -R www-data:www-data /var/www/html/mediawiki | ||
chmod -R 755 /var/www/html/mediawiki | chmod -R 755 /var/www/html/mediawiki | ||
Edit dan buat simboling link sites-available : | '''Edit dan buat simboling link sites-available :''' | ||
nano /etc/nginx/sites-available/default &>/dev/null | nano /etc/nginx/sites-available/default &>/dev/null | ||
Pengaturan Virtualhost nginx : | '''Pengaturan Virtualhost nginx :''' | ||
server | # http -> https redirection | ||
server { | |||
listen 80; | |||
listen [::]:80; | |||
location / { | # virtual host domains | ||
server_name mediawiki.web.id www.mediawiki.web.id; | |||
# accept requests only for this domain | |||
location ~ \. | if ($host !~ ^(mediawiki.web.id|www.mediawiki.web.id)$) { | ||
return 444; | |||
} | |||
# redirect to https | |||
return 301 <nowiki>https://$host$request_uri</nowiki>; | |||
} | |||
# https and spdy | |||
server { | |||
listen 443 ssl spdy; | |||
listen [::]:443 ssl spdy; | |||
# virtual host domains | |||
server_name mediawiki.web.id www.mediawiki.web.id; | |||
# accept requests only for this domain | |||
if ($host !~ ^(mediawiki.web.id|www.mediawiki.web.id)$) { | |||
return 444; | |||
} | |||
# certificate and private key | |||
ssl_certificate /etc/ssl/ellak/mediawiki.web.id-codomo-bundle.pem; | |||
ssl_certificate_key /etc/ssl/ellak/mediawiki.web.id-decrypted.key; | |||
# random 2048-bit parameter for DH elliptic curves | |||
# (re)generate with: | |||
# openssl dhparam -outform pem -out dhparam2048.pem 2048 | |||
ssl_dhparam /etc/vhosts/mediawiki.web.id/ssl/dhparam2048.pem; | |||
# include common ssl settings | |||
include /etc/nginx/ssl.conf; | |||
# ocsp stapling (optional, uncomment if necessary) | |||
#ssl_trusted_certificate /etc/ssl/certs/combined.stapling.pem; | |||
# public html | |||
root /var/www/vhosts/mediawiki.web.id/site/public_html; | |||
# access and error logs | |||
access_log /var/www/vhosts/mediawiki.web.id/logs/access.log; | |||
error_log /var/www/vhosts/mediawiki.web.id/logs/error.log error; | |||
# include standard restrictions | |||
include /etc/nginx/restrictions.conf; | |||
# application configuration | |||
include /etc/nginx/cms.conf; | |||
# document root | |||
index index.php index.html index.htm; | |||
# css and js | |||
location ~* ^.+\.(css|js) { | |||
# 1 week expires | |||
expires 1w; | |||
## no external referer | |||
valid_referers none blocked | |||
mediawiki.web.id *.mediawiki.web.id; | |||
if ($invalid_referer) { | |||
return 403; | |||
} | |||
} | |||
location /wiki/ { | |||
try_files $uri $uri/ @mediawiki; | |||
# Do this inside of a location so it can be negated | |||
location ~ \.php$ { | |||
try_files $uri $uri/ =404; # Don't let php execute non-existent php files | |||
include /etc/nginx/fastcgi_params; | |||
fastcgi_pass unix:/var/run/php7.3-fpm/mediawiki.web.id.sock; | |||
} | |||
} | |||
location /wiki/images { | |||
# Separate location for images/ so .php execution won't apply | |||
location ~ ^/wiki/images/thumb/(archive/)?[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ { | |||
# Thumbnail handler for MediaWiki | |||
# This location only matches on a thumbnail's url | |||
# If the file does not exist we use @thumb to run the thumb.php script | |||
try_files $uri $uri/ @thumb; | |||
} | |||
} | |||
location /wiki/images/deleted { | |||
# Deny access to deleted images folder | |||
deny all; | |||
} | |||
# Deny access to folders MediaWiki has a .htaccess deny in | |||
location /wiki/cache { deny all; } | |||
location /wiki/languages { deny all; } | |||
location /wiki/maintenance { deny all; } | |||
location /wiki/serialized { deny all; } | |||
# Just in case, hide .svn and .git too | |||
location ~ /.(svn|git)(/|$) { deny all; } | |||
# Hide any .htaccess files | |||
location ~ /.ht { deny all; } | |||
# Uncomment the following code if you wish to hide the installer/updater | |||
## Deny access to the installer | |||
location /wiki/mw-config { deny all; } | |||
# Handling for the article path | |||
location @mediawiki { | |||
include /etc/nginx/fastcgi_params; | |||
# article path should always be passed to index.php | |||
fastcgi_param SCRIPT_FILENAME $document_root/wiki/index.php; | |||
fastcgi_pass unix:/var/run/php7.3-fpm/mediawiki.web.id.sock; | |||
} | |||
# Thumbnail 404 handler, only called by try_files when a thumbnail does not exist | |||
location @thumb { | |||
# Do a rewrite here so that thumb.php gets the correct arguments | |||
rewrite ^/wiki/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /wiki/thumb.php?f=$1&width=$2; | |||
rewrite ^/wiki/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /wiki/thumb.php?f=$1&width=$2&archived=1; | |||
# Run the thumb.php script | |||
include /etc/nginx/fastcgi_params; | |||
fastcgi_param SCRIPT_FILENAME $document_root/wiki/thumb.php; | |||
fastcgi_pass unix:/var/run/php7.3-fpm/mediawiki.web.id.sock; | |||
} | |||
# media files | |||
location ~* ^.+\.(og?|svg|svgz|eot|otf|woff|mp4|ttf|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|swf)$ { | |||
# maximum expires | |||
expires max; | |||
# block hot-linking, allow SE and social media | |||
valid_referers none blocked ~\.google\. ~\.yahoo\. ~\.bing\. | |||
~\.facebook\. ~\.fbcdn\. ~\.twitter\. | |||
mediawiki.web.id *.mediawiki.web.id; | |||
if ($invalid_referer) { | |||
return 403; | |||
} | |||
} | |||
# disable public access to buddypress docs attachments | |||
location /wp-content/uploads/bp-attachments/ { | |||
rewrite ^.*uploads/bp-attachments/([0-9]+)/(.*) /?p=$1&bp-attachment=$2 permanent; | |||
} | |||
# php-fpm support | |||
location ~ \.php$ { | |||
# make sure to not run php hidden in other files | |||
try_files $uri =404; | |||
# fastcgi unix socket | |||
fastcgi_pass unix:/var/run/php7.3-fpm/mediawiki.web.id.sock; | |||
# include standard parameters | |||
include /etc/nginx/fastcgi_params; | |||
# increate fastcgi timeout (for mu) | |||
fastcgi_read_timeout 360; | |||
# include micro-caching configuration | |||
include /etc/nginx/microcache.conf; | |||
} | |||
} | |||
Test Konfigurasi nginx : | '''Test Konfigurasi nginx :''' | ||
nginx -t | nginx -t | ||
echo "192.168.1.50 www.mediawiki.web.id" >> /etc/hosts; | |||
'''Restart service php7.3-fpm & mariadb :''' | |||
Restart service php7.3-fpm & mariadb : | |||
systemctl restart php7.3-fpm nginx mariadb | systemctl restart php7.3-fpm nginx mariadb | ||
Pengaturan atau copy dari mediawiki yang lama LocalSetting.php : | '''Pengaturan atau copy dari mediawiki yang lama LocalSetting.php :''' | ||
cp -r /home/ubuntu/Downloads/LocalSettings.php /var/www/html/mediawiki/ | cp -r /home/ubuntu/Downloads/LocalSettings.php /var/www/html/mediawiki/ | ||
<nowiki>---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</nowiki> | <nowiki>---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</nowiki> |
Revisi per 14 Mei 2024 17.15
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Our Server Specification-
Os:Ubuntu 18.04 LTS Bionic Beaver 64Bit | IP address- 192.168.1.50 | Hostname :www.yourdomain.com
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lsb_release -cd ; getconf LONG_BIT ; whoami ; hostname -f ; hostname -I ; apt update; apt install -y build-essential software-properties-common curl gdebi wget aptitude nano git net-tools lsb-release apt-transport-https
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://mirror.biznetgio.com/mariadb/repo/10.4/ubuntu bionic main' add-apt-repository ppa:ondrej/php -y
apt-get update apt-get install -y nginx mariadb-server mariadb-client php7.3 php7.3-cli php7.3-fpm php7.3-cgi php7.3-bcmath php7.3-curl php7.3-gd php7.3-intl php7.3-json php7.3-mbstring php7.3-mysql php7.3-opcache php7.3-sqlite3 php7.3-xml php7.3-zip php7.3-snmp php7.3-json php7.3-imap php7.3-common php7.3-tidy
Edit php.ini sesuai dengan versi php yang di install :
sudo nano /etc/php/7.1/fpm/php.ini file_uploads = On allow_url_fopen = On memory_limit = 256M upload_max_filesize = 100M max_execution_time = 360 cgi.fix_pathinfo = 0 date.timezone = Asia/Jakarta
Restart Service nginx dan MariaDb :
systemctl start nginx mariadb systemctl enable nginx mariadb
Konfigurasi Mariadb :
mysql_secure_installation mysql -u root -p Masukkan password : 12345678 CREATE DATABASE mediawikidb CHARACTER SET utf8 COLLATE utf8_bin; CREATE USER 'mediawikidb'@'%' IDENTIFIED BY PASSWORD '12345678';
Beri izin akses user database :
GRANT ALL PRIVILEGES ON mediawikidb.* TO 'mediawikiuser'@'localhost' IDENTIFIED BY PASSWORD'12345678'; FLUSH PRIVILEGES; exit
Download Mediawiki dengan wget :
Linux$/home/user/wget https://releases.wikimedia.org/mediawiki/1.33/mediawiki-1.33.0.tar.gz
Ekstrak file :
tar -xvzf mediawiki-1.33.0.tar.gz
Copy mediawiki hasil ekstrakan pada direktory nginx :
cp -r mediawiki-1.33.0 /var/www/html/mediawiki
Ubah kepemilikan file dan beri akses attribut file:
chown -R www-data:www-data /var/www/html/mediawiki chmod -R 755 /var/www/html/mediawiki
Edit dan buat simboling link sites-available :
nano /etc/nginx/sites-available/default &>/dev/null
Pengaturan Virtualhost nginx :
# http -> https redirection server { listen 80; listen [::]:80; # virtual host domains server_name mediawiki.web.id www.mediawiki.web.id; # accept requests only for this domain if ($host !~ ^(mediawiki.web.id|www.mediawiki.web.id)$) { return 444; } # redirect to https return 301 https://$host$request_uri; } # https and spdy server { listen 443 ssl spdy; listen [::]:443 ssl spdy; # virtual host domains server_name mediawiki.web.id www.mediawiki.web.id; # accept requests only for this domain if ($host !~ ^(mediawiki.web.id|www.mediawiki.web.id)$) { return 444; } # certificate and private key ssl_certificate /etc/ssl/ellak/mediawiki.web.id-codomo-bundle.pem; ssl_certificate_key /etc/ssl/ellak/mediawiki.web.id-decrypted.key; # random 2048-bit parameter for DH elliptic curves # (re)generate with: # openssl dhparam -outform pem -out dhparam2048.pem 2048 ssl_dhparam /etc/vhosts/mediawiki.web.id/ssl/dhparam2048.pem; # include common ssl settings include /etc/nginx/ssl.conf; # ocsp stapling (optional, uncomment if necessary) #ssl_trusted_certificate /etc/ssl/certs/combined.stapling.pem; # public html root /var/www/vhosts/mediawiki.web.id/site/public_html; # access and error logs access_log /var/www/vhosts/mediawiki.web.id/logs/access.log; error_log /var/www/vhosts/mediawiki.web.id/logs/error.log error; # include standard restrictions include /etc/nginx/restrictions.conf; # application configuration include /etc/nginx/cms.conf; # document root index index.php index.html index.htm; # css and js location ~* ^.+\.(css|js) { # 1 week expires expires 1w; ## no external referer valid_referers none blocked mediawiki.web.id *.mediawiki.web.id; if ($invalid_referer) { return 403; } } location /wiki/ { try_files $uri $uri/ @mediawiki; # Do this inside of a location so it can be negated location ~ \.php$ { try_files $uri $uri/ =404; # Don't let php execute non-existent php files include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/run/php7.3-fpm/mediawiki.web.id.sock; } } location /wiki/images { # Separate location for images/ so .php execution won't apply location ~ ^/wiki/images/thumb/(archive/)?[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ { # Thumbnail handler for MediaWiki # This location only matches on a thumbnail's url # If the file does not exist we use @thumb to run the thumb.php script try_files $uri $uri/ @thumb; } } location /wiki/images/deleted { # Deny access to deleted images folder deny all; } # Deny access to folders MediaWiki has a .htaccess deny in location /wiki/cache { deny all; } location /wiki/languages { deny all; } location /wiki/maintenance { deny all; } location /wiki/serialized { deny all; } # Just in case, hide .svn and .git too location ~ /.(svn|git)(/|$) { deny all; } # Hide any .htaccess files location ~ /.ht { deny all; } # Uncomment the following code if you wish to hide the installer/updater ## Deny access to the installer location /wiki/mw-config { deny all; } # Handling for the article path location @mediawiki { include /etc/nginx/fastcgi_params; # article path should always be passed to index.php fastcgi_param SCRIPT_FILENAME $document_root/wiki/index.php; fastcgi_pass unix:/var/run/php7.3-fpm/mediawiki.web.id.sock; } # Thumbnail 404 handler, only called by try_files when a thumbnail does not exist location @thumb { # Do a rewrite here so that thumb.php gets the correct arguments rewrite ^/wiki/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /wiki/thumb.php?f=$1&width=$2; rewrite ^/wiki/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /wiki/thumb.php?f=$1&width=$2&archived=1; # Run the thumb.php script include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root/wiki/thumb.php; fastcgi_pass unix:/var/run/php7.3-fpm/mediawiki.web.id.sock; } # media files location ~* ^.+\.(og?|svg|svgz|eot|otf|woff|mp4|ttf|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|swf)$ { # maximum expires expires max; # block hot-linking, allow SE and social media valid_referers none blocked ~\.google\. ~\.yahoo\. ~\.bing\. ~\.facebook\. ~\.fbcdn\. ~\.twitter\. mediawiki.web.id *.mediawiki.web.id; if ($invalid_referer) { return 403; } } # disable public access to buddypress docs attachments location /wp-content/uploads/bp-attachments/ { rewrite ^.*uploads/bp-attachments/([0-9]+)/(.*) /?p=$1&bp-attachment=$2 permanent; } # php-fpm support location ~ \.php$ { # make sure to not run php hidden in other files try_files $uri =404; # fastcgi unix socket fastcgi_pass unix:/var/run/php7.3-fpm/mediawiki.web.id.sock; # include standard parameters include /etc/nginx/fastcgi_params; # increate fastcgi timeout (for mu) fastcgi_read_timeout 360; # include micro-caching configuration include /etc/nginx/microcache.conf; } }
Test Konfigurasi nginx :
nginx -t echo "192.168.1.50 www.mediawiki.web.id" >> /etc/hosts;
Restart service php7.3-fpm & mariadb :
systemctl restart php7.3-fpm nginx mariadb
Pengaturan atau copy dari mediawiki yang lama LocalSetting.php :
cp -r /home/ubuntu/Downloads/LocalSettings.php /var/www/html/mediawiki/
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------