I got my main development tools setup on Ubuntu this weekend. My workstation has 64 bit Ubuntu installed and I did not want to have to install the 32 bit libraries (used by XAMPP). So I opted for installing all the components from the ubuntu repositories.
Ubuntu makes it super easy to install ALL the required components using 1 single command! You no longer have to go into Synaptic and check all the required software!
Open up a terminal and type
Select LAMP from the options presented and follow the prompts. Seriously.. It could not get any easier!
Ok.. so now, you have Apache2, PHP and Mysql server setup. The default web directory is /var/www.
You should now be able to navigate to http://localhost on your browser and see the “It Works!” default page. Now, if you try to add any of your own scripts/pages to this folder, you will get a “insufficient privileges” error. This is because the var/www by default belongs to user ‘root’ and group ‘root’.
I have noticed so many websites/blogs suggesting granting super cow rights to ALL to this directory to get around this.. I strongly recommend against doing that. Instead, I suggest creating a group named ‘web’ with rwx permissions to /var/www. Then, if you want other users to be able to author pages, add them as members of the ‘web’ group.
- Click on ‘System’->’Users’->’Manage Groups’->’Add’
Go ahead and enter the new group name ‘web’ and make yourself a member like so:
2. Next, setup ‘web’ as the group for /var/www
sudo chgrp -R web /var/www
sudo chmod -R g+rwx /var/www
The first command changes the group ownership from ‘root’ to ‘web’
The second command adds read, write and execute permissions to the group (web)
(the -R signifies recursive flag.. so files and subfolders inside /var/www will inherit these settings as well)
At this point, this is what “ls -l /var” should look like:
3. log out and log back on (Group membership is only processed on login) . You should now be able to save to the /var/www folder. Also, if you need any other shared user to have web permissions, simply add them to this group ‘web’.
Go ahead and create a “phpinfo” page in /var/www:
Point your browser to http://localhost/phpinfo.php and confirm that php is successfully installed.
The next task is to install the Zend Framework. Download the most recent version from the Zend Framework website and extract it to the /opt folder. To enable us to easily switch out different versions, we will create a symbolic link to this folder (just right click and select the ‘Make link’ option.. name it ‘Zend’)
Next, we will tell php to include the zend framework in the include_path.
sudo gedit /etc/php5/apache2/php.ini
Add/Change the include_path in to :
include_path = “.:/opt/Zend/library”
Note that I used the symbolic link in the include path.. This way, when there is a new version of ZF, we can just switch out the symlink without having to edit the ini file!
In order to use the zend framework command line tool (/opt/Zend/bin/zf.sh), we need to install the php command line interface (php5-cli).
sudo apt-get install php5-cli
Note that the CLI uses a different version of the php.ini file (NOT the one in the apache2 folder but in the cli folder!). We need to tell CLI also where the zend framework directory is located.
sudo gedit /etc/php5/cli/php.ini
include_path = “.:/opt/Zend/library”
The final step is to include the path to /opt/Zend/bin in the unix PATH variable (this way, you can use zf.sh instead of /opt/Zend/bin/zf.sh). Edit file named ~/.bashrc (an easy way to get to this is to click on ‘view’->’show hidden files’ in nautilus in your home directory). Add the following line at the end:
The Zend Framework relies on the apache “rewrite” module. So, go ahead and enable the “rewrite” module using the following command:
sudo a2enmod rewrite
Restart apache.. and you should be all set 🙂
Netbeans 6.9 beta includes a plugin to create Zend Framework projects (using the zf.sh tool).. I have it installed, and it works great!