php关联Apache和nginx
2021-06-06 04:02
标签:信息 链接 ati 工作 apach request 格式 127.0.0.1 ... 编辑apache配置文件httpd.conf,以apache支持php vim /etc/httpd/httpd.conf 定位至DirectoryIndex index.html 修改为: 而后重新启动httpd,或让其重新载入配置文件即可测试php是否已经可以正常使用。 编辑nginx配置文件nginx.conf,以nginx支持php 编辑/etc/nginx/nginx.conf,启用如下选项: 编辑/etc/nginx/fastcgi_params,将其内容更改为如下内容: 并在所支持的主页面格式中添加php格式的主页,类似如下: 而后重新载入nginx的配置文件: 在网页根目录下新建index.php的测试页面,测试php是否能正常工作: 这个可以查看PHP的信息; 测试页面index.php示例如下: mysql_close(); 这个可以查看PHP和数据库是否链接成功 php关联Apache和nginx 标签:信息 链接 ati 工作 apach request 格式 127.0.0.1 ... 原文地址:http://www.cnblogs.com/52py/p/7340621.html
添加如下二行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.html
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
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 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;
location / {
root html;
index index.php index.html index.htm;
}
# service nginx restart
# cat > /usr/html/index.php phpinfo();
?>
$link = mysql_connect(‘127.0.0.1‘,‘root‘,‘123.abc‘);
if ($link)
echo "Success...";
else
echo "Failure...";
?>