內容目录上一个主题< WAMP 下安装(Installation on WAMP) 下一个主题Nginx 安装说明(Nginx Installation Notes) > 本页 |
Apache 安装说明(Apache Installation Notes)¶Apache is a popular and well known web server available on many platforms. Apache 下配置 Phalcon(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 router component. Commonly an application has the following structure: 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/). # test/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
Now a second .htaccess file is located in the public/ directory, this re-writes all the URIs to the public/index.php file: # test/public/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</IfModule>
If you do not want to use .htaccess files you can move these configurations to the apache’s main configuration file: <IfModule mod_rewrite.c>
<Directory "/var/www/test">
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</Directory>
<Directory "/var/www/test/public">
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</Directory>
</IfModule>
虚拟主机(Virtual Hosts)¶And this second configuration allows you to install a Phalcon application in a virtual host: <VirtualHost *:80>
ServerAdmin admin@example.host
DocumentRoot "/var/vhosts/test/public"
DirectoryIndex index.php
ServerName example.host
ServerAlias www.example.host
<Directory "/var/vhosts/test/public">
Options All
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
|