Search This Blog

Monday, July 30, 2012

Installing PHP and Zend Framework on Ubuntu

Installing PHP and Zend Framework on Ubuntu

Print PDF
I had a lot of trouble setting up Zend Framework. The installation procedure is very simple, but making the custom controllers and routes work isn't that easy.
Installing a PHP and Apache server on linux is very easy: just find and install the following packages (or open the terminal and run sudo apt-get package_name for each package):
apache2
php5
The directory for websites should be located at /var/www/ and the configuration files for apache in /etc/apache2/ and for php5 in /etc/php5/. To install Zend Framework, install the following package:
zend-framework
Now let's create a Zend project. Open the terminal and run:
zf create project path_to_project project_name
As described on official Zend Framework site, you should create a virtual host for your zend project. This way, you'll access the site at subdomain.localhost. Open /etc/apache2/sites-enabled/000-default (which is a symlink to /etc/apache2/sites-available/default) and add the following lines:
NameVirtualHost *:80

	ServerName subdomain.localhost
	DocumentRoot /path/to/zend_project/public
			
	/path/to/zend_project/public>
                Options Indexes FollowSymLinks MultiViews
		DirectoryIndex index.php
		AllowOverride All
		Order allow,deny
		Allow from all
	
The AllowOverride All option allows URL rewriting, which is required by Zend Framework. You should enable the mod_rewrite apache2 module (by default is disabled). This can be done by:
cd /etc/apache2/mods-enabled
sudo touch rewrite.load
sudo gedit rewrite.load
and add the following line to the opened file:
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
Finally, restart the apache2 server to enable the new settings:
service apache2 restart

No comments:

Post a Comment

Thank you