A little guide to save my server if it crashes again.

First Steps

  1. Flash SD Card with RPi OS
  2. Config: Boot to CLI, hostname homegrownapps, overclock 1000MHz, set passwords to something more secure, ssh on
  3. Set DHCP reservation for RPi (192.168.0.2) - old port forwarding settings will work
  4. Connect Pi to power and Ethernet
  5. Enable root login: ssh (don’t forget to delete old entry in known_hosts) into Pi then sudo su into root, then passwd.
  6. Enable root ssh with password: nano /etc/ssh/sshd_config and change PermitRootLogin without-password to PermitRootLogin yes. Then do /etc/init.d/ssh restart
  7. Transfer root dir and pi dir files. Careful with overwriting the dotfiles in each - check contents.
  8. sudo apt-get update && sudo apt-get upgrade (good practice to do so)

LAMP Base

  1. sudo apt-get install apache2
  2. Transfer apache2 conf files from /etc/apache2 (check contents first and make a backup of the apache2 conf files on server): Transfer apache2.conf, copy sites in sites-available over. DO NOT SIMPLY COPY THE CONFIG DIRECTORY OVER - IF YOU DO, THE INSTALLATION WILL CRASH!
  3. Install mysql-server
  4. Check /etc/mysql for config file diffs (there most likely won’t be any)
  5. Transfer all files from /var/lib/mysql to the server /var/lib/mysql
  6. Check for MySQL password (mysql -p); if it doesn’t work:
    1. Stop mysql service: /etc/init.d/mysql stop Output: Stopping MySQL database server: mysqld.
    2. Start MySQL server without password: mysqld_safe --skip-grant-tables & Output: [1] 5988 Starting mysqld daemon with databases from /var/lib/mysql mysqld_safe[6025]: started
    3. Connect to mysql server using mysql client: mysql -u root Output: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>
    4. Setup new MySQL root user password mysql> use mysql; mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root'; mysql> flush privileges; mysql> quit

    5. Stop MySQL Server: # /etc/init.d/mysql stop Output: Stopping MySQL database server: mysqld STOPPING server from pid file /var/run/mysqld/mysqld.pid mysqld_safe[6186]: ended [1]+ Done mysqld_safe --skip-grant-tables

    6. Start MySQL server and test it /etc/init.d/mysql start mysql -u root -p
  7. Open mysql (mysql -p) and DROP TABLE phpmyadmin;
  8. Install phpmyadmin and dependencies
  9. Edit /etc/php5/apache2/php.ini - add line extension=mysqli.so
  10. Transfer contents of /var/www to server

Webalizer

  1. Install webalizer (sudo apt-get install webalizer)

Webmin

  1. Add deb http://download.webmin.com/download/repository sarge contrib deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib to /etc/apt/sources.list
  2. cd /root
  3. wget http://www.webmin.com/jcameron-key.asc
  4. apt-key add jcameron-key.asc
  5. sudo apt-get update
  6. sudo apt-get install webmin

Blog

  1. sudo apt-get install ruby
  2. sudo apt-get install ruby2.0-dev (If this doesn’t work install ruby2.(x)/dev where x is version installed on system.)
  3. gem install rubygems-update
  4. update_rubygems
  5. gem update --system
  6. gem install jekyll
  7. Transfer /var/blog to server