The custom Nginx configuration fails. Why?

Source: Internet
Author: User
In the past, my configuration in apache was as follows: {code...}: if the file to which the URL points does not exist in the server directory, all the URLs will be directed to index. php. The structure is described in the Custom Nginx configuration in the document. Nginx I do not use a configuration Conversion Tool to get the configuration in Ngin... the original configuration in apache is as follows:

RewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^ index.php [QSA,L]

Purpose: if the file to which the URL points does not exist in the server directory, all URLs are directed to index. php.

The structure is described in the Custom Nginx configuration in this document. I do not use a configuration Conversion Tool to get the configuration in Nginx:

# nginx configurationlocation / {    if (!-e $request_filename){        rewrite ^(.*)$ /index.php break;    }}

But in the cloud view's PHP Spaceconf/nginx_server.incAfter the file is in, the space cannot be opened. I want to ask why!

Reply content:

The configuration in apache is as follows:

RewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^ index.php [QSA,L]

Purpose: if the file to which the URL points does not exist in the server directory, all URLs are directed to index. php.

The structure is described in the Custom Nginx configuration in this document. I do not use a configuration Conversion Tool to get the configuration in Nginx:

# nginx configurationlocation / {    if (!-e $request_filename){        rewrite ^(.*)$ /index.php break;    }}

But in the cloud view's PHP Spaceconf/nginx_server.incAfter the file is in, the space cannot be opened. I want to ask why!

This problem is solved. Finally, I found the solution in readme OF THE slimphp project, as follows:

location / {    try_files $uri $uri/ /index.php?$args;    root /opt/src/app;}

Some settings are also made for PHP:

location ~ \.php$ {    root /opt/src/app;    fastcgi_pass 127.0.0.1:8080;    fastcgi_index index.php;    fastcgi_param SCRIPT_FILENAME /opt/src/app/$fastcgi_script_name;    include /opt/apps/nginx/conf/fastcgi_params;}

Http://cloudscape.sohu.com/doc/operation/app-conf.shtml
Refer to section 6 "Custom Nginx configuration" in the document.

The nginx custom configuration may conflict with the overall configuration of your project. You can log on to the container to view the configuration and modify the configuration.

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.