您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
webman-靜態文件-更改靜態文件目錄
发布时间:2022-01-24 14:56:54编辑:雪饮阅读()
更改静态文件目录
webman默认使用public目录为静态文件目录。如需修改请更改support/helpers.php的中的public_path()助手函数。
首先我們將public目錄複製為public2,然後修改support/helpers.php中的public_path()助手函数,將其中的public修改為public2
然後我們public2目錄中將原本的ajax.html修改為ajax2.html,此時我們的config/static.php中enable選項重新恢復到true狀態。
然後有可能要重啓下webman,否則有可能會不生效,我這裏就遇到了不生效的情況
[root@localhost webman]# /usr/local/php734/bin/php -c /usr/local/php734/lib/php.ini start.php start
Workerman[start.php] start in DEBUG mode
----------------------------------------- WORKERMAN -----------------------------------------
Workerman version:4.0.26 PHP version:7.3.4
------------------------------------------ WORKERS ------------------------------------------
proto user worker listen processes status
tcp root webman http://0.0.0.0:8787 4 [OK]
tcp root monitor none 1 [OK]
---------------------------------------------------------------------------------------------
Press Ctrl+C to stop. Start success.
重啓后就能再次訪問public2目錄中的文件了。
[root@localhost ~]# wget http://192.168.1.10:8787/ajax2.html
--2022-01-24 14:55:33-- http://192.168.1.10:8787/ajax2.html
Connecting to 192.168.1.10:8787... connected.
HTTP request sent, awaiting response... 200 OK
Length: 871 [text/html]
Saving to: ‘ajax2.html’
100%[====================================================================================================================================================================>] 871 --.-K/s in 0s
2022-01-24 14:55:33 (209 MB/s) - ‘ajax2.html’ saved [871/871]
[root@localhost ~]# cat ajax2.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<script>
$(document).ready(function(){
/*
$.ajax({
url:"http://192.168.31.53:8787/user/hello",
success:function(data){
console.log("data",data);
console.log("$(data)", $(data));
}
});
*/
$.ajax({
url:"https://shengke.bhzlkj.com/api/payment/payment/open_pay.html?site_id=1",
success:function(data){
console.log("data",data);
console.log("$(data)", $(data));
}
});
});
</script>
</head>
<body>
</body>
</html>
关键字词:webman,靜態,文件,目錄,更改