日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

用Nginx如何配置运行无扩展名PHP文件或非.PHP扩展名文件

發(fā)布時(shí)間:2025/7/25 49 豆豆
生活随笔 收集整理的這篇文章主要介紹了 用Nginx如何配置运行无扩展名PHP文件或非.PHP扩展名文件 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

用Nginx如何配置運(yùn)行無(wú)擴(kuò)展名PHP文件或非.PHP擴(kuò)展名文件

使用Apache + PHP 很容易做到運(yùn)行無(wú)擴(kuò)展名的PHP文件。
在Nginx中能做到嗎?是可以的。
只需將nginx.conf文件中的默認(rèn)

location ~ .php$ {
…..
}

上的正則表達(dá)式 更改為:

location ~ (|.php)$ {

}

就可以了。

同理,可以運(yùn)行非.php擴(kuò)展名的PHP文件,如 abc.html, abc.asp, abc.net, abc.jsp 等擴(kuò)展名的PHP文件。

?

上在代碼在php-5.2.17與nginx-0.8.54下通過(guò)。


nginx.conf文件信息

?

user ?nobody;

worker_processes ?1;


error_log ?logs/error.log;

#error_log ?logs/error.log ?notice;

#error_log ?logs/error.log ?info;


pid ? ? ? ?logs/nginx.pid;



events {

? ? worker_connections ?1024;

}



http {

? ? include ? ? ? mime.types;

? ? default_type ?application/octet-stream;


? ? #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 ?logs/access.log ?main;


? ? server_names_hash_bucket_size 64;


? ? sendfile on;

? ? tcp_nopush ? ? on;

? ? keepalive_timeout 60;

? ? tcp_nodelay on;

? ? fastcgi_connect_timeout 120;

? ? fastcgi_send_timeout 120;

? ? fastcgi_read_timeout 120;

? ? fastcgi_buffer_size 64k;

? ? fastcgi_buffers 4 64k;

? ? fastcgi_busy_buffers_size 128k;

? ? fastcgi_temp_file_write_size 128k;


? ? gzip ?on;

? ? gzip_min_length ?1k;

? ? gzip_buffers ? ? 4 8k;

? ? gzip_http_version 1.1;

? ? gzip_comp_level 2;

? ? gzip_types ? ? ? text/plain application/x-javascript text/css application/xml;

? ? gzip_vary on;

? ??

? ? autoindex on;


? ? server {

? ? ? ? listen ? ? ? 8000;

? ? ? ? server_name ?218.25.100.62;

? ? ? ? charset utf-8;

? ? ? ? location / {

? ? ? ? ? ? root ? /opt/lzw/webapps;

? ? ? ? ? ? index ?index.php index.html index.htm;

? ? ? ? }

? ? ? ? error_page ? 500 502 503 504 ?/50x.html;

? ? ? ? location = /50x.html {

? ? ? ? ? ? root ? html;

? ? ? ? }

? ? ? ? location ~ (|.php)$ {

? ? ? ? ? ? root ? ? ? ? ? /opt/lzw/webapps;

? ? ? ? ? ? fastcgi_pass ? 127.0.0.1:9000;

? ? ? ? ? ? fastcgi_index ?index.php;

? ? ? ? ? ? fastcgi_param ?SCRIPT_FILENAME ?/scripts$fastcgi_script_name;

? ? ? ? ? ? include ? ? ? ?fastcgi_params;

? ? ? ? }

? ? }

}

轉(zhuǎn)載于:https://www.cnblogs.com/lechie/archive/2012/04/05/2432710.html

總結(jié)

以上是生活随笔為你收集整理的用Nginx如何配置运行无扩展名PHP文件或非.PHP扩展名文件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。