Graphic tutorial on the configuration method of Symfony2 in Nginx, and symfony2nginx_PHP tutorial

Source: Internet
Author: User
A graphic tutorial on how to configure Symfony2 in Nginx, symfony2nginx. The configuration method of Symfony2 in Nginx is illustrated in a graphic tutorial. This document describes the configuration method of Symfony2 in Nginx. For your reference, we have a graphic tutorial on how to configure Symfony2 in Nginx on the Internet.

This document describes how to configure Symfony2 in Nginx. We will share this with you for your reference. The details are as follows:

There are a lot of articles on symfony2 configuration under nginx on the internet. if it's a little white, it's impossible to configure it according to the configuration file posted on the internet. after many explorations, I wrote my thoughts:

1. first enable Nginx pathinfo

For details about pathinfo, refer to the article "detailed description of PATH_INFO-supported method instances under nginx. Many people report a 500 error when configuring the tutorial. the error log cannot be found. in October, pathinfo is not enabled.

If AMH is installed on your host, congratulations, and configuration is easy. First install the "AMPathinfo" module, and then enable the pathinfo of your website on the list of modules.

If AMH is not installed on your host, you don't have to worry about it. to enable pathinfo, you actually add two lines of configuration code.

fastcgi_split_path_info ^(.+\.php)(.*)$;fastcgi_param PATH_INFO $fastcgi_path_info;

I don't know how to add it? Don't worry, I will tell you below

2. main configuration file

Each nginx site has a master configuration file, which is placed under/alidata/server/nginx/conf/vhosts (your path may be different from mine, run the "nginx-t" command to view the configuration file.

Server {listen 80; server_name www.sample.com; # host domain name. you do not know index index.html index.htm index. php app. php; # The default main file. I added the app myself. php set $ subdomain ''; root/alidata/www/sample/web; # The physical path of the website code disk. Note that the root directory of symfony is web include rewrite/symfony2.conf; # rewrite end # introduce symfony-related configuration location ~ \. Php (/.*)? $ {# Fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1: 9000; fastcgi_index index. php; fastcgi_split_path_info ^ (. + \. php )(. *) $; # key configuration fastcgi_param PATH_INFO $ fastcgi_path_info; # key configuration of pathinfo include fastcgi. conf;} location ~ . * \. (Gif | jpg | jpeg | png | bmp | swf) $ {expires 30d;} location ~ . * \. (Js | css )? $ # Js, css file cache time {expires 1 h;} access_log/alidata/log/nginx/access/sample. log; # Error log }~

3. Symfony-related configuration

I found out this by myself. nginx configuration instructions are also available on the official symfony website. I tried it and failed to understand it. Do you still remember that the previous configuration section contains include rewrite/symfony2.conf? now I will paste this configuration file.

location / {    index app.php;    try_files $uri @rewriteapp;  }location @rewriteapp {    rewrite ^(.*)$ /app.php/$1 last;  }

You can see that there are not a lot of code, but the actual configuration of symfony is like this. Remember to put this configuration file in the rewrite folder

Permanent Address: http://blog.it985.com/8147.html
This article is from the IT985 blog. please indicate the source and relevant links when reprinting.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.