#Setting Up a Development LAMP Stack: ##Using Windows, VirtualBox, and Ubuntu
This document describes how to set up a development LAMP stack using a host Windows machine, VirtualBox, and Ubuntu Server 12.04.
###Step 1: Setting up the host machine
- Create a shared folder on the host machine. This can be anywhere. I placed mine in my documents folder.
- Edit your hosts file as Administrator
- Right click on Notepad or your editor of choice and select Run as Administrator
- On Windows navigate to C:\Windows\System32\drivers\etc and open the hosts file
- Add the following line to the file: 127.0.0.1 sandbox.dev
- Save the file
###Step 2: Getting the stuff you need
- Install VirtualBox http://virtualbox.org
- Install PuTTY http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
- Be sure to get the installer version, it will be an exe file
- Download the Ubuntu Server 12.04 64-bit ISO file http://ubuntu.com
- On Intel based machines, you will have to enable virtualization in the BIOS of your host computer. Instructions for this will vary by manufacturer
###Step 3: Creating the virtual machine
- Open VirtualBox
- Click New
- Give your machine a name, I used Sandbox
- OS is Linux
- Version is Ubuntu 64-bit
- Set the memory, for best results use 2048 MB, but 1024 can be used as well if memory is limited.
- Create a new virtual disk, the defaults are all fine
- Keep going until you are able to click Create
- After you click Create, your virtual machine is ready
###Step 4: Configuring the virtual machine
- Make sure your VM is selected in list at the left
- Click Settings in the toolbar
- Click on Storage
- Under the IDE controller, select the cd-rom drive, it should be empty
- Under Attributes, click the CD at the far right and browse to you Ubuntu ISO and select it
- Next Click on Network
- Click Advanced
- Click Port Forwarding
- Click the green plus sign to add a forward
- You'll need to add three forwards
- Name: HTTP, Protocol: TCP, Host Port: 8080, Guest Port 80
- Name: MySQL, Protocol: TCP, Host Port: 9306, Guest Port 3306
- Name: SSH, Protocol: TCP, Host Port: 2222, Guest Port 22
- Click OK
- Click Shared Folders
- Click the green plus at the right to add one
- Under Folder Path, click other and browse to the folder you created in Step 1
- Make sure Auto-mount is checked -Click OK
- Configuring is complete, click OK
###Step 5: Installing Ubuntu Server 12.04
- In VirtualBox, select Sandbox and click the Start icon
- Read and dismiss all warnings that pop up, click the Do not show this meesage again checkbox to make sure they don't come up again the next time you start your VM
- In the VM window, select English, then hit Enter to Install the Ubuntu Server
- Select all defaults through the next several screens, you can switch between options by pressing tab and the enter key accepts your input
- For the hostname, you can just leave it as ubuntu
- Enter your full name
- Enter your desired login name
- Enter your password
- Confirm your password, if it is weak you will recieve a warning, it is okay to use a weak password here since this is a dev server
- Do not encrypt your home directory
- Set your timezone
- Partition the disk
- Select the first option Guided - use entire disk
- Don't worry, this will only see your virtual disk
- Hit Enter on the Partition Disks screen since there should only be one disk to choose from
- Select Yes when asked to Write the changes to disks, then hit Enter
- Hit enter and leave the proxy server blank
- Hit enter for No automatic updates
- On the Software Selection screen use the arrow keys to navigate to OpenSSH server, press the spacebar to select it, do the same for LAMP server, press tab to select Continue and hit enter.
- Set your MySQL password, since this is a dev machine, I used a simple password
- Select Yed to install GRUB to the master boot record and hit enter
- Once the installation is complete hit Enter to reboot the machine
- In the menu bar at the top of the VM window, click Devices and click Install Guest Additions. This will allow you to install the Guest Additions later
###Step 6: Login via SSH
- Connect to the dev server using PuTTY
- Enter sandbox.dev as the hostname and 2222 as the port, connection type will be SSH
- Under Saved Sessions enter sandbox.dev and click the save button
- The next time you start PuTTY, you can select sandbox.dev from the list and click Load to load these settings automatically
- Click Open
- Click Yes on the Security Alert
- Log in using the Ubuntu username and password you set up earlier
###Step 7: Configure Ubuntu
- Update Ubuntu
- sudo apt-get update
- sudo apt-get upgrade
- Install the following packages via apt
- build-essential
- module-assistant
- linux-headers-$(uname -r)
- dkms
- zip
- unzip
- These packages can be installed using the following command
- sudo apt-get install -q -y build-essential module-assistant linux-headers-$(uname -r) dkms zip unzip
- Install the Guest Addtions
- We've already made the Guest Additions available at the end of step 5
- Mount the Guest Additions ISO
- sudo mount /dev/cdrom /media/cdrom
- Install the Guest Additions
- sudo sh /media/cdrom/VBoxLinuxAdditions.run
- Error message regarding the X Window System can be safely ingored
###Step 8: Configure Apache
-
Set user permissions and groups and other configuration parameters
- sudo usermod -a -G vboxsf username
- This gets you access to the shared folder, insert your own username in the place of username
- sudo usermod -a -G vboxsf www-data
- This allows Apache access to the shared folder
- sudo a2enmod rewrite
- Turn on the Apache rewrite module
- sudo usermod -a -G vboxsf username
-
Next we have to tell Apache where the shared folder is
-
Use the following command to create the file. I use nano, but you can use any text editor.
- sudo nano -w /etc/apache2/sites-available/sandbox
- Enter the following configuration data into the file and save:
<VirtualHost *:80>
ServerName sandbox.dev
ServerAlias sandbox.dev
DocumentRoot /media/sf_sandbox/LogLevel info
ErrorLog ${APACHE_LOG_DIR}/sandbox.dev-error.log
CustomLog ${APACHE_LOG_DIR}/sandbox.dev-access.log combinedRewriteEngine On
RewriteLog ${APACHE_LOG_DIR}/sandbox.dev-rewrite.log
RewriteLogLevel 0
</VirtualHost>
-
-
Enable the site with the following command
- sudo a2ensite sandbox
-
Set up the httpd.conf
- sudo nano -w /etc/apache2/httpd.conf
- Enter the following information into the file and save:
- ServerName development
-
Set up error reporting by editing the php.ini file
- sudo nano -w /etc/php5/apache2/php.ini
- Search for the following settings and set their values
- error_reporting = E_ALL
- display_errors = On
- log_errors = On
- log_errors_max_len = 0
- error_log = /media/sf_sandbox/php_errors.log
###Step 9: Configure MySQL
- Edit the my.cnf file
- sudo nano -w /etc/mysql/my.cnf
- Change the bind-address to 0.0.0.0
###Step 10: Setup Exim4 for gmail send
- Install exim4 via apt-get
- sudo apt-get -y install exim4
- Configure exim4
- sudo dpkg-reconfigure exim4-config
- Select "mail sent by smarthost; recieved via SMTP or fetchmail"
- System mail name can be left as "ubuntu"
- Leave IP-addresses to listen for incoming SMTP connections as "127.0.0.1 ; ::1"
- Leave Other destinations as "ubuntu"
- Leave Machines to relay mail for empty
- IP address or host name of outgoing smarthost is:
- smtp.gmail.com::587
- Answer No to the next two questions
- Leave Delivery method for local mail as "mbox format"
- Answer No to the next question and the reconfigure is complete
- Add email and password to exim config
- WARNING this will store your gmail password in plain text
- sudo nano -w /etc/exim4/passwd.client
- Add the following line to the bottom of the file where USERNAME and PASSWORD are your actual username and password for gmail
- *:[email protected]:PASSWORD
###Step 11: Reboot the server
- sudo reboot
###Step 12: Install phpmyadmin
- sudo apt-get -y install phpmyadmin
- Select apache2 as the web server
- Select Yes for Configure database for phpmyadmin
- Set the admistrative user and password, I used root and root since this is a dev server