Quick server setup

Install lighttpd + lua support along with mysql, and php5-fpm and some other useful applications.

Migration steps:
1. Copy files & folders
2. Run install line
3. Run bash to install the rest
4. Download old db
5. Run import mysql bash
6. Copy crontab

If you are migrating from a previous server, you may also want to import this from the old server:

Backup files:
/etc/lighttpd/.lighttpdpassword
/etc/lighttpd/lighttpd.conf
/etc/lighttpd/wp-rewrite.conf
/etc/squid/squid.conf
/var/backupmysql.sh

Backup folders:
/etc/php5/fpm/pool.d
/var/www2

And make new file(s):
/var/backuplog.log

And new folder(s):
/var/backupmysql

Also don’t forget to copy your crontab over

First of all, some useful/mandatory applications and mysql

1. Installs htop, rcconf, aptitude, vim, dos2unix and mysql

apt-get -y install htop aptitude rcconf vim dos2unix mysql-server

Copy this next part to a new file and name it something.sh, upload it to your server. I use the “/var” directory. “dos2unix thefile.sh” first if you uploaded from windows to make sure line endings are correct. After this, chmod u+x thefile.sh and then run it “./thefile.sh”.

2. Adds 2 sources to download from
3. Installs lighttpd with lua support
4. Installs php
5. Adds standard php on port 9000 to lighttpd
6. Configures & restarts lighttpd and php
7. Disable and then re-enable php-fpm mod for lighttpd (some bug requires that)
8. change owner for /var/www2 ‘s subfolders to www-data
9. Install phpmyadmin

#!/bin/bash
echo deb http://www.jonmoniaci.com/debian-ppa/ lenny main contrib non-free >> /etc/apt/sources.list
echo deb http://packages.dotdeb.org stable all >> /etc/apt/sources.list
wget http://www.dotdeb.org/dotdeb.gpg
cat dotdeb.gpg | apt-key add -
rm dotdeb.gpg
apt-get -y --force-yes update
apt-get -y --force-yes install lighttpd-mod-magnet php5-cli php5-common php5-suhosin php5-fpm php5-cgi
echo -e "server.modules += ( \"mod_fastcgi\" )\n fastcgi.server = ( \".php\" =>\n                    ( \"localhost\" =>\n                        (\n                            \"host\" => \"127.0.0.1\",\n                            \"port\" => \"9000\"\n                        )\n                    )\n                 )" > /etc/lighttpd/conf-available/10-fastcgi-fpm.conf
lighttpd-disable-mod fastcgi
lighttpd-disable-mod fastcgi-php
lighttpd-enable-mod fastcgi-fpm
ldconfig
/etc/init.d/php5-fpm restart
/etc/init.d/lighttpd restart
lighttpd-disable-mod fastcgi-fpm
lighttpd-enable-mod fastcgi-fpm
mkdir www2
chmod 777 www2
chown -R www-data /var/www2/*
apt-get -y --force-yes install phpmyadmin

Other:

Import old database using ftp:

cd /var
wget ftp://user:pass@xxx.x.x/../../home/backup-mysql/backup-something.gz
gunzip backup-*.sql.gz

If you are migrating from a previous server, you may have to ‘fix’ your mysql database after having imported the old one. This will fix your mysql tables and also make debian-sys-maint function again.

PS. Change –password=YourPassword prior to copying & pasting (3x).
PS2. debian-sys-maint password can be found in /etc/mysql/debian.cnf

As a bash

#!/bin/bash
mysqlpassword=YourPassword
debiansysmaintpassword=/etc/mysql/debian.cnf

cd /var
mysql --password=$mysqlpassword -h localhost < backup-*.sql
gunzip /usr/share/doc/phpmyadmin/examples/create_tables.sql.gz
mysql -u root --password=$mysqlpassword -h localhost < /usr/share/doc/phpmyadmin/examples/create_tables.sql
mysql -u root --password=$mysqlpassword << EOT
GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '$debiansysmaintpassword' WITH GRANT OPTION;
\q
EOT
rm backup-*.sql

Or not as a bash

mysql --password=YourPassword -h localhost < backup-*.sql
gunzip /usr/share/doc/phpmyadmin/examples/create_tables.sql.gz
mysql -u root --password=YourPassword -h localhost < /usr/share/doc/phpmyadmin/examples/create_tables.sql
mysql -u root --password=YourPassword
GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
\q

Leave a Reply

Your email address will not be published. Required fields are marked *