Configuration instructions for Linux under PathInfo (thinkphp)

Source: Internet
Author: User

Small partners in the use of thinkphp to build their own or company projects, the URL mode is set to become compatible mode, that is, the value of Url_model 3 is not also encountered LNMP environment does not support PathInfo mode!

The following thinking about PHP to teach you how to say our various cloud server under the LNMP environment support PathInfo, said here is not some small partners may not quite understand pathinfo mode is what, the following small series first to everyone on a small example:

Www.xxx.com/index.php/Admin/Manager/Login

Such a URL form is PathInfo mode, such a model more conducive to the identification of small spider Baidu, that is, more than SEO.

Here is the key step, the small partners to pay attention to:

Actually, it's pretty much just tearing down the nginx.conf.

1, back up the original nginx.conf file (that is, modify the name), and then use the following nginx.conf file

User www www;

Worker_processes 4;

Error_log/home/wwwlogs/nginx_error.log Crit;

Pid/usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors the can is opened by this process.

Worker_rlimit_nofile 51200;

Events

{

Use Epoll;

Worker_connections 51200;

}

HTTP {

Include/usr/local/nginx/conf/mime.types;

Default_type Text/plain;

Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '

' $status $body _bytes_sent ' $http _referer '

' "$http _user_agent" "$http _x_forwarded_for";

Access_log off;

Sendfile on;

#tcp_nopush on;

#keepalive_timeout 0;

Keepalive_timeout 65;

gzip on;

Client_max_body_size 20m;

# Load config files from the/etc/nginx/conf.d directory

# The default server is in conf.d/default.conf

include/usr/local/nginx/conf/conf.d/*.conf;

include/usr/local/nginx/conf/vhost/*.conf;

}

2, configure PathInfo to create pathinfo.conf under/usr/local/nginx/conf (if it already exists, back up and modify it first)

Fastcgi_split_path_info ^ (? U). +.php) (/?. +)$;

Fastcgi_pass Unix:/tmp/php-cgi.sock;

Fastcgi_param path_info $fastcgi _path_info;

Fastcgi_param path_translated $document _root$fastcgi_path_info;

Fastcgi_param script_name $fastcgi _script_name;

Fastcgi_param script_filename $document _root$fastcgi_script_name;

Fastcgi_param Request_method $request _method;

Fastcgi_param query_string $query _string;

Fastcgi_param Content_Type $content _type;

Fastcgi_param content_length $content _length;

Fastcgi_param Request_uri $request _uri;

Fastcgi_param Document_uri $document _uri;

Fastcgi_param document_root $document _root;

Fastcgi_param server_protocol $server _protocol;

#fastcgi_param HTTPS $https If_not_empty;

Fastcgi_param Gateway_interface cgi/1.1;

Fastcgi_param server_software nginx/$nginx _version;

Fastcgi_param remote_addr $remote _addr;

Fastcgi_param Remote_port $remote _port;

Fastcgi_param server_addr $server _addr;

Fastcgi_param server_port $server _port;

Fastcgi_param server_name $server _name;

Fastcgi_param Redirect_status 200;

5, create a redirect under/usr/local/nginx/conf to create the drect.conf

Index index.php;

Location ~. php$ {

Include pathinfo.conf;

Break

}

AutoIndex on;

3, built in/usr/local/nginx/conf vhost and conf.d two file clips (mkdir vhost)

Create default.conf in CONF.D

server {

Listen 80;# default_server;

server_name _;

CharSet Utf-8;

#access_log Logs/host.access.log Main;

Location/{

root/usr/share/nginx/html;

Index index.html index.htm;

}

Error_page 404/404.html;

Location =/404.html {

root/usr/share/nginx/html;

}

Error_page 502 503 504/50x.html;

Location =/50x.html {

root/usr/share/nginx/html;

}

}

4, create the site configuration information in the Vhost folder (to end With. conf, each time you add a new site you just need to modify here)

server {

Listen default_server;

server_name nahan.cn;

This address should correspond to your access address.

root/home/wwwroot/nahan.cn/;

Index index.php;

if ($host = nahan.cn) {

Rewrite ^/(. *) $ http://www.nahan.cn/$1 permanent;

}

AutoIndex on;

Location/{

Try_files $uri $uri//index.php$uri;

}

Location ~. php {

Include pathinfo.conf;

Break

}

}

5, enter/usr/local/php/etc/php.ini modify Cgi.fix_pathinfo=1

Newly installed LNMP if PHP version is lower, you need to upgrade to 5.4.27

6. After all files have been modified, please restart all services. Command:/ROOT/LNMP Restart the new Restart command is: LNMP restart

Small partners Follow the steps of the above step-by-step configuration, I hope this article can help those who are still struggling with Linux under the configuration of PathInfo's small partners


Configuration instructions for Linux under PathInfo (thinkphp)

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.