Difference between revisions of "AWS Amazon Linux 2 MediaWiki"

From Michael's Information Zone
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 13: Line 13:
 
sudo sed -i 's/expose_php\ =\ On/expose_php\ =\ off/; s/upload_max_filesize\ =\ 2M/upload_max_filesize\ =\ 128M/; s/post_max_size\ =\ 8M/post_max_size\ =\ 64M/; s/max_execution_time\ =\ 30/max_execuion_time\ =\ 180/' /etc/php.ini
 
sudo sed -i 's/expose_php\ =\ On/expose_php\ =\ off/; s/upload_max_filesize\ =\ 2M/upload_max_filesize\ =\ 128M/; s/post_max_size\ =\ 8M/post_max_size\ =\ 64M/; s/max_execution_time\ =\ 30/max_execuion_time\ =\ 180/' /etc/php.ini
 
</pre>
 
</pre>
*Setup the database
+
===Change MPM===
 +
Edit /etc/httpd/conf.modules.d/00-mpm.conf to switch from prefork to event.
 +
===Setup the database===
 
<pre>
 
<pre>
  
Line 33: Line 35:
  
 
</pre>
 
</pre>
 +
===Create SWAP===
 +
*Create SWAP file (Cloud hosted instances lack these). The following will create a 6GB swap file.<ref>https://www.centos.org/docs/5/html/5.2/Deployment_Guide/s2-swap-creating-file.html</ref>
 +
<pre>
 +
sudo dd if=/dev/zero of=/SWAP bs=1024 count=6291453
 +
sudo chmod 0600 /SWAP
 +
sudo mkswap /SWAP
 +
sudo swapon /SWAP
 +
</pre>
 +
*Add the swap file to FSTAB
 +
<pre>
 +
/SWAP swap swap defaults 0 0
 +
</pre>
 +
 
==Migration==
 
==Migration==
 
This is assuming you have made a backup of the database and the files.
 
This is assuming you have made a backup of the database and the files.

Latest revision as of 10:59, 18 October 2018

Purpose

Migrate an old media wiki installation to Amazon Linux 2 on AWS.

What I wanted to accomplish was to move an internal wiki install from VMware esxi to AWS. This is to be made available from the internet the local LAN, but with ACLs on the internet facing side because of obvious reasons. Still thinking how I want to handle this...

Pre-configure Instance

This is a lightly used site, so I am using a the t2.medium instance type.

sudo yum update -y
sudo amazon-linux-extras install lamp-mariadb10.2-php7.2
sudo yum -y install mod_ssl php-gd php-xml php-mbstring mariadb-server
sudo rm -f /etc/httpd/conf.d/welcome.conf
sudo sed -i 's/expose_php\ =\ On/expose_php\ =\ off/; s/upload_max_filesize\ =\ 2M/upload_max_filesize\ =\ 128M/; s/post_max_size\ =\ 8M/post_max_size\ =\ 64M/; s/max_execution_time\ =\ 30/max_execuion_time\ =\ 180/' /etc/php.ini

Change MPM

Edit /etc/httpd/conf.modules.d/00-mpm.conf to switch from prefork to event.

Setup the database


sudo mysql_secure_installation

Set root password? [Y/n] Y 
New password: 
Re-enter new password: 

Remove anonymous users? [Y/n] Y

Disallow root login remotely? [Y/n] Y

Remove test database and access to it? [Y/n] Y

Reload privilege tables now? [Y/n] Y

mysql -uroot -p

Create SWAP

  • Create SWAP file (Cloud hosted instances lack these). The following will create a 6GB swap file.[1]
sudo dd if=/dev/zero of=/SWAP bs=1024 count=6291453
sudo chmod 0600 /SWAP
sudo mkswap /SWAP
sudo swapon /SWAP
  • Add the swap file to FSTAB
/SWAP swap swap defaults 0 0

Migration

This is assuming you have made a backup of the database and the files.

Database

First I replicated the database settings from the existing installation.

create database wikidatabase;
grant all privileges to wikidatabase.* to 'wiki'@'localhost' identified by 'password';
flush privileges;
exit;

At this point I can import the database dump from the old system.

mysql -uroot -p wikidatabase < wiki.sql

Then verify that the import looks right.

mysql -uwiki -p wikidatabase
MariaDB [wikidatabase]> show tables;
+------------------------+
| Tables_in_wikidatabase |
+------------------------+
| archive                |
| bot_passwords          |
| category               |
| categorylinks          |
| change_tag             |
| comment                |
| externallinks          |
| filearchive            |
| image                  |
| image_comment_temp     |
| imagelinks             |
| interwiki              |
| ip_changes             |
| ipblocks               |
| iwlinks                |
| job                    |
| l10n_cache             |
| langlinks              |
| log_search             |
| logging                |
| module_deps            |
| objectcache            |
| oldimage               |
| page                   |
| page_props             |
| page_restrictions      |
| pagelinks              |
| protected_titles       |
| querycache             |
| querycache_info        |
| querycachetwo          |
| recentchanges          |
| redirect               |
| revision               |
| revision_comment_temp  |
| searchindex            |
| site_identifiers       |
| site_stats             |
| sites                  |
| tag_summary            |
| templatelinks          |
| text                   |
| transcache             |
| updatelog              |
| uploadstash            |
| user                   |
| user_former_groups     |
| user_groups            |
| user_newtalk           |
| user_properties        |
| valid_tag              |
| watchlist              |
+------------------------+
52 rows in set (0.00 sec)

Restore Files

Now we restore the files.

tar -xf wikibackup
sudo cp -R var/www/html/wiki /var/www/html/wiki
sudo chown -R apache:apache /var/www/html/wiki