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 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧