Difference between revisions of "ARK2/Install"

From ARK
Jump to: navigation, search
(macOS)
(Debian Stable (Stretch))
 
(8 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
== Git / Github ==
 
== Git / Github ==
  
Development is hosted on [https://github.com/lparchaeology Github], so you will need a free Github account to contribute code.
+
Development is hosted on [https://gitlab.com/arklab GitLab], so you will need a free GitLab account to contribute code.
  
If you are new to Git, you may find the [https://desktop.github.com/ Github desktop application] easier to use. Alternatives are [https://www.sourcetreeapp.com/ SourceTree] and [https://www.gitkraken.com/ GitKraken].
+
If you are new to Git, you may find a desktop application easier to use such as [https://www.sourcetreeapp.com/ SourceTree] and [https://www.gitkraken.com/ GitKraken], or the support built-in to your IDE like Atom.
  
 
== Environment ==
 
== Environment ==
Line 37: Line 37:
 
* Install the required packages from Brew:  
 
* Install the required packages from Brew:  
 
<pre>
 
<pre>
  brew install httpd
+
  brew install httpd mariadb imagemagick icu4c
  brew install mariadb
+
  brew install php@7.4
brew tap homebrew/php
+
  pecl install apcu imagick xdebug
  brew install php71 php71-imagick php71-intl php71-opcache php71-xdebug
+
  brew install composer php-code-sniffer php-cs-fixer@2 phpdocumentor phplint phpmyadmin
  brew install composer php-code-sniffer php-cs-fixer phpdocumentor phplint phpmyadmin
+
  brew install node@14
  brew install nodejs
 
 
</pre>
 
</pre>
 
* Modify /usr/local/etc/httpd/httpd.conf to enable PHP-FPM, aliases, vhosts and rewrite by uncommenting the following lines:
 
* Modify /usr/local/etc/httpd/httpd.conf to enable PHP-FPM, aliases, vhosts and rewrite by uncommenting the following lines:
Line 53: Line 52:
 
</pre>
 
</pre>
 
* Add the following after the DocumentRoot section to enable PhpMyAdmin:
 
* Add the following after the DocumentRoot section to enable PhpMyAdmin:
 +
<pre>
 
Alias /phpmyadmin /usr/local/share/phpmyadmin
 
Alias /phpmyadmin /usr/local/share/phpmyadmin
 
<Directory /usr/local/share/phpmyadmin/>
 
<Directory /usr/local/share/phpmyadmin/>
Line 59: Line 59:
 
     Require all granted
 
     Require all granted
 
</Directory>
 
</Directory>
 +
</pre>
 
* Modify the DirectoryIndex section to appear as follows:
 
* Modify the DirectoryIndex section to appear as follows:
 
<pre>
 
<pre>
Line 78: Line 79:
 
<pre>
 
<pre>
 
  brew services start mariadb
 
  brew services start mariadb
  brew services start php71
+
  brew services start php@7.4
 
  brew services start httpd
 
  brew services start httpd
 
</pre>
 
</pre>
* Point your browser to localhost:8080 and you should see the default Apache page
+
* Point your browser to localhost 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
+
* Point your browser to localhost/phpmyadmin and sign in to confirm that PHP and MariaDB are running correctly
  
=== Debian Stable (Stretch) ===
+
=== Debian ===
  
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.
+
Since Debian Stretch, Debian has enabled the parallel install of multiple PHP versions using PHP-FM. However each release of Debian ships with a different default version and only that version is officially supported in that release. In order to install other versions such as PHP 5.6 and 7.4 you need to use the packages made available by the Debian Maintainer in his personal development repo. Check your version of Debian to determine what you need. LP Archaeology use this solution 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 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
+
Instructions for adding PHP repo: https://packages.sury.org/php/README.txt.  See also https://github.com/oerdnj/deb.sury.org/wiki/Managing-Multiple-Versions
  
 +
Summary of install commands for PHP 7.4 current requirement:
  
Summary of install commands
+
sudo apt-get install build-essential git apache2 mariadb-client mariadb-server
  
  sudo apt-get install build-essential git apache2 mariadb-client mariadb-server \
+
  sudo apt-get install php7.4 php7.4-apcu php7.4-apcu-bc php7.4-bcmath php7.4-bz2 php7.4-cli php7.4-common php7.4-fpm php7.4-gd \
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.4-geoip php7.4-imagick php7.4-intl php7.4-json php7.4-mbstring php7.4-mysql php7.4-opcache php7.1-readline php7.4-sqlite3 \
php7.1-json php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-opcache php7.1-readline php7.1-sqlite3 \
+
  php7.4-tidy php7.4-uuid php7.4-yaml php7.4-xml php7.4-zip phpmyadmin php-pear
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 -
 
  curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
Line 109: Line 109:
 
Enabled FPM
 
Enabled FPM
  
  sudo service php7.1-fpm start
+
  sudo service php7.4-fpm start
  sudo systemctl enable  php7.1-fpm
+
  sudo systemctl enable  php7.4-fpm
  sudo a2enconf php7.1-fpm
+
  sudo a2enconf php7.4-fpm
 
  sudo a2enmod proxy_fcgi rewrite
 
  sudo a2enmod proxy_fcgi rewrite
  
Line 159: Line 159:
 
   </VirtualHost>
 
   </VirtualHost>
  
  sudo a2ensite dime
+
  sudo a2ensite mysite
  
 
  sudo apache2ctl -t
 
  sudo apache2ctl -t
Line 175: Line 175:
 
  mkdir -p /srv/www/lib
 
  mkdir -p /srv/www/lib
 
  cd /srv/www/lib
 
  cd /srv/www/lib
  git clone https://github.com/lparchaeology/ark2.git
+
  git clone https://gitlab.com/arklab/arkserver.git
  
Alternatively download and unzip the file from https://github.com/lparchaeology/ark2
+
Alternatively download and unzip the file from https://gitlab.com/arklab/arkserver
  
 
Then run composer to install the required PHP libraries:
 
Then run composer to install the required PHP libraries:
  
  cd ark2/
+
  cd arkserver/
 
  composer install
 
  composer install
 
  <may need github token...>
 
  <may need github token...>
Line 207: Line 207:
 
  vim sites/<site>/config/site.json
 
  vim sites/<site>/config/site.json
  
If using vhosts or aliases to serve the site, see above for instructions.
+
If using vhosts, see above for instructions.
 +
 
 +
If not using vhosts, for local development, edit your Apache config to alias the site folder:
 +
 
 +
Alias /<site> /path/to/ark2/sites/<site>/web
 +
<Directory /path/to/ark2/sites/<mysite>/web>
 +
    Options Indexes FollowSymLinks MultiViews
 +
    AllowOverride All
 +
    Require all granted
 +
</Directory>
  
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>
 
  http://localhost/<site>
  
 
To rebuild the frontend
 
To rebuild the frontend
 
  cd build
 
  cd build
  ./build env:install
+
  npm install
 
  ./build frontend:all <frontend>
 
  ./build frontend:all <frontend>

Latest revision as of 11:58, 22 September 2021

Install

Git / Github

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

If you are new to Git, you may find a desktop application easier to use such as SourceTree and GitKraken, or the support built-in to your IDE like Atom.

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 mariadb imagemagick icu4c
 brew install php@7.4
 pecl install apcu imagick xdebug
 brew install composer php-code-sniffer php-cs-fixer@2 phpdocumentor phplint phpmyadmin
 brew install node@14
  • 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 php@7.4
 brew services start httpd
  • Point your browser to localhost and you should see the default Apache page
  • Point your browser to localhost/phpmyadmin and sign in to confirm that PHP and MariaDB are running correctly

Debian

Since Debian Stretch, Debian has enabled the parallel install of multiple PHP versions using PHP-FM. However each release of Debian ships with a different default version and only that version is officially supported in that release. In order to install other versions such as PHP 5.6 and 7.4 you need to use the packages made available by the Debian Maintainer in his personal development repo. Check your version of Debian to determine what you need. LP Archaeology use this solution 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 adding PHP repo: https://packages.sury.org/php/README.txt. See also https://github.com/oerdnj/deb.sury.org/wiki/Managing-Multiple-Versions

Summary of install commands for PHP 7.4 current requirement:

sudo apt-get install build-essential git apache2 mariadb-client mariadb-server
sudo apt-get install php7.4 php7.4-apcu php7.4-apcu-bc php7.4-bcmath php7.4-bz2 php7.4-cli php7.4-common php7.4-fpm php7.4-gd \
  php7.4-geoip php7.4-imagick php7.4-intl php7.4-json php7.4-mbstring php7.4-mysql php7.4-opcache php7.1-readline php7.4-sqlite3 \
  php7.4-tidy php7.4-uuid php7.4-yaml php7.4-xml php7.4-zip phpmyadmin php-pear
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.4-fpm start
sudo systemctl enable  php7.4-fpm
sudo a2enconf php7.4-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 mysite
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://gitlab.com/arklab/arkserver.git

Alternatively download and unzip the file from https://gitlab.com/arklab/arkserver

Then run composer to install the required PHP libraries:

cd arkserver/
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, see above for instructions.

If not using vhosts, for local development, edit your Apache config to alias the site folder:

Alias /<site> /path/to/ark2/sites/<site>/web
<Directory /path/to/ark2/sites/<mysite>/web>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
</Directory>
http://localhost/<site>

To rebuild the frontend

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