http://www.joelverhagen.com/blog/2011/05/how-to-configure-symfony-2-0-on-ubuntu-server-2011-4/
Download and Extract
- Download the framework from the Symfony website. Here's a link, because the only reason you're reading this is because you're lazy. I am working with the Symfony Standard 2.0 BETA1 (.tgz) package.
- Either download the package directly to your /var/www directory or move it there yourself. Cool people use wget.
cd /var/www wget -O symfony.tgz http://symfony.com/download?v=Symfony_Standard_Vendors_2.0.0BETA1.tgz tar xfz symfony.tgzwget -O symfony.tgz http://symfony.com/download?v=Symfony_Standard_Vendors_2.0.17.tgz - You'll now have a directory labelled
Symfonyin your/var/wwwdirectory
- Change the permissions of the
app/cache/directory so that the web server can write into it.sudo chmod -R 777 /var/www/Symfony/app/cache - Change the permissions of the
app/logs/directory so that the web server can write into it.sudo chmod -R 777 /var/www/Symfony/app/logs
app_dev.php: This is a front controller. It is the unique entry point of the application and it responds to all user requests;/demo/hello/Fabien: This is the virtual path to the resource the user wants to access.
將 symfony 解壓縮到網頁根目錄之後,
由於 ubuntu server 是文字介面,
如果想要從遠端連線到主機,以 symfony 提供的網頁介面進行設定
因為 symfony 網頁介面的檔案中,有允許IP清單,會自動比對連線 IP,
預設僅允許本機IP進行網頁介面設定
所以需要將遠端 IP 加入允許清單中
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !in_array(@$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1',
'::1',
'192.168.200.80',//自行加入遠端 IP
))
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}