Main Page
Contents |
The Server
This site is running on an Amazon Cloud Server (EC2 - Elastic Cloud Computing) as part of Amazon Web Services start here: http://aws.amazon.com/free
After signing up, create a new cloud server, known as an 'Instance' https://console.aws.amazon.com/ec2/home
You can select any geographical region in the navigation bar. Then from the menu Instance -> Instances -> Launch Instance -> Quick Launch Wizard
enter in a name, keyfile name (you must download this keyfile), and chose an OS. (I chose Ubuntu Server Cloud Guest 11.10 (Oneiric Ocelot) 32 bit which is Free tier eligible) Continue -> Edit details -> Security Settings -> Create new Security Group
Group name: websecurity Description: webserver Created new rule for SSH and HTTP with Source 0.0.0.0 (i.e. anywhere) This lets SSH and HTTP (web) traffic through the firewall.
Create -> Save details -> Launch -> Close
You should see your new server under Instances.
Last step here is to get an IP for this server (what is known as an 'Elastic IP' ) NETWORK & SECURITY -> Elastic IPs -> Allocate New Address -> Associate Address with the newly created instance "Web Server"
DNS
At this point I got a domain name from namecheap.com and pointed it to this IP. > My Account > Manage Domains > Modify Domain > All Host Records
hostname: @ ip address/url: 107.21.110.115 record type: A (Address)
hostname: www ip address/url: alaning.me. record type: CNAME (Alias)
In DNS an A record maps a hostname (eg alaning.me) to an IP (eg 107.21.110.115) a CNAME record maps one hostname (eg www.alaning.me) to another hostname (eg alaning.me.) this means that going to the address www.alaning.me has the same effect as going to alaning.me @ - means none. i.e., @ equals http://alaning.me without www.
Right click your instance under Instances and click connect Follow instructions to ssh in. If you are on *nix system like Linux or Mac OS X you will be use ssh from Terminal. If you are on Windows you will require putty.exe.
Setting it up
Software: MediaWiki, Wordpress
This installs everything I used
sudo apt-get install apache2 php5 mysql-server php5-mysql
apache2 - web server php5 - server-side scripting language mysql-server - database server php5-mysql - allows php scripts to connect to mysql database
You will be prompted to enter a mysql root password, note this down as this will be used later.
After install you must reload apache (important: things didn't work correctly because I didn't do this).
sudo /etc/init.d/apache2 reload
then to test php works correctly go into the web directory
cd /var/www sudo echo "<?php phpinfo(); ?>" > /var/www/info.php
and view this file here: http://alaning.me/info.php (I've taken it down already).
Installing MediaWiki
now to clear everything in the web directory, download and extract mediawiki Grab the latest download link from http://www.mediawiki.org/wiki/Download
cd /var/www sudo su rm * wget http://download.wikimedia.org/mediawiki/1.18/mediawiki-1.18.1.tar.gz tar zxvf mediawiki-1.18.1.tar.gz mv mediawiki-1.18.1/* ./ rm -r mediawiki-1.18.1/
Unfortunately the above does not apply anymore as of version 1.18.2 and you won't be able to wget it and install it that way. Must use subversion. [http://www.mediawiki.org/wiki/Download_from_SVN]
sudo apt-get install subversion svn checkout http://svn.wikimedia.org/svnroot/mediawiki/branches/REL1_18/phase3 mv phase3/* ./
webbrowser: go to http://alaning.me follow the instructions
>Could not find GD library or ImageMagick.
sudo apt-get install imagemagick
now you download your LocalSettings.php open it and copy everything paste the contents of your LocalSettings.php file in to a new file on your web directory (/var/www)
vim LocalSettings.php
vim is a command line based editor, type i to go into insert mode, paste (using your shortcut keys), type :wq! to save and quit after finished tried to go to http://alaning.me
I decided to allow image and file uploads >File uploads potentially expose your server to security risks. For more information, read the security section in the manual. >To enable file uploads, change the mode on the images subdirectory under MediaWiki's root directory so that the web server can write to it. Then enable this option.
chmod -R 777 images/
MediaWiki installed, now Wordpress
Installing WordPress
make a blog dir
mkdir /var/www/blog cd /var/www/blog
grab the latest Wordpress here: http://wordpress.org/download/ download extract move so the wordpress files are in blog folder go to http://alaning.me/blog and follow instructions Then I ran into a database error. Namely, I had to create a database called 'wordpress'
$mysql -u root -p Enter password: >create database wordpress; >exit
then continue with the webpage form. entering mysql user=root and password that was created before. Got an error: Sorry, but I can't write the wp-config.php file. You can create the wp-config.php manually and paste the following text into it. So copy everything vim wp-config.php i for insert mode and paste it in The "Run the install" should all work, login and now you're in wp-admin
Change the permalink structure
Settings > Permalinks Custom Structure: /%year%/%postname%/
Save it and it shows a complaint that my .htaccess isn't writeable. to fix do
cd /var/www/blog (where wordpress is installed) touch .htaccess chmod -v 666 .htaccess
Try saving it again. Go to the home page and click on the Hello World entry. You'll get a Not Found error.
I had so much problems with this until I figured out how to fix it. Basically the idea is that some urls, for example: http://alaning.me/blog/2012/hello-world/, do not correspond to a physical directory on the server (ie. there is a folder called blog at /var/www/blog but there isn't a /var/www/blog/2012 or /var/www/blog/2012/hello-world). What is means is that the webserver must rewrite a url like http://alaning.me/blog/2012/hello-world/ to become http://alaning.me/blog/?p=123 so that even though the users visited the first link, the actual content comes from the second. This is done in apache by using mod_rewrite http://httpd.apache.org/docs/current/mod/mod_rewrite.html.
Enabling mod_rewrite
assuming apache2 installed do
a2enmod rewrite
then edit /etc/apache2/sites-available/default and change this:
Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all
to this
Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny allow from all
then restart apache2 so that it reloads from the config file
service apache2 restart
Apache Virtual Hosts
I don't want my blog to be accessible by going through [http://alaning.me/blog] rather I'd like it to be at [http://blog.alaning.me] this is a new domain which implies a new IP. but we don't have a new IP. we already have one. what we want to do is treat requests for 'blog.alaning.me' differently from 'alaning.me' even though they point to the same IP.
this is done using Apache's virtual host
cd /etc/apache2/site-avaliable
make a file named 'alaning.me' with the contents:
<VirtualHost *:80> ServerName alaning.me ServerAlias www.alaning.me DocumentRoot /var/www/alaning.me </VirtualHost>
make another file named 'blog.alaning.me' with the contents:
<VirtualHost *:80> ServerName blog.alaning.me DocumentRoot /var/www/blog.alaning.me </VirtualHost>
(copy the old files around - don't delete them just yet /var/www/ --> /var/www/alaning.me /var/www/blog --> /var/www/blog.alaning.me )
Then do:
a2ensite alaning.me a2ensite blog.alaning.me /etc/init.d/apache2 reload
Update in Wordpress Settings the URL to http://blog.alaning.me
save, re do the .htaccess file (probably wasn't copied over properly) and it should all go well. then rm -rf the old dir
In DNS make a new CNAME called blog (blog.alaning.me) that points to alaning.me
Then have to wait a few hours (minutes?) for global dns servers to update with the new entry.
Congratulations. You have now moved [http://alaning.me/blog] to [http://blog.alaning.me].
But there is a problem. I uploaded an image at http://alaning.me/blog/wp-content/uploads/2012/04/if-you-can.png but that has been moved to this: http://blog.alaning.me/wp-content/uploads/2012/04/if-you-can.png
How to fix. remake the blog dir (/var/www/alaning.me/blog) make a .htaccess file with the following contents.
RewriteEngine on RewriteRule (.*) http://blog.alaning.me/$1 [R=301,L]
Now the image should be shown properly.