In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to realize Nginx pan parsing to the subdirectory automatically determine whether there is a public directory, the article is very detailed, has a certain reference value, interested friends must read it!
preface
When we configure the local PHP development environment, unless it is under Windows, otherwise I prefer Nginx + PHP-FPM, even if Mac already has its own Apache+PHP environment. On the one hand, because the PHP version that comes with Mac is not new enough (5.6.x), on the other hand, Nginx + PHP-FPM is closer to my production server environment, and it is also convenient to use Homebrew to manage versions and extensions.
Laravel is developed on Mac, and the official valet is provided, which can easily map subdirectories to virtual hosts, but when I use it, I encounter some problems:
Real error messages are difficult to track, always reporting index.php errors for valet or index.php errors for laravel;
Symfony framework config.php/app_debug.php etc. cannot be accessed directly.
So I kept dnsmasq only to manage domain names with specific suffixes (for automatic resolution), and then abandoned valet and made my own configuration of pan-resolution binding to local subdirectories.
The specific configuration is as follows (domain name is *.app):
server { listen 80; server_name ~^(?.+). app$; set $root /Users/kairee/Sites/$subdomain; if ( -d "/Users/kairee/Sites/$subdomain/public") { set $root /Users/kairee/Sites/$subdomain/public; } root $root; charset utf-8; client_max_body_size 128M; index index.php; location / { try_files $uri $uri/ /index.php$is_args$args; } access_log off; location ~ \.php\?? { fastcgi_split_path_info ^(.+\. php)(/.+)$; fastcgi_pass unix:/tmp/php.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } location ~ /\.ht { deny all; }}
With this configuration:
domain.app requested URL/sites/domain/public/was not found on this server.
If ~/Sites/domain exists but ~/Sites/domain/public does not exist, the root directory of the domain.app domain will point to ~/Sites/domain;
The php files that actually exist in the root directory of the website can be accessed directly, and only the files that do not exist will be processed through the entry file (index.php);
If you need to support other frameworks, you can add an if statement to the configuration file. For example, if you want to support symfony, copy the if judgment block and change public to web.
The above is "how to achieve Nginx pan parse to the subdirectory automatically determine whether there is a public directory" all the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!
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.