Symfony2 what to do when deploying manually? - symfony

Since i can't find any useful information on Symfony2 website i'm asking here. What should be done when manually deploying a Symfony2 project? As far i understand:
Edit app/config/paramenters.ini to meet server paramenters
Update vendors to the latest version: php bin/vendors update
Install database with php app/console doctrine:database:create then tables with php app/console doctrine:schema:update --force and eventually load fixtures: php app/console doctrine:fixtures:load
Dump and install assets/assetics: php app/console assets:install --symlink web as long as php app/console assetic:dump --env=prod --no-debug
Symlink index.php to web/app.php, assuming that all files from Symfony2 distribution are in the root of the web server
Remove web/app_dev.php (is this really necessary?)
should app/config/paramenters.ini left untouched? What about security concerns?
Am i right? Thanks for helping. I think that Symfony2 documentation should cover this too.
EDIT: virtual host example:
<VirtualHost *:80>
ServerName symfony.local
DocumentRoot "C:/www/Symfony2/web"
DirectoryIndex app.php
<Directory "C:/www/Symfony2/web">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>

Only two things I wouldn't do is:
Symlink index.php to web/app.php, assuming that all files from
Symfony2 distribution are in the root of the web server
Remove web/app_dev.php (is this really necessary?)
The thing with the symlink might be ok, but I prefer to link the webroot directory with the web directory of symfony2.
Second thing is, you don't have to remove app_dev.php, because it can only be run from localhost (it checks the IP). So no need to remove it, and I personally sometimes want to see debug info on the webpage (maybe not best way), and than I just add my own IP to app_dev (and remove it afterwards).

Yes. That is all. And also you don't need web/app_dev.php in prod environment.
Moreover, web folder should be document root and run app.php

I think you should put DirectoryIndex app.php inside <Directory></Directory>

Related

Symfony Missing sf folder

This question is not really related to programming, but I dont know where else I should ask it.
I just installed Symfony on Xampp for windows, now I struggle getting it to work because it is missing the project/web/sf folder and I can't find anything about it on the internet.
The missing of this folder causes me to lose the css files and images ect.
I installed Symfony via Pear and then just got a clean project using symfony generate:project projectname
[edit]: this is how my homepage looks after loading;
[edit 2]: Printscreen of version number seen on web/app_dev.php (which is one of the few pages working correctly)
It looks like from your "3 methods of installing" you have mixed multiple versions of Symfony into one installation. The symfony_data/web/sf problem is unique to Symfony 1.x only. Symfony2 does not use the web/sf structure, and instead utilizes web/bundles/framework for framework assets.
This makes sense since the PEAR channel isn't supported for Symfony anymore (see the big red header?) Plus, you can only get Symfony 2.x by explicitly using pear install symfony2 (not pear install symfony). You may be using the old PEAR channel located here (see how they're all 1.x versions?) and symfony-project.com redirects to symfony.com/legacy
So now when you access app.php you get Symfony 1.x, and when you access app_dev.php you get the newest version of Symfony ~2.5. This makes things very confusing for both you and us.
What's the fix?
Start over. Remove the project folder and its contents entirely. Then follow these installation instructions (I've condensed them for you):
Start in your desired project folder.
curl -s https://getcomposer.org/installer | php
php composer.phar create-project symfony/framework-standard-edition ./ '2.5.*'
php composer.phar install
You must make an alias on your web server apache, like this example:
# Be sure to only have this line once in your configuration
NameVirtualHost 127.0.0.1:8080
# This is the configuration for your project
Listen 127.0.0.1:8080
<VirtualHost 127.0.0.1:8080>
DocumentRoot "/home/sfprojects/jobeet/web"
DirectoryIndex index.php
<Directory "/home/sfprojects/jobeet/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /home/sfprojects/jobeet/lib/vendor/symfony/data/web/sf
<Directory "/home/sfprojects/jobeet/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>

symfony2 assets in changed web folder

I'm using Symfony2 in my project and I changed web root ditectory. I followed instructions on this page http://symfony.com/doc/current/cookbook/configuration/override_dir_structure.html. Now my project structure looks like this:
/frontend - the new web root dir
/myproject - the project dir
Then i'm installed and dumped assets
php app/console assets:dump
php app/console assetic:install ../frontend --symlink
Most things works fine. But the problem is that I can't acces to any asset in /bundles directory, Symfony returns error
No route found for "GET /bundles/..."
But I can see my assets in this directory in explorer (symlinks created correctly).
Is your web server configured to follow symlinks? Without knowing which web server you are using, as an example in apache you need to set the FollowSymLinks option. Alternatively, remove the symlink option when doing assets:install.
Also, it's probably just a typo, but you've got the commands for installing assets and dumping assetic a bit muddled in your question - should be something like this:
php app/console assets:install --symlink ../frontend
php app/console assetic:dump -e dev

Symfony 2.x shows broken layout with clean install

I've just installed a Symfony Standard Application from scratch, and the layout is broken:
I've already did a bunch of stuff, such as clearing cache, changing directory permissions and etc, and nothing seems to work.
Does anyone have any idea?
I'm referencing Daniel's other question yesterday.
The cause for the problem was a misconfiguration of his nginx webserver. The stylesheets were served by nginx but did not include the correct mime-type for css files and were therefore ignored by the browser.
The solution:
nginx
You need to make sure your nginx.conf actually includes the correct mime-types.
http {
include conf/mime.types;
# ...
}
... or ...
types {
# ...
text/css css;
}
Apache:
Make sure you have included this in your httpd.conf and enabled mod_mime.
AddType text/css .css
It seems that the css files are missing.
Run php app/console assets:install and look at the output if some errors occurs.
Always use following commands:
php app/console assetic:dump
This dumps all your assets
Then you use
php app/console assets:install
Or even a faster option
php app/console assets:install --symlink

symfony2 blank page on web hosting server

I try to deploy my project on my distant web server. I think the sf2 installation is ok I have the app_dev.php and the config.php pages, the check.php doesn't return me any error and I set up the acl on the directories app/cache and app/logs.
but I cant have any of my pages from my controllers. If I try something like .../Symfony/web/app_dev.php/myurl I have a blank page.
What can I do? thanks in advance
Most likely there's a php error, you should check your web server/php error log files. The exact location of those depends on configuration, ask your hosting provider if you can't find them yourself.
As a wild guess, check the permission on the app/cache folder - this is a common problem I believe. You should always run app/console cache:clear --no-debug --env=prod with the webserver user.
You may also check whether mod_rewrite is enabled in your server.
I am not sure if you have checked the obvious but app_dev contains the following:
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !in_array(#$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1',
'::1',
))
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
Make sure to add your IP, remove the IP block altogether or come up with a login solution.
I resolved the blank pages simply executing this command on the project root:
app/console assets:install web
i opened my Linux terminal and execute :
php app/check.php
it showed me ERROR:
date.timezone setting must be set
Set the "date.timezone" setting in php.ini*
i set server timezone and restart my server, my blank page gone, and symfony 2.7.3 version start working

How to place certain files in the root directory of the Grails server?

I am using a grails application as backend for a Flex frontend. To be able to easily develop and debug my applications I would need to place a crossdomain.xml file into the root of the server, i.e. it must be accessible via http://localhost:8080/crossdomain.xml. Similar use cases might be the deployment of a favicon.ico or a robots.txt, however this can be done in the production environment through a tomcat server with a default root web application.
In my case however I need to have the crossdomain.xml available after running grails run-app. I know that I can move the entire application to the root (http://ca.rroll.net/2009/03/27/configuring-the-grails-root-application-context/) however this is also not what I want, since the grails application should still reside below its default application context.
Does somebody know, how I can do this? Will I have to reconfigure the jetty servlet container of my grails installation somehow?
I think I found the answer. I haven't tried this yet, so YMMV.
In this article, Colin Harrington discusses making a crossdomain.xml file available at the root of the server by deploying an additional Jetty context.
His technique was first proposed in this blog entry, where the author also discusses using the Static Resources Plugin as another alternative
I figured out a way to solve this with Apache and mod_proxy. This allows both your Grails install and Grails project to remain pristine. No hacking at the Grails internals, no adding plug-ins you may not need in production.
1. Install Apache httpd 2.2
Do this however makes the most sense for your operating system. It is important that you install Apache 2.2. I did this on an Ubuntu system, so any specific commands and file locations will be for Ubuntu. Modify as necessary for your system.
After you've installed Apache, start httpd.
sudo /sbin/service httpd start
Test that it is installed correctly using a web browser.
2. Create a root directory
Pick a location on your disk where you will keep your static files. This will be the document root for httpd. I will be using /var/grails_root.
mkdir /var/grails_root
touch /var/grails_root/crossdomain.xml
3. Create a VirtualHost in httpd.conf
Open httpd.conf in your favorite text editor.
vim /etc/httpd/conf/httpd.conf
Pick your favorite port, and create a virtual host on that port. I will be using 9090, but any port will do.
Add these lines to httpd.conf
Listen 9090
<VirtualHost *:9090>
DocumentRoot "/var/grails_root"
<Directory "/var/grails_root">
Allow from all
</Directory>
</VirtualHost>
Restart httpd
sudo /sbin/service httpd restart
Test that you are now able to access the static files in your document root directory. If not, you will need to fix this before moving on to the next step.
4. Enable mod_proxy and mod_proxy_http
You need to load both of these modules. mod_proxy has the base functionality for proxying, and the mod_proxy_xxx modules have information specific to a protocol. They ship standard with httpd 2.2, so you shouldn't need to install anything extra.
Add these lines to httpd.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Now modify the virtual host you set up in the previous step. (You can omit the comments)
<VirtualHost *:9090>
DocumentRoot "/var/grails_root"
<Directory "/var/grails_root">
Allow from all
</Directory>
# New lines start here
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /grailsApp http://your.grails.server:8080/grailsApp
# New lines end here
</VirtualHost>
Restart httpd
sudo /sbin/service httpd restart
Now, you should be able to access both your static files and your Grails app via port 9090.
This is all based on information found here: http://docs.codehaus.org/display/JETTY/Configuring+mod_proxy
Information for doing this with other versions of Apache is available on the same site.

Resources