Revision #17 has been created by François Gannaz on Oct 30, 2013, 9:18:08 AM with the memo:
Add comments to the Apache VH snippet
« previous (#16) next (#18) »
Changes
Title
unchanged
How to write secure Yii applications
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
security, authorization, authentication, XSS, SQL injection
Content
changed
[...]
php_admin_flag engine off
Options -Indexes
</Directory>
~~~
Instead of the previous configuration, here is an example of putting a Yii application in a Virtual Host. Each securing directive has an explaining comment.
~~~
[apache]
# Example config for Yii-myapp as an Apache VirtualHost
# Please set the path
es
and the host name to their right values
<VirtualHost *:80>[...]
<Directory "/home/myapp/www">
AllowOverride NoneOptions +FollowSymLinks
# These 2 lines are useless with modern PHP
php_flag register_globals Off
php_flag gpc_magic_quotes Off
#
# <IfModule mod_rewrite.c>
# # The following block is for masking "index.php" in the url
# #
We also need toTo enable it, configure the app: urlManager.showScriptName = false
# Options +FollowSymLinks
# IndexIgnore */*
# RewriteEngine on
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule . index.php
# </IfModule>
</Directory>
# Forbid direct access to this directory
<Directory "/home/myapp/www/protected">
Deny from All
</Directory>
# protect several non-PHP directories
<Directory
Match "/home/myapp/www/
(assets
">
php_admin_flag engine off|css|images|js)$">
# Forbid execution of PHP scripts
php_admin_flag engine off
# Forbid listing of files
Options -Indexes
</Directory
Match>
</VirtualHost>
~~~
### For every PHP project[...]