5 Minute Debian LAMP Setup In Google Compute Engine

We just started dabbling with Google's latest offering, Compute Engine and I have to say so far I'm very impressed.  We've already moved over one of our production web servers from Amazon EC2. The Google Compute Console UI is clean, easy to use, and spinning up instances takes less than 10 seconds.  

Google currently offers three Linux images.  We got ourselves started with Backports Debian 7 Wheezy.  Being a meticulous list-maker I hope this helps someone in the future with getting their LAMP stack set up.  I am not a Linux guru so it may be common sense so some veterans, but I like to keep things simple.

Login to your instance via SSH and perform an apt-get update.

sudo apt-get update

Install Apache

sudo apt-get install apache2

Verify Apache is setup correctly by typing your instance IP into your web browser.  http://your-instance-ip

You should be seeing Apache's success message, "It Works!" If you do not see this, verify your instance frewall has port 80 opened up to all traffic.

Install Mod Rewrite for Apache

sudo a2enmod rewrite

Now you have to edit a file to allow .htaccess 

sudo nano /etc/apache2/sites-available/default

In the  section change AllowOverride None to AllowOverride All
sudo service apache2 restart

 

Install MySQL

sudo apt-get install mysql-server

mysql_secure_installation

If want to be able to access MySQL from outside the localhost you need to grant privileges.

mysql -u root -p 

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '[your root password]' WITH GRANT OPTION;

exit

sudo nano /etc/mysql/my.cnf

comment out the bind-address = 127.0.0.1

#bind-address = 127.0.0.1

sudo service mysql restart

Install PHP

sudo apt-get install php5 php-pear php5-mysql

sudo service apache2 restart

Install cURL

sudo apt-get install php5-curl

sudo service apache2 restart

Install GD Graphics Package for PHP

sudo apt-get install php5-gd

sudo service apache2 restart

Install Webmin

Personally, I like to use Webmin for managing users, apache websites, etc.  This isn't required but if you're interested in setting it up, it has some great tools that expedite Linux server management and administration.

cd /

sudo wget http://prdownloads.sourceforge.net/webadmin/webmin_1.670_all.deb

sudo dpkg --install webmin_1.670_all.deb

sudo apt-get -f install

It should now be working on port 10000 so make sure you have that open in your firewall as well. 
http://your-instance-ip:10000
The default username is root and the password is your Linux root password.

To change your root password

sudo passwd

Install Zip Unzip

This is another optional component but I find it helpful when moving website data for example.  It's must faster to zip up a web directory and download one file than thousands of files.

sudo apt-get install zip

sudo apt-get install unzip

To unzip an entire file

unzip website.zip

To uzip only a certain file from a zip file

unzip website.zip onlythisfile.html

To Zip only the one directory you're in with no sub directories included

zip data *

To Zip an entire direcotry including all sub directories from the folder you are in

zip -r data *

Allow SSH for additional users with password and not require public key

sudo nano /etc/ssh/sshd_config

Find the line PasswordAuthentication no and change to yes

PasswordAuthentication yes

 

Some Quick Commands that are helpful

Stop Apache: sudo /etc/init.d/apache2 stop
Start Apache: sudo /etc/init.d/apache2 start
Restart Apache: sudo /etc/init.d/apache2 restart

Start MySQL: sudo service mysql start
Stop MySQL: sudo service mysql stop
Restart MySQL: sudo service mysql restart

Deleting Files and Folders

This will remove all files:  
rm /path/to/directory/*.*

This will remove all files and sub-folders:   
rm -rf /path/to/directory/*

Common Network Commands

netstat -a | more - Shows all active connections and ports (Listening)

netstat -an | more - Shows the actual port numbers as opposed to the named ports

netstat -a -p tcp   Adding -p (protocol) then either tcp or udp will show only that protocol, helps narrow down a huge list.

I will update this list as needed. But feel free to comment and share your thoughts. 

google compute engine, debian wheezy, lamp setup, gce instances, google compute cloud, cloud computing google, backports, new york web design

0 Comments

Add your comment