Basic Magento/PHP development environment - Part 2
In this second part we're continue some setup and go through a test magento install. You can find the first part here if you missed it.
MySQL configuration
We now need to grant our host machine access to connect to MySQL on our vm. Here you'll use the MySQL root password you setup previously. Note: if you used a different IP address adjust the commands accordingly.
mysql -u root -p
Once connected run the following SQL (fee free to change the password):
GRANT ALL PRIVILEGES ON *.* TO root@'192.168.56.1' IDENTIFIED BY 'magedev'; FLUSH PRIVILEGES; exit
su root nano /etc/mysql/my.cnf
Find and comment out the bind-address setting:
... skip-external-locking # # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. #bind-address = 127.0.0.1 ...
Restart MySQL:
/etc/init.d/mysql restart
Using an external database manager such as SequelPro or MySQL Workbench you should be able to connect to the database on the virtual machine.
I'll be using SequelPro on my system, but the settings should be similar for MySQL Workbench.
We'll go ahead an add a database named “magedev” that we'll use later on during Magento's installation.
Sharing folders with guest system.
We'll now setup a local directory that will be accessed on the virtual machine. This will allow applications on the host machine to work on files locally and changes will be immediately seen by the guest vm. There will be no need to transfer files or mount the remote host via [s]ftp or sabma.
I personally like to keep all project files inside of ~/Documents/Projects. I will share this parent directory so that any new project I add will be accessible by the vm. From the Devices menu select “Shared Folders”, click on the Add Shared folder icon.
On the virtual machine run the following:
su root mkdir /mnt/Projects chown magedev:magedev /mnt/Projects/
We'll now configure our shared folder to mount on start up:
nano /etc/fstab
Add the following to the bottom of the file:
Projects /mnt/Projects vboxsf defaults,ttl=5,uid=1000,gid=1000 0 0
Now run:
mount -a ls /mnt/Projects/
You should see any files you have on your local Projects folder. If you started with a new directory, try adding some files to make sure everything is working properly. Note, the uid and gui are of our magedev user, chances are that your system should have the same values.
Installing Magento
We'll start off by downloading the source off of Magento's SVN. Feel free to download the zip/tar and extract the source yourself from here. From the host machine:
svn export http://svn.magentocommerce.com/source/branches/1.6 ~/Documents/Projects/magedev
Lets add a local host for our project, add
192.168.56.2 magedev.vm
to your /etc/hosts file.
Now we must link the ~/Documents/Projects/magedev directory to our magedev user's public_html directory. On the virtual machine run:
ln -s /mnt/Projects/magedev /home/magedev/public_html/magedev
Now navigate to http://magedev.vm/, you should be greeted by the Magento Installation Wizard. As these next
Configuration:
If you've been following along the information for MySQL should be:
host: localhost
datbase: magedev
username: root
password: magedev
Web Access Options:
Base URL: http://magedev.vm/
Admin Path: admin
Enable Charts: Checked
Skip Base URL Validation…: Checked
Use Web Server (Apache) Rewrites: Checked
Use Secure URLs (SSL): Unchecked
Session can be set to “File System” (not shown in screen shot).
Once you hit continue Magento will proceed to install, once completed you can create the initial admin account:
This is the final step in the installation and you should be able to go the backend and frontend.
If everything worked out well for you then you should see the same results. If you ran into any issues feel free to leave a comment.
One Small Kink
Due to the use of VirtualDocumentRoot directive in Apache mod_rewrite tends to break/get confused and magento's .htaccess needs some tweaking. Modify magento's .htaccess file:
nano .htaccess
Locate the “#RewriteBase /magento” line and replace it with: “RewriteBase /“.