如何在 Linux Centos 中运行 php 文件?

如何在 Linux Centos 中运行 php 文件?

如何让所有 php 文件在 Apache 中运行?我将所有 php 文件复制到 /www 下的 linux 服务器,并更改了配置设置,如下所示。此外,我还在 /logs 下创建了错误日志文件。但是当我在浏览器中运行 mytest.example.com 时,它无法正常工作,页面显示“哎呀!Google Chrome 找不到 mytest.example.com”。我想我可能需要更改或添加一些内容。请帮助我。提前致谢!

我使用Putty访问Centos并使用WinSCP作为FTP。

<VirtualHost *:80>
ServerName mytest.example.com
DocumentRoot /www/allphpfile/
ErrorLog logs/my_test_error_log
</VirtualHost>

答案1

确保 php 模块已加载LoadModule,并将以下内容添加到您的VirtualHost

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

答案2

当我输入“ping mytest.example.com”时,系统显示 ping: unknown host mytest.example.com。请问这是什么问题?

这表明您的问题与 apache 配置无关,而是与 DNS 解析有关。mytest.example.com 未被您的 DNS 解析。

检查您的 DNS 配置,确保您的域/子域有 A 记录集,并且您等待传播的时间足够长。如果您的域正在使用某些提供商的名称服务器,请联系名称服务器管理部门以获取进一步帮助。

相关内容