Skip to content

Instantly share code, notes, and snippets.

@scollazo
Last active November 17, 2019 16:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scollazo/7a13dbea3ea88f8d7463befa4e996d0d to your computer and use it in GitHub Desktop.
Save scollazo/7a13dbea3ea88f8d7463befa4e996d0d to your computer and use it in GitHub Desktop.

RedHat 7.5 and AtoM 2.4.x/2.5.x install

Install prerequisites

  • Enable epel repo and software collections
    sudo -u root yum install -y epel-repo 
    <centos> sudo -u root yum install -y centos-release-scl
    <rhel> sudo -u root yum-config-manager --enable rhel-server-rhscl-7-rpm
    <rhel> sudo subscription-manager repos --enable=rhel-7-server-optional-rpms

  • Install common tools
    sudo -u root yum install -y wget git git nodejs make gcc http-parser python-pip python-setuptools 
  • ElasticSearch

    • Install ES repository:

    Atom 2.4:

sudo -u root rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
sudo -u root bash -c 'cat << EOF > /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-1.7]
name=Elasticsearch repository for 1.7 packages
baseurl=https://packages.elastic.co/elasticsearch/1.7/centos
gpgcheck=1
gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1
EOF'

Atom 2.5:

sudo -u root rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
sudo -u root bash -c 'cat << EOF > /etc/yum.repos.d/elasticsearch-5.repo
[elasticsearch-5]
name=Elasticsearch repository for 5.X packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
EOF'
  • Install and enable services
    sudo -u root yum install -y java-1.8.0-openjdk-headless elasticsearch                      
    sudo -u root systemctl enable elasticsearch
    sudo -u root systemctl start elasticsearch
  • Gearmand
   sudo -u root yum install -y gearmand
   sudo -u root systemctl enable gearmand
   sudo -u root systemctl start gearmand
  • Memcached
   sudo -u root yum install -y memcached
   sudo -u root systemctl enable memcached
   sudo -u root systemctl start memcached
  • MariaDB
    sudo -u root yum install -y mariadb-server
    sudo -u root systemctl enable mariadb
    sudo -u root systemctl start mariadb
  • Nginx
     sudo -u root yum install -y nginx

Create the file /etc/nginx/conf.d/atom.conf with the following content:

  upstream atom {
       server unix:/run/php7.0-fpm.atom.sock;
  }

  server {

  listen 80;
  root /usr/share/nginx/atom;

  # http://wiki.nginx.org/HttpCoreModule#server_name
  # _ means catch any, but it's better if you replace this with your server
  # name, e.g. archives.foobar.com
  server_name _;

  client_max_body_size 72M;

  # http://wiki.nginx.org/HttpCoreModule#try_files
  location / {
    try_files $uri /index.php?$args;
  }

  location ~ /\. {
    deny all;
    return 404;
  }

  location ~* (\.yml|\.ini|\.tmpl)$ {
    deny all;
    return 404;
  }

  location ~* /(?:uploads|files)/.*\.php$ {
    deny all;
    return 404;
  }

  location ~* /uploads/r/(.*)/conf/ {

  }

  location ~* ^/uploads/r/(.*)$ {
    include /etc/nginx/fastcgi_params;
    set $index /index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$index;
    fastcgi_param SCRIPT_NAME $index;
    fastcgi_pass atom;
  }

  location ~ ^/private/(.*)$ {
    internal;
    alias /usr/share/nginx/atom/$1;
  }

  location ~ ^/(index|qubit_dev)\.php(/|$) {
    include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    fastcgi_pass atom;
  }

  location ~* \.php$ {
    deny all;
    return 404;
  }

}

Install PHP

  • Install PHP 7.0 from Software Collections:
sudo -u root yum install -y rh-php70-php-cli rh-php70-php-ldap rh-php70-php-fpm  \
rh-php70-php-mysqlnd rh-php70-php-xml rh-php70-php-opcache rh-php70-php-devel \
rh-php70-php-pear rh-php70-php-mbstring zlib-devel unzip \    
  • Build and install PHP Apcu module
 sudo -u root bash -c '/opt/rh/rh-php70/root/bin/pecl install apcu_bc-beta && \
              printf "extension=apcu.so\nextension=apc.so\n" > /etc/opt/rh/rh-php70/php.d/20-apcu_bc.ini'
  • Build and install memcache php module
wget https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.zip
unzip NON_BLOCKING_IO_php7.zip
cd pecl-memcache-NON_BLOCKING_IO_php7/
sudo -u root bash -c " \
export PATH=/opt/rh/rh-php70/root/bin:$PATH
phpize && \
./configure --enable-memcache && \
make && \
cp modules/memcache.so \
/opt/rh/rh-php70/root/usr/lib64/php/modules/memcache.so && \
printf "extension=memcache.so\n" >> /etc/opt/rh/rh-php70/php.d/20-memcache.ini
 ";
  • Configure PHP

    • Remove the default configuration
       sudo -u root rm /etc/opt/rh/rh-php70/php-fpm.d/www.conf 
    
    • Create a new config file in /etc/opt/rh/rh-php70/php-fpm.d/www.conf with the following content:
[atom]

; The user running the application
user = nginx
group = nginx

; Use UNIX sockets if Nginx and PHP-FPM are running in the same machine
listen = /run/php7.0-fpm.atom.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0600

; The following directives should be tweaked based in your hardware resources
pm = dynamic
pm.max_children = 30
pm.start_servers = 10
pm.min_spare_servers = 10
pm.max_spare_servers = 10
pm.max_requests = 200

chdir = /

; Some defaults for your PHP production environment
; A full list here: http://www.php.net/manual/en/ini.list.php
php_admin_value[expose_php] = off
php_admin_value[allow_url_fopen] = on
php_admin_value[memory_limit] = 512M
php_admin_value[max_execution_time] = 120
php_admin_value[post_max_size] = 72M
php_admin_value[upload_max_filesize] = 64M
php_admin_value[max_file_uploads] = 10
php_admin_value[cgi.fix_pathinfo] = 0
php_admin_value[display_errors] = off
php_admin_value[display_startup_errors] = off
php_admin_value[html_errors] = off
php_admin_value[session.use_only_cookies] = 0

; APC
php_admin_value[apc.enabled] = 1
php_admin_value[apc.shm_size] = 64M
php_admin_value[apc.num_files_hint] = 5000
php_admin_value[apc.stat] = 0

; Zend OPcache
php_admin_value[opcache.enable] = 1
php_admin_value[opcache.memory_consumption] = 192
php_admin_value[opcache.interned_strings_buffer] = 16
php_admin_value[opcache.max_accelerated_files] = 4000
php_admin_value[opcache.validate_timestamps] = 0
php_admin_value[opcache.fast_shutdown] = 1

; This is a good place to define some environment variables, e.g. use
; ATOM_DEBUG_IP to define a list of IP addresses with full access to the
; debug frontend or ATOM_READ_ONLY if you want AtoM to prevent
; authenticated users
env[ATOM_DEBUG_IP] = "10.10.10.10,127.0.0.1"
env[ATOM_READ_ONLY] = "off"
  • Enable and start php
systemctl enable rh-php70-php-fpm
systemctl start rh-php70-php-fpm

Atom dependencies

  • Install rpmfusion repository (needed for ffmpeg):
sudo -u root yum localinstall -y --nogpgcheck \
https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm \
https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm
  • Install atom required packages
    sudo -u root yum install -y ImageMagick ghostscript poppler-utils ffmpeg fop 
  • Install atom required pip packages
    sudo -u root pip install sphinx 
    sudo -u root pip install sphinxcontrib-httpdomain
    sudo -u root pip install sphinx_rtd_theme
  • Install atom required node packages
   sudo -u root npm install -g "less@<2.0.0"

Atom install

  • Create the folder where atom will be installed
sudo mkdir /usr/share/nginx/atom
  • Clone atom code

Atom 2.4:

sudo git clone -b stable/2.4.x http://github.com/artefactual/atom.git \
/usr/share/nginx/atom

Atom 2.5:

sudo git clone -b stable/2.5.x http://github.com/artefactual/atom.git \
/usr/share/nginx/atom
  • Build atom CSS
cd /usr/share/nginx/atom
sudo -u root make -C /usr/share/nginx/atom/plugins/arDominionPlugin
  • Create database and user:
sudo -u root mysql -h localhost -u root -p -e "CREATE DATABASE atom CHARACTER SET utf8 
COLLATE utf8_unicode_ci;"
sudo -u root mysql -h localhost -u root -p -e "GRANT ALL ON atom.* TO 'atom'@'localhost'  IDENTIFIED BY '12345';"
  • Change permissinos for atom folder
sudo chown -R nginx:nginx /usr/share/nginx/atom
sudo chmod o= /usr/share/nginx/atom

Atom worker

  • Create the file /usr/lib/systemd/system/atom-worker.service using the following content:
[Unit]
Description=AtoM worker
After=network.target

[Install]
WantedBy=multi-user.target

[Service]
Type=simple
User=nginx
Group=nginx
env[PATH] = /opt/rh/rh-php70/root/bin/:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin
WorkingDirectory=/usr/share/nginx/atom
ExecStart=/opt/rh/rh-php70/root/bin/php -d memory_limit=-1 -d error_reporting="E_ALL" symfony jobs:worker
ExecStop=/bin/kill -s TERM $MAINPID
Restart=no
  • Enable and start it with
systemctl enable atom-worker
systemctl start atom-worker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment