User:Iho jose/gammapeit/phabricator

From mediawiki.org

Manual de instalación de Phabricator, con configuración de repositorios y servidor.

Phabricator es una aplicación web desarrollada en PHP en la que podemos hospedar proyectos y repositorios, sirve para las organizaciones que buscan tener sus repositorios en un servidor propio y no requiere gastos adicionales debido a que la aplicación es gratuita para los que lo instalan manualmente.

NOTA: Este aplicativo no puede ser instalado en hosting compartido si se quiere tener todas las prestaciones del aplicativo.

Instalación de servidor[edit]

Requerimientos[edit]

  • Puede ser instalado en cualquier servidor pero es recomendable hacerlo sobre un servidor tipo UNIX como Ubuntu.
  • RAM: 512 MB (Se recomienda usar 1 GB).
  • SSD/HDD: 20 GB (Para almacenamiento de los repositorios).
  • VPS: El servidor debe ser dedicado para tener todas las características de la aplicación.

Instalación de Servidor Apache2/MySQL/PHP7[edit]

Ubuntu 14+[edit]

  1. Ejecutamos el comando de instalación:
    sudo apt-get install apache2
    
  2. Habilitamos modulos necesarios para el funcionamiento de phabricator.
    sudo a2enmod rewrite
    sudo a2enmod ssl
    
  3. Instalamos servidor de bases de datos MySQL.
    sudo apt-get install mysql-server
    
  4. Ahora argegaremos el repositorio de PHP al servidor.
    sudo apt-get install -y python-software-properties
    sudo add-apt-repository -y ppa:ondrej/php
    sudo apt-get update -y
    
  5. Instalamos PHP y sus componentes.
    sudo apt-get install -y php7.1 php7.1-fpm php7.1-cli php7.1-common php7.1-mbstring php7.1-gd php7.1-intl php7.1-xml php7.1-mysql php7.1-mcrypt php7.1-zip php7.1-curl libapache2-mod-php7.1
    

Instalación de phabricator[edit]

  1. Instalamos algunas herramientas usadas por Phabricator, entraremos al servidor como usuario root:
    root# apt-get install git mercurial subversion python-pygments sendmail imagemagick
    
  2. Ahora agregaremos 2 usuarios que serán usados por Phabricator para efectuar acciones en la máquina.
    root# adduser phd --home /home/phd
    root# adduser phd sudo
    root# adduser git
    
  3. Crearemos un directorio para los repositorios:
    root# mkdir /var/repo
    root# chown -R phd /var/repo
    root# chgrp -R phd /var/repo
    
  4. Descargamos Phabricator, (en /var/www):
    git clone https://github.com/phacility/libphutil.git
    git clone https://github.com/phacility/arcanist.git
    git clone https://github.com/phacility/phabricator.git
    
  5. accedemos al directorio de phabricator:
    cd /var/www/phabricator
    
  6. Las siguientes son las configuraciones iniciales para Phabricator:
    # Generally acceptable settings:
    ./bin/config set mysql.pass <MYSQL_ROOT_PASSWD>
    ./bin/config set phabricator.base-uri 'http://phabricator.mydomain.net/'
    ./bin/config set phd.user phd
    ./bin/config set environment.append-paths '["/usr/lib/git-core"]'
    ./bin/config set diffusion.ssh-user git
    ./bin/config set pygments.enabled true
    
    # for local-disk file storage only:
    mkdir /home/phd/phabricator-files
    chmod -R 755 /home/phd/phabricator-files
    ./bin/config set storage.local-disk.path /home/phd/phabricator-files
    
    # Set true if you want to allow public http cloning:
    ./bin/config set policy.allow-public true
    # Set to true if you want to allow http pushes
    ./bin/config set diffusion.allow-http-auth false
    # You most likely want prototype apps, they are very useful:
    ./bin/config set phabricator.show-prototypes true
    # You may want this true, depending on your workflow:
    ./bin/config set differential.require-test-plan-field false
    
    # recommended silliness-enabling settings:
    ./bin/config set files.enable-imagemagick true
    ./bin/config set remarkup.enable-embedded-youtube true
    
  7. Ahora editamos /etc/sudoers para los accesos, agregamos la siguiente configuración:
    git ALL=(phd) SETENV: NOPASSWD: /usr/bin/git-upload-pack, /usr/bin/git-receive-pack, /usr/bin/hg, /usr/bin/svnserve
    www-data ALL=(phd) SETENV: NOPASSWD: /usr/bin/git-upload-pack, /usr/lib/git-core/git-http-backend, /usr/bin/hg
    

Configuración de Apache[edit]

  1. Editaremos (crearemos) el archivo /etc/apache2/sites-available/phabricator.conf, y agregamos el siguiente código:
    <VirtualHost *:80>
            # The ServerName directive sets the request scheme, hostname and port that
            # the server uses to identify itself. This is used when creating
            # redirection URLs. In the context of virtual hosts, the ServerName
            # specifies what hostname must appear in the request's Host: header to
            # match this virtual host. For the default virtual host (this file) this
            # value is not decisive as it is used as a last resort host regardless.
            # However, you must set it for any further virtual host explicitly.
            ServerName phabricator.mydomain.net
            ServerAlias phabricator.mydomain.net
            ServerAdmin webmaster@example.com
    
            DocumentRoot /var/www/phabricator/webroot
    
            RewriteEngine on
            RewriteRule ^/rsrc/(.*) - [L,QSA]
            RewriteRule ^/favicon.ico - [L,QSA]
            RewriteRule ^(.*)$ /index.php?__path__=$1 [B,L,QSA]
    
            # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
            # error, crit, alert, emerg.
            # It is also possible to configure the loglevel for particular
            # modules, e.g.
            #LogLevel info ssl:warn
    
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    
            # For most configuration files from conf-available/, which are
            # enabled or disabled at a global level, it is possible to
            # include a line for only one particular virtual host. For example the
            # following line enables the CGI configuration for this host only
            # after it has been globally disabled with "a2disconf".
            #Include conf-available/serve-cgi-bin.conf
            <Directory "/var/www/phabricator/webroot">
                    Require all granted
            </Directory>
    </VirtualHost>
    
    Si se tiene un certificado TLS/SSL, entonces agregamos lo siguiente:
    <IfModule mod_ssl.c>
            <VirtualHost *:80>
                    ServerName phabricator.mydomain.net
                    Redirect permanent / https://phabricator.mydomain.net
            </VirtualHost>
            <VirtualHost *:443>
    
                    # Change this to the domain which points to your host.
                    ServerName phabricator.mydomain.net
                    SSLEngine on
                    SSLCertificateKeyFile /etc/ssl/private/phabricator.key
                    SSLCertificateFile /etc/ssl/certs/phabricator_mydomain.net.crt
                    SSLCertificateChainFile /etc/ssl/certs/phabricator_mydomain.net.ca-bundle
                    SSLProtocol All -SSLv2 -SSLv3
    
                    # Change this to the path where you put 'phabricator' when you checked it
                    # out from GitHub when following the Installation Guide.
                    #
                    # Make sure you include "/webroot" at the end!
                    DocumentRoot /var/www/phabricator/webroot
    
                    RewriteEngine on
                    RewriteRule ^/rsrc/(.*) - [L,QSA]
                    RewriteRule ^/favicon.ico - [L,QSA]
                    RewriteRule ^(.*)$ /index.php?__path__=$1 [B,L,QSA]
                    <Directory "/var/www/phabricator/webroot">
                            Require all granted
                    </Directory>
            </VirtualHost>
    </IfModule>
    
  2. Ahora habilitaremos nuestro nuevo sitio:
    # podemos reshabilitar el que está por defecto
    a2dissite 000-default
    
    # Ahora activamos el nuevo sitio
    a2ensite phabricator
    
    # Reiniciamos el servidor
    service apache2 restart
    
  3. (Opcional): Ahora, si contamos con un servidor con grandes pretaciones podemos subir la velocidad de consulta de MySQL, con la siguiente configuración opcional (/etc/mysql/my.cnf): Debajo de la etiqueta [mysqld]:
    sql_mode=STRICT_ALL_TABLES
    ft_boolean_syntax=' |-><()~*:""&^'
    ft_stopword_file=/home/phd/phabricator/resources/sql/stopwords.txt
    ft_min_word_len=3
    
    Aumentamos el uso de memoria del sistema:
    innodb_buffer_pool_size=800M
    
    Reiniciamos el servidor MySQL:
    service mysql restart
    
  4. En /var/www/phabricator actualizamos almacenamiento:
    /bin/storage upgrade
    
  5. Ahora configuraremos PHP: Ajustamos las siguientes líneas de /etc/php5/apache2/php.ini. Con nano, podemos buscar la línea usando el comando ctrl+w.
    post_max_size = 8M
    date.timezone = Etc/UTC
    opcache.validate_timestamps = 0
    
    Reiniciamos Apache
    service apache2 restart
    
    Reiniciamos dameon user de phabricator:
    root# sudo -su phd
    phd$ ./bin/phd restart
    
  6. Ahora copiaremos archivo de clonado SSH a otro directorio:
    # copy ssh hook to executable location
    cp /var/www/phabricator/resources/sshd/phabricator-ssh-hook.sh /usr/lib/phabricator-ssh-hook.sh
    chown root /usr/lib/phabricator-ssh-hook.sh
    chmod 755 /usr/lib/phabricator-ssh-hook.sh
    # Modify hook to match your system (hint: vcs-user == git)
    nano /usr/lib/phabricator-ssh-hook.sh
    
    Creamos ssh daemon en el puerto 22:
    # Copy the examply sshd config
    cp /var/www/phabricator/resources/sshd/sshd_config.phabricator.example /etc/ssh/sshd_config.phabricator
    # Edit AuthorizedKeysCommand, AuthorizedKeysCommandUser, and AllowUsers
    nano /etc/ssh/sshd_config.phabricator
    # Start the phabricator sshd
    /usr/sbin/sshd -f /etc/ssh/sshd_config.phabricator
    
    Corremos el siguiente comando para probar accesibilidad:
    echo {} | ssh git@phabricator.mydomain.net conduit conduit.ping
    
    El resultado debería ser:
    {"result":"orbital","error_code":null,"error_info":null}
    
  7. Ahora ingresaremos desde un navegador a nuestra instancia de Phabricator y terminamos los procesos pendientes en el icono de notificaciones.