doubi7346 2015-05-07 15:33
浏览 41
已采纳

PHP仍未在MAC OSX 10.10 Yosemite上执行

I cannot get PHP to work on my computer. My browser prints out the php code rather than executing it.

The first thing I did was to open up the apache conf file and edit it to uncomment the php line

Opened file:

    sudo nano /etc/apache2/httpd.conf

This is the line I uncommented in that file:

    LoadModule php_module libexec/apache2/libphp5.so

I then restarted apache using:

    sudo apachectl restart

Apache would run, http://127.0.0.1 would show "It works!" I then created a file called test.php, in which I put the following line of code:

    <?php phpinfo(); ?> 

In chrome I clicked file -> open file -> test.php, and all it printed was the code I had written.

I've also tried changing the line "User _www" in the conf file to

    User myusername 

I've tried changing the line "DirectoryIndex index.html" to:

    DirectoryIndex index.php index.html index.htm 

None of these changes have resulted in PHP script executing on my computer. Any help would be appreciated!

  • 写回答

1条回答 默认 最新

  • doufu9145 2015-05-07 15:40
    关注

    Put the test.php in /Library/WebServer/Documents .

    Make sure you have

     <?php phpinfo(); ?> 
    

    inside your test.php

    Open Chrome. Go to http://localhost/test.php

    You cant just open test.php file using Chrome. PHP script needs to be executed by a PHP Compiler before you can see any output. If you simply open the PHP file in chrome, it will show you the PHP code only.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler