Difference between revisions of "Web Server Documentation"
imported>Alex |
imported>Alex |
||
Line 239: | Line 239: | ||
$ cd /var/lib/mediawiki/maintenance | $ cd /var/lib/mediawiki/maintenance | ||
$ php initSiteStats.php | $ php initSiteStats.php | ||
+ | |||
+ | But this runs into some errors ([https://www.mediawiki.org/wiki/Manual:Maintenance_scripts this page] suggests setting the MW_INSTALL_PATH environment variable, but I can't find a good way to do that). | ||
We also want to limit account creation to sysops only [https://www.mediawiki.org/wiki/Manual:Preventing_access#Restrict_account_creation as done here]. To do this, edit LocalSettings.php and add these lines: | We also want to limit account creation to sysops only [https://www.mediawiki.org/wiki/Manual:Preventing_access#Restrict_account_creation as done here]. To do this, edit LocalSettings.php and add these lines: |
Revision as of 17:21, 11 March 2016
Contents
- 1 Installing Ubuntu aka Trying RAID 10 (2/15/2016)
- 2 Configuring RAID 1 on Web Server (2/17/2016)
- 3 Network Configuration (2/22/2016)
- 4 Installing Software (2/24/2016)
- 5 Installing Mediawiki (3/7/2016)
- 6 Short URLs (3/7/2016)
- 7 Labeled Section Transclusion (3/7/2016)
- 8 Responsive Design (3/7/2016)
- 9 Mediawiki CSS changes (3/9/2016)
- 10 Setting up users (3/11/2016)
- 11 To-do list
Installing Ubuntu aka Trying RAID 10 (2/15/2016)
Some general configuration options:
- hostname: McNairWebServ
- user full name: McNair Center
- username: mcnair
- don't encrypt home directory
- manual partitioning (see below for configuration of RAID)
- no automatic updates
- software: LAMP stack
Sahil and I tried to configure RAID 10 using the software RAID option in the installer, which is documented here. We put two 64 GB swap space partitions on the first two hard drives, and created two ext4 partitions that took up the rest of the space on those two drives. For the other two drives, we used a single ext4 partition for each drive. For all of the ext4 partitions, we set the bootable flag to "on." Then we chose to configure the software RAID, created a new MD device, and chose RAID10 with 2 active devices and 2 spare devices. For the active devices, we chose the two ext4 partitions on the first two hard drives, and for the spare devices, we chose the two ext4 partitions on the other two hard drives. But then the installation process fails when the GRUB boot loader can't be installed, because the GUID partition tables (GPT) need a designated, small (1 MB is enough) partition for the GRUB bootloader.
So we started partitioning from scratch, but with only two hard drives for a RAID1 array. In the first drive, there are three partitions: one 1 MB partition reserved for the bootloader, one 64 GB swap partition, and the rest of the drive as an ext4 partition for the filesystem. In the second drive, there are two partitions: one 1 MB partition reserved for the bootloader and the rest of the drive as an ext4 partition for the filesystem. Then we made two software RAID devices, both with one with 2 active devices and 0 spare devices. The first RAID device had both of the bootloader partitions as the active devices, and the second RAID device had both of the ext4 filesystem partitions as the active devices. Then we set the first RAID device to "use as ext4" and the mount as "/boot" and the second RAID device as "use as ext4" and the mount as "/" and then continued with the installation. This time, it failed to install the kernel.
I guessed that, because the 1 MB RAID device was made first, that the kernel tried to install itself to that device and failed. So I went back to the partitioner and set the first RAID device to "do not use" and then tried the installation process again. It prompted me a couple of times warning me that the old filesystem would be overwritten, but I continued the installation regardless. But then the GRUB boot loader failed, even if we tried not installing it to the master boot record (MBR) and installing it to "dev/md0" or installing it to "dev/md0_raid1"
Configuring RAID 1 on Web Server (2/17/2016)
The first RAID device (/dev/md0) we set to use as an ext4 filesystem and mounted /boot to it, and the second RAID device (/dev/md127) we set to use as an ext4 filesystem and mounted / to it (we tried this before, but it failed to install the kernel). This time, it failed to install the bootloader, but it never prompted me to choose where to install the bootloader (usually it asks whether you'd like to install the bootloader to the master boot record).
Second partitioning attempt:
First hard disk (/dev/sda):
- 10 MB partition, use as reserved BIOS boot area, bootable flag off
- 64 GB partition, use as swap space
- rest of the space partition, use as ext4 filesystem, mount point /, bootable flag off
Second hard disk (/dev/sdb):
- 10 MB partition, use as reserved BIOS boot area, bootable flag off
- rest of the space partition, use as ext4 filesystem, mount point /, bootable flag off
Write partition changes to disk and then start configuring software RAID:
- First RAID device (/dev/md0): RAID1, 2 active devices (/dev/sda3 and /dev/sdb2), 0 spare devices
- Second RAID device (/dev/md1): RAID1, 2 active devices (/dev/sda1 and /dev/sdb1), 0 spare devices
- first RAID device partition: use as ext4 filesystem, mount point /
- second RAID device partition: use as ext4 filesystem, mount point /boot, format data on the partition
Failed to install GRUB bootloader on a hard disk (again).
Next attempt: First RAID device (/dev/md0): use as ext4 filesystem, mount point /, format data on the partition Second RAID device (/dev/md1): erase data on partition, use as "do not use"
Next attempt: Redo the RAID devices so that the first device (/dev/md0): RAID1, 2 active devices (/dev/sda1 and /dev/sdb1), 0 spare devices, and the second RAID device (/dev/md1): RAID1, 2 active devices (/dev/sda3 and /dev/sdb2), 0 spare devices. Then configure the RAID devices:
- first RAID device partition: use as ext4 filesystem, mount point /boot, format data on the partition
- second RAID device partition: use as ext4 filesystem, mount point /, format data on the partition
New idea: ditch the idea of RAID on the boot partitions (we'll put the bootloader on one of the boot partitions and then we can try to set up RAID once we've got the thing booting into Linux), so leave the partitions as above ("Second Partitioning Attempt"). Only make one software RAID device (/dev/md0): RAID1, 2 active devices (/dev/sda3 and /dev/sdb2), 0 spare devices. Then configure the first RAID device partition: use as ext4 filesystem, mount point /, format data on the partition.
Third partitioning attempt:
First hard disk (/dev/sda):
- 10 MB partition, use as reserved BIOS boot area, bootable flag off
- 32 GB partition, use as swap space
- rest of the space partition, use as ext4 filesystem, mount point /, bootable flag off
Second hard disk (/dev/sdb):
- 10 MB partition, use as reserved BIOS boot area, bootable flag off
- 32 GB partition, use as swap space
- rest of the space partition, use as ext4 filesystem, mount point /, bootable flag off
One RAID device (/dev/md0): RAID1, 2 active devices (/dev/sda3 and /dev/sdb3), 0 spare devices. set partition: use as ext4 filesystem, mount point /
Fourth partitioning attempt:
First hard disk (/dev/sda):
- 10 MB partition, use as reserved BIOS boot area, bootable flag off
- 32 GB partition, use as swap space
- rest of the space partition, use as ext4 filesystem, mount point /, bootable flag off
Second hard disk (/dev/sdb):
- 10 MB partition, use as reserved BIOS boot area, bootable flag off
- 32 GB partition, use as swap space
- rest of the space partition, use as ext4 filesystem, mount point /, bootable flag off
First RAID device (/dev/md0): RAID1, 2 active devices (/dev/sda3 and /dev/sdb3), 0 spare devices. set partition: use as ext4 filesystem, mount point /
Second RAID device (/dev/md1): RAID1, 2 active devices (/dev/sda1 and /dev/sdb1), 0 spare devices. set partition: use as ext4 filesystem, mount point /boot
Third RAID device (/dev/md2): RAID0, 2 active devices (/dev/sda2 and /dev/sdb2). set partition: use as swap area
Fifth partitioning attempt (made sure all software RAID devices are removed, delete all partitions, create new partition tables):
First hard disk (/dev/sda):
- 10 MB partition, use as reserved BIOS boot area, bootable flag off
- 32 GB partition, use as swap space
- rest of the space partition, use as ext4 filesystem, mount point /, bootable flag off
Second hard disk (/dev/sdb):
- 10 MB partition, use as reserved BIOS boot area, bootable flag off
- 32 GB partition, use as swap space
- rest of the space partition, use as ext4 filesystem, mount point /, bootable flag off
First RAID device (/dev/md0): RAID1, 2 active devices (/dev/sda3 and /dev/sdb3), 0 spare devices. set partition: use as ext4 filesystem, mount point /
install GRUB bootloader to /dev/sda and /dev/sdb. It works!
Network Configuration (2/22/2016)
As with the test web server, network configuration can be annoying. First, I had to figure out the right LAN port on the mobo by plugging the RJ45 cable in and waiting for the LED to light up (it took about 5 seconds and a couple of tries). Then I went to the terminal to check on the network interfaces:
$ ifconfig $ ifconfig -a $ sudo ifconfig eth0 up $ cat /etc/network/interfaces
After bringing up the eth0 interface (it's down if it's not listed in the output of ifconfig), I then modified /etc/network/interfaces to set up the eth0 interface:
$ sudo vi /etc/network/interfaces
And added these lines:
auto eth0 iface eth0 inet dhcp dns-nameservers 8.8.8.8 8.8.4.4
Then I used ifdown/ifup to reconfigure the interface:
$ sudo ifdown eth0 $ sudo ifup eth0
There's a couple of configuration files that you can check to make sure that the network configured correctly (I compared them to the corresponding files in the test web server):
$ hostname -I $ cat /etc/resolv.conf $ cat /etc/hosts $ cat /var/lib/dhcp/dhclient.eth0.leases
Then I checked if it was connected to the internet:
$ ping google.com $ sudo apt-get update
I got a "GPG error: http://security.ubuntu.com trusty-security InRelease: Clearsigned file isn't valid, got 'NODATA' (does the network require authentication?)" message on the apt-get update a couple of times, so I tried sudo ifdown eth0 and sudo ifup eth0 a couple of times. Then I rebooted the machine and tried to update the package manager again, and it still didn't work.
These results seem familiar; I think I had the same error when I tried to connect the test web server to the internet before Ed filed the ticket with the IT help desk, which suggests that we may have given the wrong MAC address or IT messed up the configuration. Still, I checked all of the configuration files. I only noted a couple of differences between the test web server network interface and this web server network interface:
- The IP addresses are different. The test web server has an address that starts with 128, but this webserver has an address that starts with 10. (Ed thinks this is a sign that this webserver's IP address limits it to the Rice network).
- The subnet masks are different. The test web server has a subnet mask that ends in 240, but this webserver has a mask that ends in 0.
- The test webserver has a DNS domain name (i.e. the output of hostname -d) of attlocal.net. This webserver doesn't have one. I tried adding it (by editing /etc/hosts), but that change alone didn't help.
Interesting side note: going into the mobo BIOS menu, under "Server Mgmt" there is a submenu "BMC network configuration" that shows the MAC address for "DM_LAN1" as ending in de, whereas the MAC address for eth0 ends in dc (otherwise, the two MAC addresses are the same). So maybe the mobo is interfering with the MAC address? But changing DM_LAN1's Config Address source from "Previous State" to "DynamicBmcDhcp" doesn't fix the problem (and upon reboot, it switches back to Previous State).
Turns out IT just configured the network IP addresses incorrectly. Ed and I talked to the IT desk on Tuesday and we got new IP addresses.
Installing Software (2/24/2016)
Now that we have internet connection, we can start getting packages:
$ sudo apt-get update $ sudo apt-get upgrade
Since I didn't install the SSH server in the beginning, I'll go ahead and install the openssh-server package now:
$ sudo apt-get install openssh-server
Backup the SSH server config file:
$ sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original
Installing Mediawiki (3/7/2016)
As with the test web server, I followed the steps from this page on installing Mediawiki.
Make a directory for the stable version of Mediawiki (1.26.2), which isn't available through apt-get, so we're downloading the official tarball!
$ mkdir ~/Downloads $ cd ~/Downloads $ wget https://releases.wikimedia.org/mediawiki/1.26/mediawiki-1.26.2.tar.gz $ tar -xvzf /pathtofile/mediawiki-*.tar.gz
Copy the extracted files to /var/lib/mediawiki:
$ sudo mkdir /var/lib/mediawiki $ sudo mv mediawiki-1.26.2/* /var/lib/mediawiki
Then set up the mediawiki directory:
$ cd /var/www/html $ sudo ln -s /var/lib/mediawiki mediawiki
Now point a browser to http://[ip_address]/mediawiki/mw-config/index.php and configure the Mediawiki site as follows:
Choose both "your language" and the "wiki language" to be English and continue to the next page. Make sure that all of the environmental checks pass before continuing to the next page. Leave the "database host" as localhost and change "database name" to mcnair. Leave "database table prefix" empty and "database username" as root. Set the "database password" to whatever the password for the MySQL user was set as during installation and then continue to the next page. Check the box for "Use this account for installation" and choose InnoDB for "Storage Engine" and choose Binary for "Database character set" and continue to the next page. Set the name of the wiki as McNair Center and let the project namespace be the same as the wiki name. For the administrator account, set the username, password, and email. Choose to subscribe to the release announcements mailing list if you provide an email, and choose to answer more questions.
Choose "open wiki" for the user rights profile. Choose "no license footer". Uncheck the box for "enable outbound email" and choose which skin you'd like to use. For extensions, leave them all unchecked. Leave "enable file uploads" unchecked. Don't change the Logo URL and don't check "enable Instant Commons". For caching, choose "no caching".
Copy the downloaded LocalSettings.php configuration file onto the webserver in the root directory of the mediawiki installation: /var/lib/mediawiki. Then point a browser to http://[ip_address]/mediawiki and see your new site!
Short URLs (3/7/2016)
Same as for the test web server.
Labeled Section Transclusion (3/7/2016)
Same as for the test web server.
Responsive Design (3/7/2016)
Same as for the test web server.
Mediawiki CSS changes (3/9/2016)
Started working with Julia on the mediawiki website CSS design (color scheme and typography on Website Design). Ran into a couple of problems:
- If you upload a file to Slack and want to download it from its URL using the wget command on command-line, make sure you get a public link from the person who uploaded the file, otherwise the file won't be downloaded. (I was trying to figure out why the McNair logo that Julia sent me on slack wasn't showing up on the website, but it turns out I just needed a public link to the file, which should look something like https://files.slack.com/files-pri/T0JA2A9Q9-F0RL0G4BZ/mcnair.png?pub_secret=30505f5d02).
- the @font-face rule doesn't seem to work in Common.css... I never got past this problem. I think the .tff file for the font may have failed to download onto the server properly, but I haven't found a good way to test for that case. Also, I tried using an absolute URL (i.e. http://128.42.44.180/mediawiki/resources/assets/fonts/franklin-gothic-book.ttf) when specifying the @font-face rule, but it doesn't seem to help. Using an absolute URL to the slack file public URL (i.e. https://files.slack.com/files-pri/T0JA2A9Q9-F0RLDB3G8/download/franklin-gothic-book.ttf?pub_secret=327cdaaeb8) doesn't seem to work either.
Well, I don't really trust the file to download onto the webserver properly from terminal, so I got an SFTP client and used that to copy the .ttf file onto the webserver. Still no dice.
Setting up users (3/11/2016)
First, getting the ImportUsers extension for bulk account creation (using a CSV). Downloading the extension is as follows:
$ cd ~/Downloads $ wget https://extdist.wmflabs.org/dist/extensions/ImportUsers-REL1_26-0fe9e22.tar.gz $ tar -xzvf ImportUsers-REL1_26-0fe9e22.tar.gz $ cd /var/lib/mediawiki/extensions $ cp -r ~/Downloads/ImportUsers ./ImportUsers
Then edit LocalSettings.php and add this line:
require_once("$IP/extensions/ImportUsers/ImportUsers.php");
Then we just have to make a CSV with columns for username, password, email, real name, and user groups (optional). More info on the extension documentation page.
I made a small little CSV to test the ImportUsers extensions:
user1,pass1,user1@example.com,Dummy One user2,pass2,user2@example.com,Dummy Two user3,pass3,user3@example.com,Dummy Three
After importing the users, run a maintenance script from the command line to update new user statistics:
$ cd /var/lib/mediawiki/maintenance $ php initSiteStats.php
But this runs into some errors (this page suggests setting the MW_INSTALL_PATH environment variable, but I can't find a good way to do that).
We also want to limit account creation to sysops only as done here. To do this, edit LocalSettings.php and add these lines:
# Prevent new user registrations except by sysops $wgGroupPermissions['*']['createaccount'] = false;
To-do list
- extra namespaces for IntraACL stuff. see here
- open source blogging platform (separate from the Mediawiki)
- BibTex extension