The evergrowing community of the Symfony framework was a great help to me when starting with Symfony, so I decided to give something back, with this step-by-step introductory tutorial about installing Symfony 1.4 on a subdomain with CentOS 5.5 and Plesk 10 on a dedicated server. I assume you have the server configured to run Symfony. Whatever you do, you do it on your own, so I'm not the one to blame if anything goes wrong!
I'll start my blog entry with the topic I opened on the Symfony forum (which, sadly, didn't receive any replies). You can find the original post on the forum.
So, here it is:
[quote] Hello everybody!
I finally decided to start working with a framework and after some thinking I decided to go with Symfony, but I'm having a hard time setting it up.
I have root access to a dedicated server running a fresh install of CentOS 5.5 with Parallels Plesk 10 admin panel.
I set up a sub domain on let's say: http://dev.mydomain.com
Now my config:
- /home/ is empty except for two automatically generated folders
- the path to home directory is /var/www/vhosts/mydomain.com with subdomain under /dev so the full path to the subdomain is: /var/www/vhosts/mydomain.com/dev
- the vhost.conf file is under the /mydomain.com/conf
Code inside the vhost.conf file:
[code] DocumentRoot /var/www/vhosts/mydomain.com/dev/web DirectoryIndex? index.php Alias /sf /home/dev/lib/vendor/symfony/data/web/sf /code [code] <Directory /var/www/vhosts/mydomain/dev/web> php_admin_value open_basedir none AllowOverride? All </Directory> /code [code] <Directory /home/dev/lib/vendor/symfony/data/web/sf> AllowOverride? All Allow from All </Directory> /code
Then I go to [b]/var/www/vhosts/mydomain.com/dev/web/b and run: [code] php /home/dev/lib/vendor/symfony/data/bin/symfony generate:project testproj
php symfony generate:app frontend
Then I run the [b]/usr/local/psa/admin/bin/httpdmng --reconfigure-domain dev.mydomain.com /b command and restart the httpd server.
Any ideas what is going on, since I'm getting the Wall McBashing?'s syndrome. :D
Thanks for all the answers!
P.S.: After solving this problem, I'll create a guide and try to contribute to the community. :) /quote
And here is the guide! :D
Since you're running a dedicated server I assume you have root access, so everything I'll be doing here is while being logged in as "root".
- Create a subdomain in plesk
- Locate the directory of your subdomain (in my case, which I'll be using is: /var/www/vhosts/mydomain.com/dev)
- cd to your subdomain (eg. cd /var/www/vhosts/mydomain.com/dev)
- Create 2 subdirs using mkdir -p lib/vendor
- cd to the subdir (cd lib/vendor)
- use wget to get the latest Symfony version from the Symfony homepage (eg. wget http://www.symfony-project.org/get/symfony-1.4.8.tgz )
- use tar -zxvf symfony-1.4.8.tgz and then mv symfony-1.4.8 symfony
- remove the symfony-1.4.8.tgz file using rm symfony-1.4.8.tgz
- cd ../..
- Use the php lib/vendor/symfony/data/bin/symfony generate:project demo
command to generate a new Symfony project (demo is not an actual command, it's just the name of the project so use the name of your project)
- Use the php symfony generate:app frontend command to generate the frontend app
- chmod 777 cache/ log/
And here comes vhosts.conf part that I didn't understand and why the whole thing didn't work. :)
Plesk actually generates TWO conf/ directories, one in /var/www/vhosts/mydomain.com/conf and one in /var/www/vhosts/mydomain.com/subdomains/yoursubdomain/conf . When creating and publishing a web page you use the /mydomain.com/yoursubdomain directory, but Plesk uses the /mydomain.com/yoursubdomain/conf directory for all the vhosts configuration, so you have to put the vhosts.conf under that directory.
This is the vhosts.conf source that I'm using and it works:
[code] DocumentRoot "/var/www/vhosts/mydomain.com/subdomain/web" DirectoryIndex? index.php ServerName? subdomain.mydomain.com /code [code] <Directory "/var/www/vhosts/mydomain.com/subdomain/web"> AllowOverride? All Allow from All </Directory> /code [code] Alias /sf "/var/www/vhosts/mydomain.com/subdomain/lib/vendor/symfony/data/web/sf" /code [code] <Directory "/var/www/vhosts/mydomain.com/subdomain/lib/vendor/symfony/data/web/sf"> AllowOverride? All Allow from All </Directory> /code
Now you have to follow these steps:
- cd to /mydomain.com/subdomains/subdomain/conf
- vi vhost.conf
- Paste the code I provided and change the path so it matches your domain and subdomain
- Save and quit ( :wq )
- Run /usr/local/psa/admin/sbin/httpdmng --reconfigure-domain mydomain.com
- VOILA! You're ready to embark on a framework dev journey! :)