In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to configure Symfony2 under Nginx, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.
1. First, open the pathinfo of Nginx
As for what is pathinfo, you can refer to the article "detailed explanation of the methods that support PATH_INFO under nginx". When configuring according to the tutorials, many people will report 500 errors and cannot find them in the error log. It is probably that pathinfo is not turned on.
If you have AMH installed on your host, congratulations, it will be easy to configure. First install the "AMPathinfo" module, and then on the list of this module, open the pathinfo of your website
If you don't have AMH installed on your host, and don't worry, turning on pathinfo is actually adding two lines of configuration code.
Fastcgi_split_path_info ^ (. +\ .php) (. *) $; fastcgi_param PATH_INFO $fastcgi_path_info
Don't you know how to add it? Don't worry. I'll tell you next.
two。 Master configuration file
Under every nginx site, there is a main configuration file, and they are all placed under / alidata/server/nginx/conf/vhosts (your path may be different from mine, enter the command "nginx-t" to see it), and now expose the main configuration file.
Server {listen 80; server_name www.sample.com; # host domain name, not to mention that I don't know the default master file of index index.html index.htm index.php app.php; #, I added app.php set $subdomain'; the disk physical path of root / alidata/www/sample/web; # website code. 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 fastcgi_index index.php; fastcgi_split_path_info 9000; fastcgi_index index.php; fastcgi_split_path_info ^ (. +\ .php) (. *) $; # pathinfo key configuration fastcgi_param PATH_INFO $fastcgi_path_info Key configuration of # pathinfo include fastcgi.conf;} location ~. *\. (gif | jpg | jpeg | png | swf) ${expires 30d;} location ~. *\. (js | css)? file cache time of $# js,css {expires 1h;} access_log / alidata/log/nginx/access/sample.log; # error log} ~
3. Configuration related to Symfony
I fumbled out this by myself, and there are also configuration instructions for nginx on the symfony official website. I tried, but I didn't understand it and didn't succeed. Do you remember that there was a sentence in the previous configuration that was include rewrite/symfony2.conf? now let's post this configuration file.
Location / {index app.php; try_files $uri @ rewriteapp;} location @ rewriteapp {rewrite ^ (. *) $/ app.php/$1 last;}
That's what's really about the configuration of symfony. Remember to put this configuration file under the rewrite folder
Thank you for reading this article carefully. I hope the article "how to configure Symfony2 under Nginx" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.