求救!按助教所說修改終端機指令,結果server無法開啟

求救!按助教所說修改終端機指令,結果server無法開啟

mamp安裝完成後,瀏覽器無法解析php文件,只會把整個代碼打印出來。

此後,依助教要求輸入終端機指令,修改apache文件,但終端機的wq保存是怎樣保存?接著輸入指令去重啟apache,是要整個終端機關掉再重開後,去輸入指令重啟嗎?因為在apache文件下,不像是能輸入sudo apachectl restart

然後現在因為有動到終端機,現在重開mamp後,server無法開啟,apache也無法勾選。輸入終端機指令sudo vi /etc/apache2/httpd.conf 就跳錯誤,整個mamp砍掉重灌也沒用

E325: ATTENTION

Found a swap file by the name "/etc/apache2/.httpd.conf.swp"

          owned by: root   dated: Sat Jul  1 11:05:07 2017

         file name: /private/etc/apache2/httpd.conf

          modified: YES

         user name: root   host name: wuzhede-MBP

        process ID: 28776

While opening file "/etc/apache2/httpd.conf"

             dated: Wed Jan 11 21:17:29 2017


(1) Another program may be editing the same file.  If this is the case,

    be careful not to end up with two different instances of the same

    file when making changes.  Quit, or continue with caution.

(2) An edit session for this file crashed.

    If this is the case, use ":recover" or "vim -r /etc/apache2/httpd.conf"

    to recover the changes (see ":help recovery").

    If you did this already, delete the swap file "/etc/apache2/.httpd.conf.swp"


    to avoid this message.


Swap file "/etc/apache2/.httpd.conf.swp" already exists!

[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort: 

選O下去查看apache文件
#LoadModule php5_module libexec/apache2/libphp5.so
#字號依然存在

請求大神支援,環境搭不起來後面的課程都卡住了
然後涉及終端機還有指令麻煩一步一步教啊,小白如我根本不知道終端機的操作。

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
guly 2017-07-10 09:40:39

你好,退出步骤是先按ecs键,然后再按"冒号",然后"wq!",至于添加AddType application/x-httpd-php .php报错,建议产看代码是否数写如httpd.conf中代码有误,添加AddType application/x-httpd-php .php本身是没有问题的,如果解决了您的问题请采纳祝学习愉快!

guly 2017-07-01 21:26:44

你好,

1.apache没有添加对应的php类型,所以不支持php的脚本解析

解决办法:在配置文件中添加对应类型

找到apache配置文件:知道位置的自己去找,不知道位置的试试使用find命令

在根目录下执行:#find / -name "httpd.conf"

修改httpd.conf在文件中添加一行内容:AddType application/x-httpd-php .php

2.没有加上针对php的索引,如果没有该索引的支持,则无法解析用php编写的网页

解决办法:在配置文件中添加对应索引

找到配置文件方法同上,找到DirectoryIndex index.html

改为DirectoryIndex index.html index.htm index.php 即可

3.开启了防火墙

用命令:#getenforce

来查看防火墙的状态,若是Enforcing,说明是打开的,请在配置文件中关闭

在/etc/selinu目录下,修改config中的enforcing为disabled

4.未加载php5_module模块 

解决办法:添加模块

在配置文件中添加:LoadModule php5_module modules/libphp5.so

最后重新启动机器。重新测试,可以返回php信息,如果解决了您的问题请采纳,祝学习愉快!


  • 提问者 PittWu #1
    請問mac的終端機環境下(vim),特定的指令該如何執行?我想要保存或退出,按wq或按q都沒反應,是否提供指令教學的材料。 新增了AddType application/x-httpd-php .php在httpd.conf文末結果加跳一個錯誤 Error detected while processing function <SNR>13_NetrwBrowseChgDir: line 170: 而且httpd.conf中也未出現剛剛輸入的AddType application/x-httpd-php .php
    2017-07-10 07:51:35
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师