Difference between revisions of "ARK2/Install"

From ARK
Jump to: navigation, search
(Install)
(Debian Stable (Stretch))
 
(28 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 22: Line 22:
 
=== macOS ===
 
=== macOS ===
  
On macOS, while you can install the requirements via standalone packages, we recommend using HomeBrew as it makes installing and updating all the tools used easier.
+
On macOS, while you can install the requirements via standalone packages such as [https://www.mamp.info/en/ 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
+
* Install XCode from the App Store and run it to accept the license, or from the command line: <pre>sudo xcodebuild -license accept</pre>
* Install the Command Line Tools (includes Git)
+
* Check you have the Command Line Tools (including Git) installed and enabled: <pre>sudo xcode-select --install</pre>
* Download and install [http://brew.sh/ HomeBrew]
+
* Download and install [http://brew.sh/ HomeBrew]: <pre>/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"</pre>
* Modify your .profile to add brew packages to your $PATH <pre>export PATH=/usr/local/bin:/usr/local/sbin:$PATH</pre>
+
* Modify your ~/.profile file to add brew packages to your $PATH and to enable Git completion
* Install the required packages from Brew: <pre>brew install homebrew/php/composer homebrew/php/php-cs-fixer homebrew/php/php-code-sniffer homebrew/php/sqlformat homebrew/php/phplint</pre>
+
<pre> export PATH=/usr/local/bin:/usr/local/sbin:$PATH
* If you need to do front end development you will also need <pre>brew install node tidy-html5</pre>
+
source /Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash
* (Optional) Modify your .profile to enable command-line auto-complete
+
source /Library/Developer/CommandLineTools/usr/share/git-core/git-prompt.sh
 +
GIT_PS1_SHOWDIRTYSTATE=true
 +
PS1='\u@\h \W$(__git_ps1 " (%s)") \$ '
 +
</pre>
 +
* Source your modified ~/.profile file to start using it: <pre>source ~/.profile</pre>
 +
* Install the required packages from Brew:  
 +
<pre>
 +
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
 +
</pre>
 +
* Modify /usr/local/etc/httpd/httpd.conf to enable PHP-FPM, aliases, vhosts and rewrite by uncommenting the following lines:
 +
<pre>
 +
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
 +
</pre>
 +
* Add the following after the DocumentRoot section to enable PhpMyAdmin:
 
<pre>
 
<pre>
export HOMEBREW_GITHUB_API_TOKEN="token"
+
Alias /phpmyadmin /usr/local/share/phpmyadmin
source /Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash
+
<Directory /usr/local/share/phpmyadmin/>
source /Library/Developer/CommandLineTools/usr/share/git-core/git-prompt.sh
+
    Options Indexes FollowSymLinks MultiViews
GIT_PS1_SHOWDIRTYSTATE=true
+
    AllowOverride All
PS1='\u@\h \W$(__git_ps1 " (%s)") \$ '
+
    Require all granted
 +
</Directory>
 
</pre>
 
</pre>
 +
* Modify the DirectoryIndex section to appear as follows:
 +
<pre>
 +
#
 +
# DirectoryIndex: sets the file that Apache will serve if a directory
 +
# is requested.
 +
#
 +
<IfModule dir_module>
 +
    DirectoryIndex index.html index.php
 +
</IfModule>
  
The easiest way to run a webserver and database server is using [https://www.mamp.info/en/ MAMP]. Simply install MAMP and create a soft-link from the MAMP webroot to the location of your ARK git repository. The alternative is to use HomeBrew to configure and run your own install. The HomeBrew method is recommended for developing with PostgreSQL (TODO).
+
<IfModule proxy_fcgi_module>
* <pre>brew install homebrew/php/php71 homebrew/php/php71-tidy homebrew/php/php71-xdebug</pre>
+
    <FilesMatch ".+\.ph(ar|p|tml)$">
 
+
        SetHandler "proxy:fcgi://127.0.0.1:9000"
For QGIS Python:
+
    </FilesMatch>
* 'brew install python qt pyqt'
+
</IfModule>
* 'pip install pep8 autopep8 jedi pb_tool '
+
</pre>
 
+
* Start the required services:
TODO
+
<pre>
* xdebug setup
+
brew services start mariadb
* apache / php /mysql / mamp
+
brew services start php@7.4
* linter/fixer rulesets
+
brew services start httpd
 +
</pre>
 +
* 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 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 76: 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
  
 
Once ARK is installed (see below), configure Apache to serve the site, using either alias or symlink.
 
Once ARK is installed (see below), configure Apache to serve the site, using either alias or symlink.
  
sudo vim /etc/apache2/sites-available/dime.conf
+
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>
 
   <VirtualHost *:80>
       ServerName dime2.lparchaeology.com
+
       ServerName mysite.example.com
       ServerAdmin sysadmin@lparchaeology.com
+
       ServerAdmin admin@example.com
       DocumentRoot /srv/www/lib/ark2/sites/dime/web
+
       DocumentRoot /srv/www/lib/ark2/sites/mysite/web
 
       DirectoryIndex index.html index.php
 
       DirectoryIndex index.html index.php
 
       LogLevel warn
 
       LogLevel warn
       ErrorLog /srv/www/lib/ark2/sites/dime/web/var/logs/error.log
+
       ErrorLog /path/to/logs/<site>/error.log
       CustomLog /srv/www/lib/ark2/sites/dime/web/var/logs/access.log combined
+
       CustomLog /path/to/logs/<site>/access.log combined
       <Directory "/srv/www/lib/ark2/sites/dime/web">
+
       <Directory "/srv/www/lib/ark2/sites/mysite/web">
 
           Options FollowSymLinks
 
           Options FollowSymLinks
 
           Require all granted
 
           Require all granted
Line 104: Line 159:
 
   </VirtualHost>
 
   </VirtualHost>
  
  sudo a2ensite dime
+
  sudo a2ensite mysite
 +
 
 +
sudo apache2ctl -t
 +
 
 +
sudo systemctl reload apache2
  
  systemctl reload apache2
+
  sudo apache2ctl -S
  
 
== Install ==
 
== Install ==
  
To install using git:
+
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 /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 133: Line 194:
 
  less sites/servers.json
 
  less sites/servers.json
  
If you need tyo add different server details:
+
If you need to add different server details:
  
 
  ./bin/sysadmin database:server:add
 
  ./bin/sysadmin database:server:add
Line 146: Line 207:
 
  vim sites/<site>/config/site.json
 
  vim sites/<site>/config/site.json
  
If not using vhosts, for local development you can symlink the site
+
If using vhosts, see above for instructions.
cd ..
+
 
  ln -s sites/<site>/web  /Applications/MAMP/htdocs/<site>
+
If not using vhosts, for local development, edit your Apache config to alias the site folder:
  http://localhost:8888/<site>
+
 
 +
  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
 
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>