我有几个使用 IIS 10 运行的网站使用相同的php.ini
,现在我更改了php.ini
文件中的一个值,该值无法通过 PHP 中的方法设置ini_set()
。
有没有办法php.ini
在不停止和启动整个服务器的情况下重新加载其中一个网站?重新启动网站本身不起作用。
我不想停止现在可能正在使用其他网站的用户的操作
我有几个使用 IIS 10 运行的网站使用相同的php.ini
,现在我更改了php.ini
文件中的一个值,该值无法通过 PHP 中的方法设置ini_set()
。
有没有办法php.ini
在不停止和启动整个服务器的情况下重新加载其中一个网站?重新启动网站本身不起作用。
我不想停止现在可能正在使用其他网站的用户的操作
建议我在 IIS 的请求过滤中取消选中“允许未列出的文件扩展名”选项。但现在 PHP 应用程序无法运行,我得到:
HTTP 错误 404.7 - 未找到
请求过滤模块用于拒绝文件扩展名。
我不确定这是否是由于.php
文件扩展名或运行应用程序的 php-cgi.exe 模块引起的。
无论哪种情况 - 我需要做什么才能使 PHP 工作(使用 php-cgi)并且也无法“允许未列出的文件扩展名”?
我认为这与“文件扩展名”和“允许文件扩展名”有关,但不确定如何执行此操作,因为我尝试添加.php
但仍然不起作用
编辑:出于测试目的,我还添加了exe
但仍然错误 404.7
编辑 2:添加了网站中可能使用的任何文件类型:css
,js
并且仍然是 404.7
编辑3 :我只是检查在没有请求过滤的情况下尝试加载的页面上加载的所有文件,添加了正在加载的所有png
可能的扩展名: ,,,等等,但仍然是404.7jpg
ttf
svg
更新:即使将.php
扩展名添加到 Mime Types as后application/x-httpd-php
,它仍然不起作用
现在我有以下块web.config
:
<fileExtensions allowUnlisted="false">
<add fileExtension=".html" allowed="true" />
<add fileExtension=".ico" allowed="true" />
<add fileExtension=".htm" allowed="true" />
<add fileExtension="." allowed="true" />
</fileExtensions>
我在我的邮递员 API 中通过 POST 方法获取一个数组,在获取后我试图拆分数组,然后将每个数组值分配给一个变量,将其存储在 XML 代码中并将该 XML 代码发送到服务器。我知道我的代码在数组拆分中写错了。这是我的 POSTMAN API: 响应中的服务器错误
我知道这个错误正在发生,因为由于代码中的数组语法,请求无法处理到服务器,这是我的代码:
<?php
public function price(Request $request)
{
$information = $this->validate($request, [
'prices' => 'required'
]);
$prices = $information['prices']; //Getting the array from postman api
list($array1, $array2, $array3, $array4, $array5) = array_chunk($prices, 1); //assigning variables
$xml = "<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
<methodName>update_plan_prices</methodName>
<params>
<param>
<value>
<struct>
<value>
<array>
<data>
<value>
<int>" . $array1 . "</int>
</value>
<value>
<int>" . $array2 . "</int>
</value>
<value>
<int>" . $array3 . "</int>
</value>
<value>
<int>" . $array4 . "</int>
</value>
<value>
<int>" . $array5 . "</int>
</value>
</data>
</array>
</value>
</struct>
</value>
</param>
</params>
</methodCall>
";
$url = "https://my_server_url/";
$send_context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Content-Type: application/xml',
'content' => $xml
)
));
$response = file_get_contents($url, false, $send_context);
return response()->json($response);
}
?>
我运行以下语句(因此它是完全可重现的)(因为我想使用 WordPress 的源代码)并且以下使您当前的目录成为在 8082(pwd)下运行的网站。
mkdir wordpress
cd wordpress
git clone https://github.com/WordPress/WordPress.git .
docker run -p 127.0.0.1:3306:3306 –name some-mariadb -e MARIADB_ROOT_PASSWORD=PASSWORD -d mariadb:latest
docker run -d -p 8082:80 –mount type=bind,source=”$(pwd)”,target=/var/www/html php:apache
我制作了一个新文件:info.php:
if ( function_exists( 'mysqli_connect' ) )
{
echo "exists";
}
else
{
echo "does not exist";
}
phpinfo();
问题:浏览器中的输出显示“不存在”。
(phpinfo() phpinfo 显示 lib mysqlnd 8.0.11)
这意味着 WordPress 给出了相同的错误,因为这是 WordPress 使用的代码。
那么为什么...在 phpinfo 提供详细信息时找不到功能/扩展名。
我做错了很可能。
参考:
更新 我注意到“--with-mysqli=mysqlnd”不在上面的 phpinfo 屏幕中。所以我解压了 tar 文件(当然在 docker 镜像中)并
这解决了问题。
这是我example.conf
的nginx
配置文件:
server {
listen 80;
server_name api.example.net;
return 301 https://api.example.net$request_uri;
access_log off;
error_log /dev/stderr;
}
server {
listen 443 ssl;
root /var/www/example_api/public;
server_name api.example.net;
ssl_certificate /etc/letsencrypt/live/api.example.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/api.example.net/privkey.pem;
location / {
# try to serve file directly, fallback to index.php
try_files $uri /index.php$is_args$args;
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS, PUT, DELETE, PATCH";
add_header Access-control-Allow-Headers "Content-Range, Authorization,X-Requested-With, counter, id_token, Keep-Alive, User-Agent, Cache-Control, Content-Type, MyApp-Handle-Errors-Generically";
add_header Access-Control-Expose-Headers "Content-Range, Authorization, id_token, Keep-Alive, User-Agent, Cache-Control, Content-Type, MyApp-Handle-Errors-Generically";
add_header Access-Control-Max-Age "31536000";
}
#location ~ ^/index\.php(/|$) {
# https://stackoverflow.com/questions/68350978/nginx-serving-only-but-not-any-other-files
location ~ \.php(/|$) {
try_files $uri $uri/ /index.php?$query_string;
fastcgi_pass api:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS, PUT, DELETE, PATCH";
add_header Access-control-Allow-Headers "Content-Range, Authorization,X-Requested-With, counter, id_token, Keep-Alive, User-Agent, Cache-Control, Content-Type, MyApp-Handle-Errors-Generically";
add_header Access-Control-Expose-Headers "Content-Range, Authorization, id_token, Keep-Alive, User-Agent, Cache-Control, Content-Type, MyApp-Handle-Errors-Generically";
add_header Access-Control-Max-Age "31536000";
}
location ~ \.php$ {
return 404;
}
access_log off;
error_log /dev/stderr;
}
问题是当我从in发送POST
请求时,我收到此错误:POSTMAN
http
api.example.net/api/user/register/checkuser?phone=0123456789
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="robots" content="noindex,nofollow,noarchive" />
<title>An Error Occurred: Method Not Allowed</title>
...
但是,如果将 URL 更改为https
,则没有问题:
https://api.example.net/api/user/register/checkuser?phone=0123456789
{"data":{"status":1},"meta":[]}
我做错什么了吗?
我应该提到我们从旧服务器迁移Caddy web server
到当前服务器nginx
,并且两者都是 Dockerized (仅额外信息)。
我刚刚克隆了一个项目,所以当我加载它时它工作得很好,例如:“localhost/example/contact.html”,但是当我点击到端点是“localhost/example/index.php”的主页时,它会问我像这样保存文件:https ://i.stack.imgur.com/afq10.png
我检查了 php.ini、httpd.conf 等文件中的所有内容,但仍然找不到解决方案,我还重新安装了 wamp 2 次。
php错误日志也给了我这个错误:文件C:/WINDOWS/system32/drivers/etc/hosts不存在
任何帮助,将不胜感激!
我正在使用带有 PHP Server 扩展的 Visual Studio Code。当我尝试启动我的 Web 应用程序时,浏览器会向我显示以下消息:
警告:未知:无法打开流:第0行的未知中没有此类文件或目录
致命错误:无法打开所需的 'c:\Users\OMISSIS\.vscode\extensions\brapifra.phpserver-3.0.2\src\server\logger.php' (include_path='C:\xampp\php\PEAR')第0行未知
我也尝试重新安装 VS Code 和 XAMPP,但问题仍然存在。我能做些什么?