Apache Installation Notes ========================= Apache_ is a popular and well known web server available on many platforms. Configuring Apache for Phalcon ------------------------------ The following are potential configurations you can use to setup Apache with Phalcon. These notes are primarily focused on the configuration of the mod-rewrite module allowing to use friendly urls and the :doc:`router component `. Commonly an application has the following structure: .. code-block:: php test/ app/ controllers/ models/ views/ public/ css/ img/ js/ index.php Directory under the main Document Root ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This being the most common case, the application is installed in any directory under the document root. In this case, we use two .htaccess files, the first one to hide the application code forwarding all requests to the application's document root (public/). .. code-block:: apacheconf # test/.htaccess RewriteEngine on RewriteRule ^$ public/ [L] RewriteRule (.*) public/$1 [L] Now a second .htaccess file is located in the public/ directory, this re-writes all the URIs to the public/index.php file: .. code-block:: apacheconf # test/public/.htaccess RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L] If you do not want to use .htaccess files you can move these configurations to the apache's main configuration file: .. code-block:: apacheconf RewriteEngine on RewriteRule ^$ public/ [L] RewriteRule (.*) public/$1 [L] RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L] Virtual Hosts ^^^^^^^^^^^^^ And this second configuration allows you to install a Phalcon application in a virtual host: .. code-block:: apacheconf ServerAdmin admin@example.host DocumentRoot "/var/vhosts/test/public" DirectoryIndex index.php ServerName example.host ServerAlias www.example.host Options All AllowOverride All Allow from all .. _Apache: http://httpd.apache.org/