Mac配置Apache和php笔记

1、默认路由路径

apache修改默认路径

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

这样在浏览器也就可以访问自己设定的域名了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值