Difference between revisions of "ARK2/Install"

From ARK
Jump to: navigation, search
(Install)
(Debian Stable (Stretch))
 
(51 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>
 +
Alias /phpmyadmin /usr/local/share/phpmyadmin
 +
<Directory /usr/local/share/phpmyadmin/>
 +
    Options Indexes FollowSymLinks MultiViews
 +
    AllowOverride All
 +
    Require all granted
 +
</Directory>
 +
</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>
 +
 
 +
<IfModule proxy_fcgi_module>
 +
    <FilesMatch ".+\.ph(ar|p|tml)$">
 +
        SetHandler "proxy:fcgi://127.0.0.1:9000"
 +
    </FilesMatch>
 +
</IfModule>
 +
</pre>
 +
* Start the required services:
 
<pre>
 
<pre>
export HOMEBREW_GITHUB_API_TOKEN="token"
+
brew services start mariadb
source /Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash
+
brew services start php@7.4
source /Library/Developer/CommandLineTools/usr/share/git-core/git-prompt.sh
+
brew services start httpd
GIT_PS1_SHOWDIRTYSTATE=true
 
PS1='\u@\h \W$(__git_ps1 " (%s)") \$ '
 
 
</pre>
 
</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 ===
 +
 +
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
  
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).
+
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
* <pre>brew install homebrew/php/php71 homebrew/php/php71-tidy homebrew/php/php71-xdebug</pre>
 
  
For QGIS Python:
+
Summary of install commands for PHP 7.4 current requirement:
* 'brew install python qt pyqt'
 
* 'pip install pep8 autopep8 jedi pb_tool '
 
  
TODO
+
sudo apt-get install build-essential git apache2 mariadb-client mariadb-server
* xdebug setup
 
* apache / php /mysql / mamp
 
* linter/fixer rulesets
 
  
=== Debian Jessie ===
+
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 -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
 
sudo apt-get install build-essential git nodejs php-codesniffer php5-intl libsodium13
 
 
  curl -sS https://getcomposer.org/installer -o composer-setup.php
 
  curl -sS https://getcomposer.org/installer -o composer-setup.php
 
  php composer-setup.php --install-dir=/usr/local/bin --filename=composer
 
  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 ==
 
== Install ==
  
  git clone git@github.com:lparchaeology/ark2.git
+
To install using git, create the folder where the library code will be located, then clone the ARK2 repository.
  cd ark2/
+
 
 +
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
 
  composer install
 
  <may need github token...>
 
  <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
 
  cd build
 
  npm install
 
  npm install
  ./build env:install
+
  ./build frontend:all <frontend>
<build frontend if needed>
 
cd ../bin
 
./sysadmin site:create <site>
 
<fix database load!>
 
cd ..
 
ln -s sites/<site>/web  /Applications/MAMP/htdocs/<site>
 
http://localhost:8888/<site>
 

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>