1、默认路由路径
2、apache配置php
-
打开
/etc/apache2/httpd.conf文件,寻找php相关(command+F搜索php) -
在约187行的
#LoadModule php7_module libexec/apache2/libphp7.so
- 将注释符
#删除
LoadModule php7_module libexec/apache2/libphp7.so
- 重启apache服务
sudo apachectl restart - 在DocumentRoot路径下创建php文件,如
Info.php
写入
<?php
phpinfo();
- 打开浏览器输入url,看见如下界面即成功
3、php打印时间戳不对
在国内utc都是+8的,在/etc文件夹下的php.ini文件中搜索timezone关键字,修改成
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/ShangHai
4、自定义域名
本地地址127.0.0.1或者localhost,那么localhost是多少呢?
进入/etc,有一个hosts文件
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 didideMacbook.local
255.255.255.255 broadcasthost
::1 localhost
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
# This entry was appended by Docker Desktop because `localhost` did not resolve
# to a list of addresses which included 127.0.0.1. This can happen due to a bug
# in the macOS migration assistant, or possibly because another tool has
# corrupted the file.
127.0.0.1 localhost
# End of the section appended by Docker Desktop
所以localhost == 127.0.0.1
因此可以在此添加修改自己喜欢的域名,如127.0.0.1 ycc.com
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 didideMacbook.local
255.255.255.255 broadcasthost
::1 localhost
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
127.0.0.1 ycc.com
# This entry was appended by Docker Desktop because `localhost` did not resolve
# to a list of addresses which included 127.0.0.1. This can happen due to a bug
# in the macOS migration assistant, or possibly because another tool has
# corrupted the file.
127.0.0.1 localhost
# End of the section appended by Docker Desktop
这样在浏览器也就可以访问自己设定的域名了
本文介绍了如何修改Apache的默认路径以支持PHP,详细步骤包括解除php7_module的注释并重启Apache服务。此外,还展示了如何通过调整php.ini文件设置正确的时区,并在本地设置自定义域名,只需在hosts文件中添加对应条目即可实现。
692

被折叠的 条评论
为什么被折叠?



