Mediawiki/Fedora

From Segfault
Jump to navigation Jump to search

Apache

 $ yum install httpd mod_fcgid mysql-server phpMyAdmin mediawiki 
 $ cd /etc/httpd
 $ mv conf.d/php.conf conf.d/php.conf.disabled
 $ grep ^[A-Z] conf.d/fcgid.conf
 LoadModule fcgid_module modules/mod_fcgid.so
 AddHandler fcgid-script fcg fcgi fpl php
 FCGIWrapper /usr/bin/php-cgi .php
 FcgidIPCDir /var/run/mod_fcgid
 FcgidProcessTableFile /var/run/mod_fcgid/fcgid_shm

Additionally, we might have to put in these into conf.d/fcgid.conf:

 ProcessLifeTime  7200
 IPCCommTimeout   7200
 IPCConnectTimeout 300

Add ExecCGI to the correct <Directory> (e.g. /var/www/html) in conf/httpd.conf, probably add index.php to DirectoryIndex. Also, adjust Allow/Deny rules in conf.d/phpMyAdmin.conf:

sed 's/from 127.0.0.1/& 10.10.0.0\/24/' -i conf.d/phpMyAdmin.conf
service httpd restart

Or, with systemd:

systemctl restart httpd.service

Nginx

Install prerequisites:

sudo dnf install mediawiki nginx mariadb-server php-mysqlnd php-pecl-apcu zstd sqlite w3m

A very basic Nginx configuration:[1]

$ cd /etc/nginx
$ cat conf.d/fedora0.conf 
server {
       listen          80;
       listen          [::]:80;
       server_name     fedora0;
       root            /var/www;
       access_log      /var/log/nginx/access.log;

       client_max_body_size 5m;
       client_body_timeout 60;

       # php
       include /etc/nginx/default.d/*.conf;

       location / {
               alias /var/www/html/;
       }

       location /wiki {
               alias /var/www/wiki;
       }
}

PHP and additional modules should already be enabled:

$ echo 'phpinfo();' >> /var/www/wiki/info.php 

$ w3m http://localhost/wiki/info.php | grep -E '(APCu|MysqlI|SQLite3) [Ss]upport'
APCu Support          Enabled
MysqlI Support        enabled
SQLite3 support       enabled

MySQL

Adjust the MySQL root password as needed:

> ALTER USER root@localhost IDENTIFIED BY 's3cr3t';

phpMyAdmin

Adjust phpMyAdmin

 $ grep -E 'blowfish_secret|auth_type' /etc/phpMyAdmin/config.inc.php
 $cfg['blowfish_secret']           = 'some-string-up-to-42-characters';
 $cfg['Servers'][$i]['auth_type']  = 'cookie'; 

Also, instead of messing around with SELinux rules, we can just disable the Alias and create a symlink:

 $ grep Alias conf.d/phpMyAdmin.conf 
 # Alias /phpMyAdmin /usr/share/phpMyAdmin
 # Alias /phpmyadmin /usr/share/phpMyAdmin
 
 $ ln -s /usr/share/phpMyAdmin /var/www/html/phpmyadmin

Restore

We actually have a MediaWiki database backup, let's use that:

mysql -D wikidb < ~/wikidb-backup.sql

Use the setup routine to adopt that restored database.

Because Fedora comes with SELinux enabled, we may have to allow network and database access to httpd:

sudo setsebool -P httpd_can_network_connect 1
sudo setsebool -P httpd_can_network_connect_db 1

References