Development

InstallingSymfonyInASubDirectoryWithCentOSandPlesk (diff)

You must first sign up to be able to contribute.

Changes from Version 1 of InstallingSymfonyInASubDirectoryWithCentOSandPlesk

Show
Ignore:
Author:
wowca (IP: 89.142.35.22)
Timestamp:
11/27/10 00:12:27 (7 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • InstallingSymfonyInASubDirectoryWithCentOSandPlesk

    v0 v1  
     1Hello everyone! 
     2 
     3The 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! 
     4 
     5I'll start my blog entry with the topic I opened on the Symfony forum (which, sadly, didn't receive any replies). 
     6You can find the original post on the forum. 
     7 
     8So, here it is: 
     9 
     10[quote] 
     11Hello everybody! 
     12 
     13I 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. 
     14 
     15I have root access to a dedicated server running a fresh install of CentOS 5.5 with Parallels Plesk 10 admin panel. 
     16 
     17I set up a sub domain on let's say: http://dev.mydomain.com 
     18 
     19Now my config: 
     20 
     21    * /home/ is empty except for two automatically generated folders 
     22    * 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 
     23    * the vhost.conf file is under the /mydomain.com/conf 
     24 
     25Code inside the vhost.conf file: 
     26 
     27[code] 
     28DocumentRoot /var/www/vhosts/mydomain.com/dev/web 
     29DirectoryIndex index.php 
     30Alias /sf /home/dev/lib/vendor/symfony/data/web/sf 
     31[/code] 
     32[code] 
     33<Directory /var/www/vhosts/mydomain/dev/web> 
     34php_admin_value open_basedir none 
     35AllowOverride All 
     36</Directory> 
     37[/code] 
     38[code] 
     39<Directory /home/dev/lib/vendor/symfony/data/web/sf> 
     40AllowOverride All 
     41Allow from All 
     42</Directory> 
     43[/code] 
     44 
     45So 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] 
     46 
     47Then I go to [b]/var/www/vhosts/mydomain.com/dev/web[/b] and run: 
     48[code] 
     49php /home/dev/lib/vendor/symfony/data/bin/symfony generate:project testproj 
     50 
     51php symfony generate:app frontend 
     52 
     53chmod 777 cache/ log/ 
     54[/code] 
     55I get the whole structure inside the [b]/var/www/vhosts/mydomain.com/dev/web[/b]. 
     56 
     57Then I run the [b]/usr/local/psa/admin/bin/httpdmng --reconfigure-domain dev.mydomain.com [/b] command and restart the httpd server. 
     58 
     59After 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. 
     60 
     61Any ideas what is going on, since I'm getting the Wall McBashing's syndrome.  :D 
     62 
     63Thanks for all the answers! 
     64 
     65P.S.: After solving this problem, I'll create a guide and try to contribute to the community. :) 
     66[/quote] 
     67 
     68And here is the guide! :D 
     69 
     70Since 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". 
     71 
     72   1. Create a subdomain in plesk 
     73   2. Locate the directory of your subdomain (in my case, which I'll be using is: /var/www/vhosts/mydomain.com/dev) 
     74   3. cd to your subdomain (eg. cd /var/www/vhosts/mydomain.com/dev) 
     75   4. Create 2 subdirs using mkdir -p lib/vendor 
     76   5. cd to the subdir (cd lib/vendor) 
     77   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 ) 
     78   7. use tar -zxvf symfony-1.4.8.tgz and then mv symfony-1.4.8 symfony 
     79   8. remove the symfony-1.4.8.tgz file using rm symfony-1.4.8.tgz 
     80   9. cd ../.. 
     81  10. Use the php lib/vendor/symfony/data/bin/symfony generate:project demo 
     82      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) 
     83  11. Use the php symfony generate:app frontend command to generate the frontend app 
     84  12. chmod 777 cache/ log/ 
     85 
     86And here comes vhosts.conf part that I didn't understand and why the whole thing didn't work. :) 
     87 
     88Plesk 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. 
     89 
     90This is the vhosts.conf source that I'm using and it works: 
     91 
     92[code] 
     93DocumentRoot "/var/www/vhosts/mydomain.com/subdomain/web" 
     94DirectoryIndex index.php 
     95ServerName subdomain.mydomain.com 
     96[/code] 
     97[code] 
     98<Directory "/var/www/vhosts/mydomain.com/subdomain/web"> 
     99AllowOverride All 
     100Allow from All 
     101</Directory> 
     102[/code] 
     103[code] 
     104Alias /sf "/var/www/vhosts/mydomain.com/subdomain/lib/vendor/symfony/data/web/sf" 
     105[/code] 
     106[code] 
     107<Directory "/var/www/vhosts/mydomain.com/subdomain/lib/vendor/symfony/data/web/sf"> 
     108AllowOverride All 
     109Allow from All 
     110</Directory> 
     111[/code] 
     112 
     113Now you have to follow these steps: 
     114 
     115   1. cd to /mydomain.com/subdomains/subdomain/conf 
     116   2. vi vhost.conf 
     117   3. Paste the code I provided and change the path so it matches your domain and subdomain 
     118   4. Save and quit ( :wq ) 
     119   5. Run /usr/local/psa/admin/sbin/httpdmng --reconfigure-domain mydomain.com 
     120   6. VOILA! You're ready to embark on a framework dev journey! :) 
     121 
     122Credits go also to ignitedcoding (email: ignitedcoding [at] gmail.com) and the whole #symfony channel on the IRC Freenode server.