美文网首页PHP学习一起学起来工具
MAMP(macOS) 搭建 Phabricator

MAMP(macOS) 搭建 Phabricator

作者: tdt | 来源:发表于2017-02-20 16:37 被阅读278次

    想把Phabricator搭建在MAMP上,但是网上搜不到太多相关资料,因此自己借鉴LAMP及外国友人的做法,进行一下简单的移植。这里做个记录。

    主要借鉴资料:
    搭建安装Phabricator代码评审工具
    CONFIGURING PHABRICATOR WITH MAMP

    环境(2017.2.20):
    macOS Sierra 10.12.3
    MAMP Pro MAMP PRO 4.1.1(Apache 2.2.31 , PHP 7.1.1)
    Phabricator最新版(要求 PHP 7.1+)

    [TOC]

    MAMP和Phabricator下载安装

    MAMP

    这个就不多说了,除了Phabricator站点,自己没事装个wiki还是其他网站还是很方便的。去官网下载安装即可。作为开发者,这种好东西还是可以去支持一把正版的。

    我一般使用的端口号如下:

    Paste_Image.png

    另外,MAMP中MySQL的密码,为了安全,需要你自己去修改,这个资料多多,也很简单,这里就不赘述了。

    Phabricator

    选择一个你喜欢的目录存放Phabricator,我是扔到iCloud Drive中去了,进入文件夹,使用git clone下载Phabricator及相关组件。

    $ cd somewhere/ # pick some install directory
    somewhere/$ git clone https://github.com/phacility/libphutil.git
    somewhere/$ git clone https://github.com/phacility/arcanist.git
    somewhere/$ git clone https://github.com/phacility/phabricator.git
    

    设置虚拟主机映射

    MAMP新建host

    1. 设置IP,如果设置了内网IP,就可以在内网中使用了。
    2. 设置端口号,比如我这里设置为1234
    3. 将启动文件夹设置到habricator/webroot文件夹
    4. 在Extension中设置参数

    效果图如下:


    Paste_Image.png

    设置Apache

    1. Options for <Directory> directive 使用默认勾选
    2. 在Additional for <VirtualHost>directive: 中加入以下代码:
    RewriteEngine on
    RewriteRule ^/rsrc/(.*)     -                       [L,QSA]
    RewriteRule ^/favicon.ico   -                       [L,QSA]
    RewriteRule ^(.*)$          /index.php?__path__=$1  [B,L,QSA]
    

    示意图如下:

    Paste_Image.png

    这些数据是从LAMP那篇文章拿过来的,后来发现官方文档上就有。

    Paste_Image.png

    以后这个设置不灵光了,照着官网的写就可以了。

    设置MySQL

    启动服务器,现在你打开本站点,会发现是这样的图。

    Paste_Image.png

    按照它的提示,升级这4个值:

    • host:数据库的ip地址,这里在本机上,继续使用localhost即可。
    • port:数据库的端口地址,我用的3306,可以去Ports面板中查看。
    • user:数据库的user,还是本机,root即可
    • pass:user对应的密码,前面说了,自行修改

    执行这4个命令,设置好之后,再刷新界面,如果提示你输入

    ./bin/storage upgrade
    

    那么恭喜你,数据库对上了,关闭Apache,保持MySQL的打开,输入上述命令连接数据库吧。

    设置Phabricator

    到了这里,打开Phabricator网站(如host:port方式),你就能够进入Phabricator了,然后你会发现有一些Unresolved Setup Issues等待你去解决。

    启动daemons

    每次重启电脑后,也要记得把这个打开,这东西就是用来刷新数据的。

    1.安装pcntl插件

    首先你需要安装pcntl插件。因为MAMP用的自己的PHP,而macOS也自己内置了PHP,所以我也不知道pcntl到底是需要安装到哪里。因此,经过一轮又一轮的折腾,我把系统本身的PHP从5.6升级到了7.1.1,然后把pcntl插件各复制了一份,就好了😁。

    #homebrew下载pcntl插件
    brew install homebrew/php/php71-pcntl
    

    复制到MAMP中的PHP插件中


    Paste_Image.png

    同理复制到系统的PHP的对应位置中。

    然后修改phpX.X.X/conf/php.ini,也是2处,调用pcntl.so

    Paste_Image.png

    重启MAMP服务,看看是不是好了呢?这一步我也做的糊里糊涂的,欢迎小伙伴们进行反馈,一些工作肯定是多余了。

    启动Phabricator中的daemons

    进入Phabricator文件夹,使用以下命令对daemons进行控制。

    启动:bin/phd start
    停止:bin/phd stop
    重启:bin/phd restarat
    查看:bin/phd status

    Base URI设置

    网页提示已经够详细了,照着输入就可以了。

    Base URI Not Configured
    The base URI for this install is not configured, and major features will not work properly until you configure it.

    You should set the base URI to the URI you will use to access Phabricator, like "http://phabricator.example.com/".

    Include the protocol (http or https), domain name, and port number if you are using a port other than 80 (http) or 443 (https).

    Based on this request, it appears that the correct setting is:

    http://192.168.39.195:1234/

    To configure the base URI, run the command shown below.
    Run this command:

    phabricator/ $ ./bin/config set phabricator.base-uri 'http://192.168.39.195:1234/'

    
    ## 提示设置storage.local-disk.path
    
    如果有这个的提示,设置这个的命令如下:
    
    

    phabricator/ $ ./bin/config set storage.local-disk.path

    
    我也不知道有什么用,以及需不需要设置。
    
    ## 提示设置repository.default-local-path
    
    同上,不知道什么用,以及需不需要设置,命令如下:
    
    

    phabricator/ $ ./bin/config set repository.default-local-path

    
    ## PHP扩展提示启用
    
    比如apcu,opchache扩展,PHP7.1.1自带,如果启用,那么MAMP其他的PHP站点也会启用,为了全局,愚见不建议启用。
    如果要启用,`File > Edit Template > PHP (php.ini) ` 中打开相应注释。
    
    ## MySQL参数修改
    
    比如` innodb_buffer_pool_size`字段,这里推荐设置成1G以上,个人服务器,没必要提升。
    如果要修改,`File > Edit Template > MySQL ` 中修改相应字段。
    
    
    ## 其他
    
    其他剩余issue我也就先扔那里了,反正phabricator能正常运行,暂时够用就行,以后再来更新,我还没开始玩phabricator呢。
    
    
    # 尾声
    
    剩余的设置Phabricator的账号密码啥的,这个简单,大家自己搞定,至少需要设置一个Provider。
    
    放个图庆祝一下:
    
    
    ![Paste_Image.png](http:https://img.haomeiwen.com/i637043/cff149c5de3904b7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
    
    
    
    经过这一轮2天的折腾,就算没有别的,对MAMP的使用和对PHP的理解倒是增强了不少,也算是意料之外的获得了。

    相关文章

      网友评论

        本文标题:MAMP(macOS) 搭建 Phabricator

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