去年装了一半跑去装artifactory了,这个就搁置了,现在要重新搭建一遍了。结果盲目相信网上的安装教程(省略了好多步骤),折腾了两天。
看官网https://secure.phabricator.com/book/phabricator/article/installation_guide/
官网直接给了两个安装脚本,执行后会安装需要的环境,是LAMP的(linux、apache、mysql、php)。
我用的是LNMP(linux、nginx、mysql、php)。道行太浅,我觉得自己一个个安装,知道安装目录在哪里会比较安心,所以就自己装了。
环境:centos7
先将phabricator下载到一个目录下,之后配置nginx和mysql会用到这个目录。
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
一、安装mysql
1.1安装
需要5.5或更新的版本
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm # rpm -ivh mysql-community-release-el7-5.noarch.rpm # yum install mysql-community-server
安装成功后重启mysql服务。
#service mysqld restart
首次登录没有密码
# mysql -u root
设置密码,无需重启即可生效
mysql> set password for 'root'@'localhost' =password('password');
参考地址:http://www.cnblogs.com/starof/p/4680083.html
1.2 phabricator连通mysql
到phabricator的安装目录下
sudo ./bin/config set mysql.pass 'root的密码' sudo ./bin/storage upgrade
在官网Configuration Guide里有写这一步,你可以在php,nginx都设置好后再执行这一步。
如果你没有设置好数据库,在启动nginx后也会提示你。
二、安装PHP
需要5.5或更新的版本
2.1编译源码
新建一个目录,下载源码并解压
#mkdir /twy #cd /twy #wget http://cn2.php.net/distributions/php-5.6.30.tar.gz #tar zxvf php-5.6.30.tar.gz
安装依赖库
#yum install gcc automake autoconf libtool make –y #yum install gcc gcc-c++ glibc –y #yum install libmcrypt-devel mhash-devel libxslt-devel –y #yum install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel –y #yum install zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel –y #yum install ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel -y #yum install php-devel #yum install krb5 krb5-devel libidn libidn-devel openssl openssl-devel -y #yum install mysql-devel(防止之后需要安装mysql扩展时找不到mysql.h) #yum install -y openssl openssl-devel
在解压目录执行configure后执行make install
#cd /twy/php-5.6.30 #./configure --prefix=/usr/local/php-5.6.30 --enable-fpm --with-mcrypt --enable-mbstring --disable-pdo --enable-pdo --with-curl --disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli --with-gd --with-jpeg-dir -with-gettext --enable-xml --enable-freetype --with-openssl --enable-apcu --enable-opcache --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
#make #install
如果执行./configure时扩展没加进去,比如我最开始没加--with-openssl这个参数,启动nginx后到phabricator的页面,会告诉你有些扩展没有安装,这样的话就再编译一遍PHP源码就好了。
2.2php.ini配置
首先将刚才解压的文件夹中将php.ini-development拷贝到/usr/local/php/lib目录并命名为php.ini:
#cp /twy/php-5.6.30/php.ini-development /usr/local/php-5.6.30/lib/php.ini
修改里面的内容后保存
vim /usr/local/php-5.6.30/lib/php.ini
always_populate_raw_post_data = -1
post_max_size = 32M
date.timezone =Asia/Shanghai
2.3php-fpm.conf配置
首先将/usr/local/php-5.6.30/etc/php-fpm.conf.default拷贝一份并命名为php-fpm.conf:
#cd /usr/local/php-5.6.30
#cp etc/php-fpm.conf.default etc/php-fpm.conf
接着对php-fpm.conf做如下更改(
注意:不能另外加这几句,只能在原语句上去掉注释后修改):
;pid = run/php-fpm.pid这一句取消注释,并改为:pid = /usr/local/php-5.6.30/var/run/php-fpm.pid;
;error_log = log/php-fpm.log这一句取消注释,并改为:error_log = /usr/local/php-5.6.30/var/log/error-log.log
user = nobody改为:user = nginx
group = nobody改为:group = nginx
;catch_workers_output = yes这一句取消注释,改为:catch_workers_output = yes
php-fpm可执行文件在/usr/local/php-5.6.30/sbin目录下,可以通过/usr/local/php-5.6.30/sbin来执行监听,默认是监听9000端口。2.4启动PHP
#/usr/local/php-5.6.30/sbin/php-fpm
查看PHP状态
[root@localhost nginx]# netstat -lntp | grep 9000 tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 16124/php-fpm: pool
关闭php-fpm
kill -INT `cat /usr/local/php5/var/run/php-fpm.pid`或者
pkill php-fpm
可以用PHP -v看下现在用的是不是你安装的php,有时用的是系统自带的,启动phabricator后还是不能证擦黄那个访问页面。执行这条语句可以使用自己安装的
ln -s /usr/local/php-5.6.30/bin/php /usr/bin/php参考地址: http://blog.csdn.net/zhoufoxcn/article/details/73195800
三、安装nginx
3.1 gcc 安装
安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装:
yum install gcc-c++
3.2 PCRE pcre-devel 安装
PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库。命令:
yum install -y pcre pcre-devel
3.3 zlib 安装
zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。
yum install -y zlib zlib-devel
3.4 OpenSSL 安装
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。
nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。
yum install -y openssl openssl-devel
3.5下载nginx并编译
#wget -c https://nginx.org/download/nginx-1.10.1.tar.gz
#tar -zxvf nginx-1.10.1.tar.gz
#cd nginx-1.10.1
#./configure
#make
#make install
nginx常用命令
nginx -s stop 快速关闭Nginx,可能不保存相关信息,并迅速终止web服务。 nginx -s quit 平稳关闭Nginx,保存相关信息,有安排的结束web服务。 nginx -s reload 因改变了Nginx相关配置,需要重新加载配置而重载。 nginx -s reopen 重新打开日志文件。 nginx -c filename 为 Nginx 指定一个配置文件,来代替缺省的。 nginx -t 不运行,而仅仅测试配置文件。nginx 将检查配置文件的语法的正确性,并尝试打开配置文件中所引用到的文件。 nginx -v 显示 nginx 的版本。 nginx -V 显示 nginx 的版本,编译器版本和配置参数。参考地址: https://www.linuxidc.com/Linux/2016-09/134907.htm
四、配置nginx
查看nginx所在的目录
#whereis nginx
nginx的配置文件在安装目录下,我的在/etc/nginx
默认配置文件是nginx.conf,可以在这里面配置,但是如果把所有内容都放在nginx.conf里就太乱了,我们可以把其他的配置内容放在conf.d目录下。只要你的默认配置中把conf.d目录include进去就行了。
在conf.d中新建一个pha.example.com.conf,内容如下:
server { server_name phabricator.example.com;#域名 listen 端口(记得加到防火墙里); root 你下载phabricator的目录/phabricator/webroot; location / { index index.php; rewrite ^/(.*)$ /index.php?__path__=/$1 last; } location /index.php { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #required if PHP was built with --enable-force-cgi-redirect fastcgi_param REDIRECT_STATUS 200; #variables to make the $_SERVER populate in PHP fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; fastcgi_param REMOTE_ADDR $remote_addr; } }
五、访问phabricator
启动nginx
#/usr/sbin/nginx -c nginx.conf所在的目录/nginx.conf
就可以通过 域名:端口 访问页面了,如果是80端口,直接使用域名访问。
如果你没设置域名会显示这个:
我这里加了域名但是没设置域名到dns,那怎样测试呢。在你本地设置域名也可以,参考地址https://jingyan.baidu.com/article/5bbb5a1b15c97c13eba1798a.html