ARK2/Install

From ARK
Revision as of 10:43, 7 January 2018 by John Layt (talk | contribs) (macOS)

Jump to: navigation, search

Install

Git / Github

Development is hosted on Github, so you will need a free Github account to contribute code.

If you are new to Git, you may find the Github desktop application easier to use. Alternatives are SourceTree and GitKraken.

Environment

To develop ARK requires the following tools to be installed:

You will also require PHP, a web server (Apache/PHP), a database server (MySQL/PostreSQL/SQLite), a web browser (Chrome/Firefox), and a an API client (Postman).

The following tools are recommend to adhere to ARK code quality standards:

  • php-cs-fixer
  • PHP CodeSniffer

macOS

On macOS, while you can install the requirements via standalone packages such as MAMP, we recommend using HomeBrew as it makes installing and updating all the tools used easier. Using macOS is only recommended for local hosting or development purposes only, internet-connected production sites should be run on a properly supported server installation, such as Debian Stretch.

  • Install XCode from the App Store and run it to accept the license, or from the command line:
    sudo xcodebuild -license accept
  • Check you have the Command Line Tools (including Git) installed and enabled:
    sudo xcode-select --install
  • Download and install HomeBrew:
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Modify your ~/.profile file to add brew packages to your $PATH and to enable Git completion
 export PATH=/usr/local/bin:/usr/local/sbin:$PATH
 source /Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash
 source /Library/Developer/CommandLineTools/usr/share/git-core/git-prompt.sh
 GIT_PS1_SHOWDIRTYSTATE=true
 PS1='\u@\h \W$(__git_ps1 " (%s)") \$ '
  • Source your modified ~/.profile file to start using it:
    source ~/.profile
  • Install the required packages from Brew:
 brew install httpd
 brew install mariadb
 brew tap homebrew/php
 brew install php71 php71-imagick php71-intl php71-opcache php71-xdebug
 brew install composer php-code-sniffer php-cs-fixer phpdocumentor phplint phpmyadmin
 brew install nodejs
  • Modify /usr/local/etc/httpd/httpd.conf to enable PHP-FPM, aliases, vhosts and rewrite by uncommenting the following lines:
 LoadModule proxy_module lib/httpd/modules/mod_proxy.so
 LoadModule proxy_fcgi_module lib/httpd/modules/mod_proxy_fcgi.so
 LoadModule vhost_alias_module lib/httpd/modules/mod_vhost_alias.so
 LoadModule alias_module lib/httpd/modules/mod_alias.so
 LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
  • Add the following after the DocumentRoot section to enable PhpMyAdmin:

Alias /phpmyadmin /usr/local/share/phpmyadmin <Directory /usr/local/share/phpmyadmin/>

   Options Indexes FollowSymLinks MultiViews
   AllowOverride All
   Require all granted

</Directory>

  • Modify the DirectoryIndex section to appear as follows:
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

<IfModule proxy_fcgi_module>
    <FilesMatch ".+\.ph(ar|p|tml)$">
        SetHandler "proxy:fcgi://127.0.0.1:9000"
    </FilesMatch>
</IfModule>
  • Start the required services:
 brew services start mariadb
 brew services start php71
 brew services start httpd
  • Point your browser to localhost:8080 and you should see the default Apache page
  • Point your browser to localhost:8080/phpmyadmin and sign in to confirm that PHP and MariaDB are running correctly

Debian Stable (Stretch)

Debian Stretch ships with PHP 7.0 by default, but also enables the parallel install of other PHP versions using PHP-FM. PHP 5.6 and 7.1 are not in the official repositories, but the Debian maintainer has made them available in his repo pending their being pushed to Debian Backports. LP Archaeology use this combination for our servers and we strongly recommend you use this method for both simplicity and reliability.

Instructions for NodeJS: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

Instructions for PHP 7.1: https://packages.sury.org/php/README.txt. See also https://github.com/oerdnj/deb.sury.org/wiki/Managing-Multiple-Versions


Summary of install commands

sudo apt-get install build-essential git apache2 mariadb-client mariadb-server \
php7.1 php7.1-bcmath php7.1-bz2 php7.1-cli php7.1-common php7.1-enchant php7.1-fpm php7.1-gd php7.1-intl \
php7.1-json php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-opcache php7.1-readline php7.1-sqlite3 \
php7.1-tidy php7.1-xml php7.1-zip phpmyadmin php-apcu php-apcu-bc php-geoip php-getid3 php-imagick \
php-pear libphp-phpmailer php-php-gettext php-phpseclib php-tcpdf php-uuid php-yaml 
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
curl -sS https://getcomposer.org/installer -o composer-setup.php
php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Enabled FPM

sudo service php7.1-fpm start
sudo systemctl enable  php7.1-fpm
sudo a2enconf php7.1-fpm
sudo a2enmod proxy_fcgi rewrite

Once ARK is installed (see below), configure Apache to serve the site, using either alias or symlink.

sudo vim /etc/apache2/sites-available/mysite.conf

Using a simple alias on a subdirectory:

 <VirtualHost *:80>
     ServerName localhost
     ServerAdmin sysadmin@localhost
     DirectoryIndex index.html index.php
     LogLevel debug
     Alias "/mysite"
     <Directory "/srv/www/lib/ark2/sites/mysite/web">
         Options FollowSymLinks
         Require all granted
         AllowOverride None
         AcceptPathInfo On
         RewriteEngine On
         RewriteCond %{REQUEST_FILENAME} !-f
         RewriteRule ^(.*)$ /index.php [QSA,L]
    </Directory>
 </VirtualHost>


Using a vhost on a subdomain

 <VirtualHost *:80>
     ServerName mysite.example.com
     ServerAdmin admin@example.com
     DocumentRoot /srv/www/lib/ark2/sites/mysite/web
     DirectoryIndex index.html index.php
     LogLevel warn
     ErrorLog /path/to/logs/<site>/error.log
     CustomLog /path/to/logs/<site>/access.log combined
     <Directory "/srv/www/lib/ark2/sites/mysite/web">
         Options FollowSymLinks
         Require all granted
         AllowOverride None
         AcceptPathInfo On
         RewriteEngine On
         RewriteCond %{REQUEST_FILENAME} !-f
         RewriteRule ^(.*)$ /index.php [QSA,L]
    </Directory>
 </VirtualHost>
sudo a2ensite dime
sudo apache2ctl -t
sudo systemctl reload apache2
sudo apache2ctl -S

Install

To install using git, create the folder where the library code will be located, then clone the ARK2 repository.

For example, for Debian stretch:

mkdir -p /srv/www/lib
cd /srv/www/lib
git clone https://github.com/lparchaeology/ark2.git

Alternatively download and unzip the file from https://github.com/lparchaeology/ark2

Then run composer to install the required PHP libraries:

cd ark2/
composer install
<may need github token...>

Run the Sysadmin console to check your install:

./bin/sysadmin
./bin/sysadmin system:about

Check the database server config file is correct for your install:

less sites/servers.json

If you need to add different server details:

./bin/sysadmin database:server:add

To create a new site:

./bin/sysadmin site:create <site>
./sites/<site>/bin/console

Now edit the site config files to reflect your site settings. Most settings will have the correct default, but some may need tweaking:

vim sites/<site>/config/site.json

If using vhosts or aliases to serve the site, see above for instructions.

If not using vhosts, for local development you can symlink the site

cd ..
ln -s sites/<site>/web  /<path>/<to>/htdocs/<site>
http://localhost/<site>

To rebuild the frontend

cd build
./build env:install
./build frontend:all <frontend>