求救!按助教所說修改終端機指令,結果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
你好,
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信息,如果解决了您的问题请采纳,祝学习愉快!
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星