dongqu3623 2015-05-26 21:34
浏览 96
已采纳

虚拟主机不解析PHP

Alright, I have spent hours searching through very similar questions but I still don't seem to have found the answer:

I have set up a virtual host with the following in my httpd-vhosts.conf

Listen 80

<VirtualHost *:80>
    ServerName test.dev
    ServerAlias test.dev
    DocumentRoot "/Users/OrangeSoda/OneDrive/Projects/Test/Website"
    ErrorLog "/private/var/log/apache2/test.dev-error_log"
    CustomLog "/private/var/log/apache2/test.dev-access_log" common

    <Directory "/Users/OrangeSoda/OneDrive/Projects/Test/Website">
         Options all
         AllowOverride all
         Require all granted
    </Directory>
 </VirtualHost>

In my http.conf I have Include /private/etc/apache2/extra/httpd-vhosts.conf as well as LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so uncommented.

When I go to test.dev/index.php which just has <?php echo "PHP TEST"; ?>, I see the contents of the file output as a string.

It seems as though PHP is not enabled and is therefore not being recognized.

If i go to localhost, I do see the "It Works!" page, so I know php is working, just for some reason not on my virtual host.

Someone suggested to put php_admin_flag engine on but that just makes the whole page crash.

Does anybody understand why php is not enabled here?

  • 写回答

4条回答 默认 最新

  • drzfnr0275 2015-05-27 22:13
    关注

    The solution was that while php was enabled, for some reason the default setting in httpd.conf was not to read .php files as .php.

    Although I am not really sure why that would not be the default setting, I added the following to my httpd.conf and now it works just fine:

    AddType application/x-httpd-php .php
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 如何将下列的“无限压缩存储器”设计出来
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口