大家好,欢迎来到IT知识分享网。
在Nginx的虚拟主机配置文件中(vhost.conf)新增一个server节点,一个server节点代表一个虚拟主机。
配置参考如下:
server {
listen 80;
server_name domain.com;
location / {
root /www/wwwroot/public;
index index.html index.htm index.php;
#显示文件列表(索引)
autoindex on;
#默认为on,显示出文件的确切大小,单位是bytes
#改为off后,显示出文件的大概大小,单位是kB或者MB或者GB
autoindex_exact_size on;
#默认为off,显示的文件时间为GMT时间。
#改为on后,显示的文件时间为文件的服务器时间
autoindex_localtime on;
#URL重写配置
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php/$1 last;
}
}
#location ~ \.php$ {
location ~ \.php { #pathinfo配置,去掉后面的$
root /www/wwwroot/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#pathinfo配置,高版本nginx的配置方法
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
#pathinfo配置,低版本nginx的配置方法
#fastcgi_split_path_info ^(.+\.php)(.*)$;
#fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/182151.html