Setup

From wiki
Revision as of 23:19, 18 October 2013 by Administrator (talk | contribs) (Created page with "==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 ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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: 
 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

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

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 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 index.*
 wget http://download.wikimedia.org/mediawiki/1.20/mediawiki-1.21.1.tar.gz
 tar zxvf mediawiki-1.21.1.tar.gz
 mv mediawiki-1.21.1/* ./
 rm -r mediawiki-1.21.1/

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 vim LocalSettings.php (while in /var/www) 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

things to note

  • unix permissions
  • vim

Lock Down Mediawiki

Add to LocalSettings.php

 # Prevent new user registrations except by sysops
 $wgGroupPermissions['*']['createaccount'] = false;
 # Disable anonymous editing
 $wgGroupPermissions['*']['edit'] = false;

http://www.mediawiki.org/wiki/Manual:Preventing_access $wgShowIPinHeader = false; $wgDisableCounters = true;

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


sub domain

vim /etc/apache2/sites-available/blog.alaning.me

  1. With the following content (modify it according to your needs)
 <VirtualHost *:80>
         ServerName blog.alaning.me
         DocumentRoot /var/www/blog.alaning.me
         <Directory /var/www/blog.alaning.me>
                 AllowOverride All
         </Directory>  

         <Location />
                 Order Allow,Deny
         Allow from All
         </Location>
 </VirtualHost>

  1. 6 Enable the vhost
 a2ensite alaning.me

---

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

things to note

  • mysql and commands

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.

things to note

  • .htaccess

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

 # cat /etc/apache2/sites-available/blog.alaning.me
 <VirtualHost *:80>
         ServerName blog.alaning.me
         DocumentRoot /var/www/blog.alaning.me
         <Directory /var/www/blog.alaning.me>
                 AllowOverride All
         </Directory>  
         <Location />
                 Options Indexes FollowSymLinks MultiViews
         </Location>
 </VirtualHost>
 
 
 # cat /etc/apache2/sites-available/alaning.me
 <VirtualHost *:80>
         ServerName alaning.me
         ServerAlias www.alaning.me
         DocumentRoot /var/www/alaning.me
         <Directory /var/www/alaning.me>
                 AllowOverride All
         </Directory>
         <Location />
                 Order Allow,Deny
                 Allow from All
         </Location>
 </VirtualHost>


then restart apache2 so that it reloads from the config file

 service apache2 restart

things to note

  • apache2 modules (mod_rewrite)
  • apache virtual hosts

wordpress upgrades and updates

 chmod -R 777 wp-content

no ftp needed

done!

apache rewriteengine mod

/var/www/alaning.me/blog# cat .htaccess 
RewriteEngine on
RewriteRule (.*) http://blog.alaning.me/$1 [R=301,L]

moves http://alaning.me/blog/wp-content/uploads/2012/04/if-you-can.png

to http://blog.alaning.me/wp-content/uploads/2012/04/if-you-can.png

SSH key setup

 ssh-keygen -t rsa
 cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'

Put the public key in .ssh/authorized_keys2

Change the permissions of .ssh to 700

Change the permissions of .ssh/authorized_keys2 to 640

sudo chmod 755 ~/.ssh

sudo chmod 644 ~/.ssh/known_hosts

sudo chmod 600 ~/.ssh/id_rsa

sudo chmod 600 ~/.ssh/id_rsa.pub

Permissions 0744 for '/home/geek/.ssh/id_rsa' are too open.

For multiple keys and hosts

.ssh/config:

Host myshortname realname.example.com
Hostname realname.example.com
IdentityFile ~/.ssh/realname_rsa # private key for realname

Host myother realname2.example.org
Hostname realname2.example.org
IdentityFile ~/.ssh/realname2_rsa

Web server Permissions

find what apache is running as (usually www-data)

 ps aux | grep apache
 find /var/www/ -type d -print0 | xargs -0 chmod 755
 find /var/www/ -type f -print0 | xargs -0 chmod 644

webserver: www-data

 chown www-data:www-data -R /var/www/

this would make just your wp-content directory writable by the webserver. You will have to change those names/webroots to your situation. This should push you in the right direction.