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 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化