Last edit by philipp October 15, 2017 09:52

How to install PHPCI on FreeBSD 11 with NGINX

This document describes, how to run PHPCI on FreeBSD 11 with NGINX.

Install Packages

root@phpci:/ # pkg install nano git nginx php71
root@phpci:/ # pkg install php71-opcache php71-openssl php71-json php71-phar php71-filter php71-hash php71-iconv php71-curl php71-dom php71-xml php71-tokenizer php71-pdo php71-pdo-mysql php71-simplexml php71-pdo_mysql php71-mbstring php71-xmlwriter php71-ctype php71-session

Get Composer

root@phpci:/ # curl -LsS https://getcomposer.org/composer.phar -o /usr/local/bin/composer
root@phpci:/ # chmod a+x /usr/local/bin/composer

Setup PHPCI

root@phpci:/ # cd /usr/local/www/
root@phpci:/usr/local/www # composer create-project block8/phpci phpci --keep-vcs --no-dev
root@phpci:/usr/local/www # chown -R www:www phpci/
root@phpci:/usr/local/www # cd phpci && ../composer install

Install MariaDB

root@phpci:/usr/local/www/phpci # pkg install mariadb102-server
root@phpci:/usr/local/www/phpci # sysrc mysql_enable="YES"
root@phpci:/usr/local/www/phpci # cp /usr/local/share/mysql/my-small.cnf /usr/local/etc/my.cnf 
root@phpci:/usr/local/www/phpci # service mysql-server start
root@phpci:/usr/local/www/phpci # mysql
CREATE DATABASE phpci;
CREATE USER phpci@localhost IDENTIFIED BY '**********';
GRANT ALL PRIVILEGES ON phpci.* TO phpci@localhost;
FLUSH PRIVILEGES;

Install PHPCI

root@phpci:/usr/local/www/phpci # ./console phpci:install
root@phpci:/usr/local/www/phpci # nano /usr/local/etc/nginx/nginx.conf
user  www;
worker_processes  2;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log info;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  phpci.typo.media;
        root /usr/local/www/phpci/public;
        index index.php;

        location / {
            try_files $uri /index.php$is_args$args;
        }

        location ~ ^/index\.php(/|$) {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php-fpm.sock;
                fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
                fastcgi_param DOCUMENT_ROOT $realpath_root;
                include fastcgi_params;
        }
    }

}

FastCGI Config

root@phpci:/usr/local/www/phpci # nano /usr/local/etc/php-fpm.d/www.conf
...
listen = /var/run/php-fpm.sock
...
listen.owner = www
listen.group = www
listen.mode = 0660
...

Start Daemons

root@phpci:/usr/local/www/phpci # sysrc nginx_enable="YES"
root@phpci:/usr/local/www/phpci # sysrc php_fpm_enable="YES"
root@phpci:/usr/local/www/phpci # service nginx start
root@phpci:/usr/local/www/phpci # service php-fpm start
root@phpci:/usr/local/www/phpci # crontab -e

Setup Cron

* * * * * /usr/local/bin/php /usr/local/www/phpci/console phpci:run-builds

Create Symlinks

root@phpci:/usr/local/www/phpci # cd /bin/
root@phpci:/bin # ln -s /usr/local/bin/git
root@phpci:/bin # ln -s /usr/local/bin/php

Config File

root@phpci:/bin # cat /usr/local/www/phpci/PHPCI/config.yml

The content on this page is licensed under Creative Commons Attribution 4.0 International license.