Development

InstallingSymfonyInASubDirectoryWithCentOSandPlesk

You must first sign up to be able to contribute.

Version 2 (modified by wowca, 7 years ago)
--

Hello everyone!

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

So let's say that I create a folder [b]dev/lib/vendor/b under [b]/home//b and I extract Symfony inside, I have the path to the generator: [b]/home/dev/lib/vendor/symfony/data/bin/b

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

chmod 777 cache/ log/ /code I get the whole structure inside the [b]/var/www/vhosts/mydomain.com/dev/web/b.

Then I run the [b]/usr/local/psa/admin/bin/httpdmng --reconfigure-domain dev.mydomain.com /b command and restart the httpd server.

After I do this this, if I point my browser to http://dev.mydomain.com/ I get the default Apache page and if I point it to http://dev.mydomain.com/web all I get is a blank page.

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".

  1. Create a subdomain in plesk
  2. Locate the directory of your subdomain (in my case, which I'll be using is: /var/www/vhosts/mydomain.com/dev)
  3. cd to your subdomain (eg. cd /var/www/vhosts/mydomain.com/dev)
  4. Create 2 subdirs using mkdir -p lib/vendor
  5. cd to the subdir (cd lib/vendor)
  6. 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 )
  7. use tar -zxvf symfony-1.4.8.tgz and then mv symfony-1.4.8 symfony
  8. remove the symfony-1.4.8.tgz file using rm symfony-1.4.8.tgz
  9. cd ../..
  1. 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)

  1. Use the php symfony generate:app frontend command to generate the frontend app
  2. 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:

  1. cd to /mydomain.com/subdomains/subdomain/conf
  2. vi vhost.conf
  3. Paste the code I provided and change the path so it matches your domain and subdomain
  4. Save and quit ( :wq )
  5. Run /usr/local/psa/admin/sbin/httpdmng --reconfigure-domain mydomain.com
  6. VOILA! You're ready to embark on a framework dev journey! :)