參考:https://blog.csdn.net/t3369/article/details/78274729
參考:
環境:
首先搭建LNMP環境:
1.安裝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');
2.安裝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
#make install
2.2 php.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.3 php-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
2.4 啓動PHP:
#/usr/local/php-5.6.30/sbin/php-fpm
查看端口是否在監聽:
[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
ps:可以用PHP -v看下現在用的是不是你安裝的php,有時用的是系統自帶的,啓動phabricator後還是不能查看那個訪問頁面。執行這條語句可以使用自己安裝的:
ln -s /usr/local/php-5.6.30/bin/php /usr/bin/php
3.安裝nginx
3.1 gcc 安裝
安裝 nginx 需要先將官網下載的源碼進行編譯,編譯依賴 gcc 環境,如果沒有 gcc 環境,則需要安裝:
yum install -y 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 的版本,編譯器版本和配置參數
3.6配置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;
}
}
啓動nginx
#/usr/sbin/nginx -c nginx.conf所在的目錄/nginx.conf
-
將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
4.1 phabricator連通mysql
到phabricator的安裝目錄下:
./bin/config set mysql.host 'localhost'
./bin/config set mysql.port '3306'
./bin/config set mysql.user 'root'
./bin/config set mysql.pass 'root的密碼'
./bin/storage upgrade