How to write secure Yii1 applications

Comparing #16 with #17

Revision #17 was created by François Gannaz François Gannaz on Oct 30, 2013, 9:18:08 AM.

Add comments to the Apache VH snippet

Content

[...]
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 pathes 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
 
<DirectoryMatch "/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 </DirectoryMatch>
</VirtualHost>
~~~

### For every PHP project
[...]