Lest get scripting
As most of you won't have administered a Ubuntu web server before then its likely your going to screw things up at some point, and before you go live with an importent site I encourage you to experiment and screw things up as much as possible. When you screw things up you will find yourself going back to the start of this guide and following it again. While its good to repeat things when we need to learn there comes a point where its getting irritating to run through the same crap again and again.
To solve this issue I have written all of the previous commands into a script. Once you get connected to your server you can upload the script and it will do most of the work for you. There are a few things I have left out and I will list them here but at the bottom of the page you will find the script. If you have read ahead or you don't really understand everything you have done so far then I suggest you go back to the start and follow the guide. There is no point getting your web server setup if you can't fix problems later on. To prevent lazy people just copying the script and never even reading the guid I have included a small bug that will be easy to spot for anyone who has followed the guide or already knows how to do all this.
Left out of the script is
And here is the script
#!/bin/bash# Sets up a webserver following thew instructions at http://foreverythingit.co.uk# Feel free to use this, modify it and repost it but please always credit the source##### Constants##### Script##Start by running an updatesudo aptitude updatesudo aptitude upgrade -ysudo aptitude autoclean##Next change the screen resolution to 1024x768sudo sed s/#GRUB_GFXMODE=640x480/GRUB_GFXMODE=1024x768/ -i /etc/default/grubsudo update-grub##next disable ctrl-alt-deletesudo sed 's/exec shutdown -r now "Control-Alt-Delete pressed"/#exec shutdown -r now "Control-Alt-Delete pressed"/' -i /etc/init/control-alt-delete.conf##Setup firewall ports and enable ufwsudo ufw enablesudo ufw allow 20sudo ufw allow 21sudo ufw allow 22sudo ufw allow 23sudo ufw allow 80sudo ufw allow 443##Set up CA/SSL certificates#openssl genrsa -des3 -out server.key 2048#openssl rsa -in server.key -out server.key.insecure#mv server.key server.key.secure#mv server.key.insecure server.key#openssl req -new -key server.key -out server.csr#openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt#sudo cp server.crt /etc/ssl/certs#sudo cp server.key /etc/ssl/private#install phpmyadminsudo apt-get -y install phpmyadmin#add a group for webuserssudo addgroup webuser#Setup the SSH jailsudo sed s,Subsystem sftp /usr/lib/openssh/sftp-server,Subsystem sftp internal-sftp, -i /etc/ssh/sshd_configsudo sh -c "echo -e \"\n\" >> /etc/ssh/sshd_config"sudo sh -c "echo -e \"\n\" >> /etc/ssh/sshd_config"sudo sh -c "echo -e \"\n\" >> /etc/ssh/sshd_config"sudo sh -c "echo -e \"Match Group webuser\" >> /etc/ssh/sshd_config"sudo sh -c "echo -e \" ChrootDirectory %h\" >> /etc/ssh/sshd_config"sudo sh -c "echo -e \" ForceCommand internal-sftp\" >> /etc/ssh/sshd_config"sudo sh -c "echo -e \"\n\" >> /etc/ssh/sshd_config"sudo service ssh restart# install fail 2 bansudo apt-get -y install fail2ban#instal PECL/PEARsudo apt-get -y install php-pear php5-dev build-essentialsudo pecl install uploadprogresssudo sh -c "echo -e \"\; activate and configurate for php uploadprogress module\" >> /etc/php5/apache2/conf.d/uploadprogress.ini"sudo sh -c "echo -e \"extension=uploadprogress.so\" >> /etc/ssh/sshd_config"#installing lib2sshsudo apt-get -y install libssh2-php#Upping the php max upload filesizesudo sed s/upload_max_filesize = 2M/upload_max_filesize = 16M/ -i /etc/php5/apache2/php.inisudo service apache2 restart#Set the server namesudo sh -c "echo -e \"ServerName localhost\" >> /etc/apache2/httpd.conf"##Run another update just incase we accidentally installed an old versionsudo aptitude updatesudo aptitude upgrade -ysudo aptitude autoclean##sudo reboot