Symfony2 Configuration method under Nginx tutorial, symfony2nginx_php Tutorial

Source: Internet
Author: User
Tags php framework codeigniter

Symfony2 under the Nginx configuration method graphic Tutorial, Symfony2nginx


In this paper, the configuration method of Symfony2 under Nginx is described in detail. Share to everyone for your reference, as follows:

Online has a lot of symfony2 under the Nginx configuration article, if it is small white, according to the configuration files posted online configuration, but how also unsuccessful, I have been groping, write down the experience:

1. First open the Nginx pathinfo

As for what is pathinfo, you can refer to the article "Nginx support Path_info method Examples of detailed", self-brain repair. Many people follow the tutorial configuration, will report 500 errors, check the error log can not find out, probably is not open pathinfo.

If you have AMH installed on your console, then congratulations, the configuration is easy. Install the "Ampathinfo" module first, then on the list of this module, open the PathInfo of your website

If you do not have AMH installed on the host, do not worry, open pathinfo, is actually added two lines of configuration code

Fastcgi_split_path_info ^ (. +\.php) (. *) $;fastcgi_param path_info $fastcgi _path_info;

Don't know how to add it? Don't worry, I'll tell you next.

2. master configuration file

Under each Nginx site, there is a master profile, they are placed under the/alidata/server/nginx/conf/vhosts (your path may not be the same as mine, the input command "NGINX-T" can be viewed), now drying out the main configuration file

server {    listen    ;    server_name www.sample.com; #主机域名, do not say do not know the    index index.html index.htm index.php app.php, #默认的主文件, I added app.php    set $subdomain ";    Root/alidata/www/sample/web; #网站代码的磁盘物理路径, note that the root directory of Symfony is web    include rewrite/symfony2.conf; #rewrite End # This is the introduction of 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) (. *) $; #pathinfo的关键配置        fastcgi_param path_info $fastcgi _path_info; #pathinfo的关键配置        include fastcgi.conf;    }    Location ~. *\. (gif|jpg|jpeg|png|bmp|swf) $    {        expires 30d;    }    Location ~. *\. (JS|CSS) $ #js, CSS file cache time    {        expires 1h;    }    Access_log/alidata/log/nginx/access/sample.log; #报错日志}~

3. Symfony-related configuration

This is my own groping out, Symfony official online also has nginx configuration instructions, I tried, did not understand, also did not succeed. Remember the last section of the configuration is an include rewrite/symfony2.conf, now to paste out this configuration file

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

You see the code is not a lot of it, really about symfony configuration is these. Remember to put this configuration file under the Rewrite folder

Permanent address of this article: http://blog.it985.com/8147.html
This article is from IT985 blog, please indicate the source and corresponding link when reproduced.

Read more about PHP framework related content Readers can view this site: "PHP Excellent Development Framework Summary", "CodeIgniter Introductory Tutorial", "CI (codeigniter) Framework Advanced Tutorial", "Yii framework Introduction and common skills Summary" and " thinkphp Getting Started Tutorial "

It is hoped that this article is helpful to the PHP program design based on Symfony framework.

Articles you may be interested in:

    • Symfony2 implementing the method of data built into the doctrine
    • Symfony2 installing a third-party bundles instance
    • Symfony2 use third-party library upload to make picture upload instance detailed
    • Symfony2 Installation Method (2 methods)
    • Symfony2 Session Usage Example analysis
    • High performance PHP Framework Symfony2 Classic Introductory Tutorial
    • Symfony Learning 10-minute Introductory classic tutorial
    • An example analysis of Symfony data verification method
    • Symfony form and page implementation tips
    • An example analysis of controller usage of SYMFONY2 development

http://www.bkjia.com/PHPjc/1098964.html www.bkjia.com true http://www.bkjia.com/PHPjc/1098964.html techarticle Symfony2 Under the Nginx configuration method and graphic tutorial, Symfony2nginx This article details the Symfony2 under the Nginx configuration method. Share to everyone for your reference, as follows: Online has very ...

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