Professional Documents
Culture Documents
REX – RTM
Installation Guide
Proposed by
PRXSION Technologies Pvt. Ltd.
Installation Guide
Contents
1. Introduction ...............................................................................................3
Hardware Prerequisites .............................................................................................................3
Software Prerequisites ..............................................................................................................3
2. Installing Python ..........................................................................................4
Step 1: Install Python Dependencies .........................................................................................4
Step 2: Download Python 3.8 Archive .......................................................................................4
Step 3: Install Python3.8 ............................................................................................................5
Step 4: Verify Installation ...........................................................................................................6
3. Installing Apache Web Server ...........................................................................7
Step 1: Install Apache ................................................................................................................7
Step 2: Activate Apache .............................................................................................................7
Step 3: Verify Apache Service ................................................................................................... 7
Step 4: Checking your Web Server ...........................................................................................7
Step 5: Managing the Apache Process .....................................................................................9
4. Installing mod_wsgi .....................................................................................11
5. Installing PostgreSQL....................................................................................11
Step 1: Install PostgreSQL .......................................................................................................11
Step 2: Configure PostgreSQL ................................................................................................ 13
Step 3: Access the PostgreSQL Shell .....................................................................................13
Step 4: Create a Database ......................................................................................................14
Step 5: Connect to a Database ............................................................................................... 14
Step 6: Secure PostgreSQL ....................................................................................................14
6. Installing PHP ............................................................................................16
Step 1: Enable EPEL repository .............................................................................................. 16
Step 2: Install PHP .................................................................................................................. 17
Step 3: Verify Installation .........................................................................................................17
7. Installing Redis ...........................................................................................19
Step 1: Install Redis................................................................................................................. 19
Step 2: Securing Redis ............................................................................................................20
8. Setup REX-RTM ...........................................................................................21
Step 1: Setup Model Server ....................................................................................................21
Step 1.1: Installing Celery ........................................................................................................26
Step 1.2 Installing Flower ........................................................................................................26
Step 1.3: Setup Supervisor ......................................................................................................26
1
Installation Guide
2
Installation Guide
1. Introduction
Hardware Prerequisites
Software Prerequisites
Before we begin with the installation, let’s make sure to update the default system
applications to have the latest versions available.
Let’s first make sure that yum is up to date by running this command:
The -y flag is used to alert the system that we are aware that we are making changes,
preventing the terminal from prompting us to confirm.
Next, we will install yum-utils, a collection of utilities and plugins that extend and
supplement yum:
Finally, we’ll install the CentOS Development Tools, which are used to allow you
to build and compile software from source code:
3
Installation Guide
If your Firewall is active you should execute the following commands in order to allow
HTTP and HTTPS ports:
sudo firewall-cmd --zone=public —add-port=80/tcp
sudo firewall-cmd --zone=public —add-port=22/tcp
sudo firewall-cmd --zone=public —-add-port=443/tcp
sudo firewall-cmd --zone=public —-add-port=8080/tcp
sudo firewall-cmd --zone=public —-add-port=8181/tcp
sudo firewall-cmd --zone=public —-add-port=5432/tcp
sudo firewall-cmd --zone=public —-add-port=6379/tcp
sudo firewall-cmd --zone=public —-add-port=5555/tcp
We can verify that this was successful using the --list-ports operation:
mkdir /root/downloads
4
Installation Guide
cd /root/downloads
wget https://www.python.org/ftp/python/3.8.3/
Python-3.8.3.tgz
cd Python-3.8*/
source ~/.bashrc
5
Installation Guide
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-19.2.3 setuptools-41.2.0
[root@rex-uat-1 Python-3.8.3]#
In order to ensure that Python 3.8 is in fact installed and useable, we can check by
running the following command:
python3.8 —version
pip3.8 —version
You may want to upgrade Pip to ensure you have the latest version:
6
Installation Guide
The system should download and install the Apache software packages.
2. Next, set the Apache service to start when the system boots:
Display information about Apache, and verify it’s currently running with:
7
Installation Guide
You can access the default Apache landing page to confirm that the software is running
properly through your IP address. If you do not know your server’s IP address, you can
get it a few different ways from the command line.
Type this at your server’s command prompt:
hostname -I
This command will display all of the host’s network addresses, so you will get back a
few IP addresses separated by spaces. You can try each in your web browser to see if
they work.
ip addr show
When you have your server’s IP address, enter it into your browser’s address bar:
8
Installation Guide
http://your_server_ip
9
Installation Guide
If you are simply making configuration changes, Apache can often reload without
dropping connections. To do this, use this command:
By default, Apache is configured to start automatically when the server boots. If this is
not what you want, disable this behaviour by typing:
Apache will now start automatically when the server boots again.
The default configuration for Apache will allow your server to host a single website. If
you plan on hosting multiple domains on your server, you will need to configure virtual
hosts on your Apache web server.
10
Installation Guide
4. Installing mod_wsgi
mod_wsgi-express module-config
You can use the output of this command to configure httpd.conf to load mod_wsgi
module
WSGISocketPrefix /var/run/wsgi
Save and exit the httpd.conf file
5. Installing PostgreSQL
11
Installation Guide
Install PostgreSQL:
yum install postgresql11-server postgresql11 -y
# instell
yum install postgresql11-contrib
12
Installation Guide
By default, PostgreSQL will create a Linux user named postgres to access the
database software.
Issue the following commands to set a password for the postgres database user. Be
sure to replace newpassword with a strong password and keep it in a secure place:
su - postgres
Note that this user is distinct from the postgres Linux user. The Linux user is used to
access the database, and the PostgreSQL user is used to perform administrative tasks
on the databases.
The password set in this step will be used to connect to the database via the network.
Peer authentication will be used by default for local connections.
psql postgres
This will log you in as the postgres database user. You’ll see a prompt similar to this:
psql (11.8)
Type "help" for help.
postgres=#
13
Installation Guide
In the last line, postgres=# indicates the name of the current database. To see a list of
available commands, type \h. You may find more information on a specific command by
adding it after \h. Once you’ve finished using the shell, you can exit with \q.
psql rex
You will see the following output:
psql (11.8)
Type "help" for help.
rex=#
Type \q to exist postgres shell and then exit to exit su bash shell.
14
Installation Guide
Edit the /var/lib/pgsql/11/data/pg_hba.conf file, under the # "local" is for Unix domain
socket connections only header:
# "local" is for Unix domain socket connections only
local all all peer
Replace peer with md5 on this line to activate password authentication using an MD5
hash.
You will be prompted to enter the password for the postgres user and then given psql
shell access to the database.
15
Installation Guide
6. Installing PHP
PHP 7.1 is not provided by the official RHEL repository so you have to add “Webtatic”
repo in order to install it easily.
16
Installation Guide
yum repolist
php -v
Apache web Server is installed on your system as a dependency for PHP, start its
service using below systemctl command:
Now create a info.php file under /var/www/html, run the following command to create
the file’s contents:
Use the path noted above to load the module into Apache by adding the following
snippet to the bottom of the /etc/httpd/conf/httpd.conf:
17
Installation Guide
18
Installation Guide
PHP 7.3.25
104 sudo dnf install dnf-utils http://rpms.remirepo.net/
enterprise/remi-release-8.rpm
105 sudo dnf module list php
106 sudo dnf module reset php
107 sudo dnf module enable php:remi-7.3
108 sudo dnf install php php-opcache php-gd php-curl php-
mysqlnd
109 sudo systemctl enable --now php-fpm
110 php -v
7. Installing Redis
Step 1: Install Redis
Install Redis using yum:
19
Installation Guide
If you’d like Redis to start on boot, you can enable it with the enable command:
Once you’ve confirmed that Redis is indeed running, test the setup with this command:
redis-cli ping
This should print PONG as the response. If this is the case, it means you now have
Redis running on your server and we can begin configuring it to enhance its security.
Locate the line beginning with bind and make sure it’s uncommented:
# /etc/redis.conf
bind 127.0.0.1
If you need to bind Redis to another IP address (as in cases where you will be
accessing Redis from a separate host) we strongly encourage you to bind it to a
private IP address. Binding to a public IP address increases the exposure of your Redis
interface to outside parties.
Since a default standalone installation of Redis server is listening only on the loopback
interface (127.0.0.1 or localhost), there should be no concern for incoming traffic on its
default port.
20
Installation Guide
8. Setup REX-RTM
Once you are in the directory where you would like the environments to live, you can
create an environment by running the following command:
Essentially, this command creates a new directory (in this case called venv)
21
Installation Guide
To use this environment, you need to activate it, which you can do by typing the
following command that calls the activate script in the bin directory:
source venv/bin/activate
Your prompt will now be prefixed with the name of your environment, in this case it is
called venv.
Look for activate_this.py in venv/bin/ folder. activate_this.py will be used in wsgi file
to activate the virtual environment. If you don’t find the file in the location, we need to
create one by copy-paste below content in a file called /venv/bin/activate_this.py:
22
Installation Guide
import os
import site
import sys
try:
abs_file = os.path.abspath(__file__)
except NameError:
raise AssertionError("You must use
exec(open(this_file).read(), {'__file__': this_file}))")
bin_dir = os.path.dirname(abs_file)
base = bin_dir[: -len("bin") - 1] # strip away the bin part
from the __file__, plus the path separator
sys.real_prefix = sys.prefix
sys.prefix = base
You might want to update pip3 utility to its latest version. Use below command to
upgrade pip3:
23
Installation Guide
To leave the environment, simply type the command deactivate and you’ll return to your
original directory.
Configure mod_wsgi
Now that mod_wsgi has been installed, let’s take a look at the configuration. We will be-
gin by creating a basic Python web application to detail the steps to configure mod_ws-
gi.
activate_this ='/var/www/rexrtmapi/venv/bin/
activate_this.py'
exec(open(activate_this).read())
sys.stdout = sys.stderr
sys.path.insert(0, '/var/www/rexrtmapi/venv/lib/python3.8/
site-packages')
sys.path.insert(0, ‘/var/www/rexrtmapi/venv/lib64/
python3.8/site-packages')
sys.path.append('/var/www/rexrtmapi')
from rexrtmapi import create_app
application, socketio = create_app()
24
Installation Guide
cd /var/www/rexrtmapi
git clone https://github.com/sarabjeethanspal/rexrtmapi.git
Execute the following command one by one to set the proper permissions:
sudo chown -R apache:apache /var/www/rexrtmapi
sudo chmod -R 755 /var/www/rexrtmapi
setenforce 0
Write the file to the following path replacing domain.com with your domain:
/etc/httpd/conf.d/rexrtmapi.conf
The contents of the file will be as follows, replacing domain.com with your domain:
<VirtualHost *:8080>
ServerName 46.101.210.238:8080
WSGIDaemonProcess rexrtmapi user=apache group=apache
threads=5
WSGIScriptAlias / /var/www/rexrtmapi/rexrtmapi.wsgi
process-group=rexrtmapi application-group=%{GLOBAL}
WSGIPassAuthorization on
<Directory /var/www/rexrtmapi>
Require all granted
</Directory>
</VirtualHost>
25
Installation Guide
To install supervisor on CentOS 7, you need epel repository which can be added using
the commands. If you have already installed epel-release in previous section, please
ignore:
26
Installation Guide
# cat /etc/supervisord.d/celery.ini
[program:celery]
command=/var/www/rexapi/venv/bin/celery -A
celery_worker.celery worker —loglevel=info
directory=/var/www/rexrtmapi
user=root
numprocs=1
stdout_logfile=/var/log/celery/celery.log
stderr_logfile=/var/log/celery/celery.log
autostart=true
autorestart=true
priority=999
Once all the changes have been made, start the supervisord daemon:
If you check on its status, you should see the commands specified on our configuration
files executed:
Supervisor also provides a command line tool called supervisorctl which allows you to
control the processes that are currently managed by supervisord:
To restart, use:
27
Installation Guide
For installing the latest version of Laravel we need to get the Composer dependency
manager:
cd /root/downloads
curl -sS https://getcomposer.org/installer | php
Execute the following command to move your Composer binary file to the executable
path:
mv /root/downloads/composer.phar /usr/local/bin/composer
chmod +x /usr/local/bin/composer
Now you can run the command below to download and install Laravel directly into your
Apache document root:
28
Installation Guide
<VirtualHost *:8080>
ServerName rexrtmapp
DocumentRoot /var/www/rexrtmapp/public
<Directory /var/www/rexrtmapp/public>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/rexrtmapp-error_log
CustomLog /var/log/httpd/rexrtmapp-access_log combined
</VirtualHost>
Save and exit.
Open port 8080. Find “Listen 80” in /etc/httpd/conf/httpd.conf. Add following line
below “Listen 80”:
Listen 8080
Syntax OK
Execute the following command one by one to set the proper permissions:
sudo chown -R apache:apache /var/www/rexrtmapp
sudo chmod -R 755 /var/www/rexrtmapp/storage
setenforce 0
29
Installation Guide
30
Installation Guide
31
Installation Guide
Contact Us
info@prxsion.com
+91 99303 17670
Request more information or for any other reason we look forward to hearing from you
soon.
32