Virtualisation: A Symfony Developer’s Best Friend - Part 4
As promised, this post will detail the steps required in order to setup the various daemons on your VM. First of all, let’s improve your shell experience by installing OpenSSH - all that Ctrl-Alt focus switching nonsense that you’ve so far been exposed to is no use to man nor beast; we need a flexible solution so we can switch windows via Alt-TAB. Go ahead and log into your VM as ‘root‘ and we’ll get started.
OpenSSH Installation and Configuration
- Type ‘cd /usr/ports/security/openssh-portable/‘ and hit Enter
- Type ‘make install clean‘ and hit Enter
- Accept defaults on configuration screen, highlight ‘OK‘ and hit Enter
- After the port has been installed, type ‘nano /usr/local/etc/ssh/sshd_config‘ and hit Enter
- Scroll down to the line that reads ‘#PasswordAuthentication no‘, uncomment it and change to ‘PasswordAuthentication yes‘, then hit Ctrl-X to save the file
- Type ‘nano /etc/rc.conf‘ and add ‘openssh_enable=”YES”‘ to the bottom of the file, then hit Ctrl-X to save the file
You can now manually start the SSHD process by typing ‘/usr/local/etc/rc.d/openssh start‘ and hitting Enter, or you can reboot your VM with the ‘shutdown -r now‘ command. Go ahead and manually start the daemon. To verify, download a copy of PuTTy (an excellent free SSH client), point it at your VM’s IP address - you can find this by issuing the command ‘ifconfig -a‘ from within your VM (look for the ‘le0‘ entry) - and try to connect. If you are presented with a dialog box asking if you wish to accept the server’s host key, you’re all set! Click ‘Yes‘ and try logging in as the user you created in the second part of this tutorial series. With any luck, you will be presented with a shell prompt. Kiss goodbye to that clunky VMware Server interface window!
If you tried to log in as ‘root‘, you’ll probably have noticed that you are getting “Access Denied” messages despite entering the correct credentials. Don’t worry, this is an inherent security feature of FreeBSD - you can only log in as a regular user. Once inside, however, you can become superuser by issuing the ‘su‘ command and entering the correct password. Before you can do that, however, you will have to give your own user account permission to do so.
- Log into your VM as ‘root‘ (the old fashioned ‘VMware Server’ way)
- Type ‘nano /etc/group‘ and hit Enter
- Look for the line that reads ‘wheel:*:0:root‘, add a comma then your own username at the end - i.e. ‘wheel:*:0:root,jbloggs‘
- Hit Ctrl-X to save the file and quit the text editor
Apache 2.2 Configuration
Now that we’ve made your shell a bit easier to work with, it is time to turn our attention to your web server software. Apache is an industry-standard and is a doddle to set up, once you get your head round the basics.
- Log into your shell account and change to superuser via ‘su -‘
- Type ‘nano /usr/local/etc/apache22/httpd.conf‘ and hit Enter
- Edit the file so it looks like this - please note, I have cut out all of the inline comments and many of the irrelevant directives
- Hit Ctrl-X to save and quit the text editor
- Type ‘nano /usr/local/etc/apache22/extra/httpd-vhosts.conf‘ and hit Enter
- Edit the file so it looks like this - obviously, you would swap out the placeholder directory with your own
- Hit Ctrl-X to save and quit the text editor
With the configuration taken care of, it is time to add Apache to your VM’s startup procedure.
- Type ‘nano /etc/rc.conf‘ and hit Enter
- Add ‘apache22_enable=”YES”‘ to the bottom of the file
- Hit Ctrl-X to save and quit
- To manually start the daemon, type ‘/usr/local/etc/rc.d/apache22 start‘ and hit Enter
MySQL Configuration
Thankfully, setting up the MySQLd process is a lot more straightforward!
- Type ‘nano /etc/rc.conf‘ and hit Enter
- Add ‘mysql_enable=”YES”‘ to the bottom of the file
- Hit Ctrl-X to save and quit
- To manually start the daemon, type ‘/usr/local/etc/rc.d/mysql-server start‘ and hit Enter
Okay, I think that’s enough for now! You have successfully cranked up both your database and webserver, so next time will will focus on setting up Symfony. Thanks for reading!
May 16th, 2008 at 1:40 am
After the default install, you will sometimes get a permissions error when running ‘/usr/local/etc/rc.d/mysql-server start‘ (if /var/db/mysql is owned by root). You can fix this by running:
chown -R mysql /var/db/mysql
=)
Great articles! Hope to see sections on setting up SVN and trac with this setup soon.
May 16th, 2008 at 12:25 pm
I thought I got it all set up but when I tried to run mysql.. I realized I do not know what the default password for root is.. Any ideas on this?
May 16th, 2008 at 4:42 pm
There is no password set for ‘root’.
Just type ‘mysql -uroot’ and you’ll get in.
June 9th, 2008 at 2:38 pm
[...] Virtualisation: A Symfony Developer’s Best Friend - Part 4 [...]