"共享",在"互联网共享"那一项前面...">

Mac上Apache服务器搭建

作者: Roy_Liang | 来源:发表于2017-02-05 09:59 被阅读442次

    1. 启动Apache服务器

    (1) 勾选互联网共享

    打开"系统偏好设置"->"共享",在"互联网共享"那一项前面打√。

    (2) 启动Apache服务器

    版本

    sudo apachectl -v
    

    启动终端命令

    sudo apachectl start
    

    浏览器中http://localhost

    Mac上Apache服务器使用的一些终端命令

    启动:sudo apachectl start
    停止:sudo apachectl stop
    重启:sudo apachectl restart
    测试配置:sudo apachectl configtest
    版本信息:sudo apachectl -v
    

    目录
    文件目录:/Library/WebServer/Documents
    服务器配置目录:/etc/apache2

    2. �PHP运行

    (1) 修改配置文件

    前往文件夹/etc/apache2
    找到httpd.conf文件,文本编辑打开
    搜索#LoadModule php5_module libexec/apache2/libphp5.so
    将#号去掉保存
    如锁定可右键查看简介解锁
    如无法解锁,复制到桌面修改然后替换

    Paste_Image.png
    (2) 重启Apache

    终端输入
    sudo apachectl restart

    php已经可以使用。

    (3) 测试info.php

    终端输入
    sudo cp /Library/WebServer/Documents/index.html.en /Library/WebServer/Documents/info.php
    前往文件夹/Library/WebServer/Documents/info.php

    打开info.php,在It works!后面加上<?php phpinfo(); ?>
    重启Apache服务器sudo apachectl restart

    浏览器打开
    http://localhost/info.php

    显示php信息页

    Paste_Image.png

    3. 配置MySql

    (1)使用Homebrew安装MySQL
    brew install mysql
    

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebr

    (2)启动MySQL
    mysql.server start
    

    mysql -uroot即可连接到MySQL数据库。

    相关文章

      网友评论

      本文标题:Mac上Apache服务器搭建

      本文链接:https://www.haomeiwen.com/subject/kjmiyttx.html