Setup Utilities and Components ============================== The following components are optional. It is recommended that you install all these components to achieve satisfactory performance of the system. Install documentation and help ------------------------------ Documentation is a part of the project and is written in reStructured text. This is published via `sphinx-doc `_. Please open a ssh terminal to the server and execute the following commands to install `pip` and `sphinx-doc`. :: $ sudo apt-get install python-pip $ sudo pip install Sphinx Compile the source documentation to html. First create a folder for html output. :: $ cd /opt/coreERP #Or you can select any target folder $ sudo mkdir coredocs Move to the source directory and build output. :: $ cd /opt/coreERP/docs $ sphinx-build -b html . /opt/coreERP/coredocs/ Now create a linked folder in apache and publish the documentation. :: $ cd /var/www/html $ sudo ln -s /opt/coreERP/coredocs docs :Tests: Open a browser from your local node and browse at ``http:///docs`` Install Mail Sender Utility --------------------------- All automated mails in coreERP are dispatched by the *Mail Sender* utility. This utility is installed as an Ubuntu Service that starts automatically upon machine start. In Ubuntu 14.04 LTS this is handled by a utility called *Upstart*. Open a ssh terminal to the server and type the following :: $ sudo nano /etc/init/coreERP-mailer.conf Copy the following code into the .conf file with changes to /path/to/coreERP (ensure that this reflects the proper path that you used for download of source) :: description "CoreERP auto mailer service" author "coreERP" start on runlevel [2345] stop on shutdown respawn script sudo php /path/to/coreERP/CoreWebApp/yii mailer/mail/sendmail sleep 30s end script Rember to change the /path/to/coreERP to reflect the proper path of coreERP installed on the local drive. Save and close (ctrl+o), (ctrl+x). This script would ensure that everytime your server is restarted, the script would automatically start. To ensure that it starts automatically with every reboot :: $ sudo initctl start coreERP-mailer If you run into any problems, look into the log file situated in /var/log/upstart/coreERP-mailer.log. In Ubuntu 16.04 LTS this is handled by a utility called *Systemd*. Open a ssh terminal to the server and type the following :: $ sudo nano /etc/systemd/system/coreERP-mailer.service Copy the following code into the .conf file with changes to /path/to/coreERP (ensure that this reflects the proper path that you used for download of source) :: [Unit] Description=CoreERP auto mailer service [Service] ExecStart=/usr/bin/php /path/to/coreERP/CoreWebApp/yii mailer/mail/sendmail User=root Restart=always RestartSec=30 [Install] WantedBy=multi-user.target Rember to change the /path/to/coreERP to reflect the proper path of coreERP installed on the local drive. Save and close (ctrl+o), (ctrl+x). This script would ensure that everytime your server is restarted, the script would automatically start. To ensure that it starts automatically with every reboot :: $ sudo systemctl enable coreERP-mailer $ sudo systemctl start coreERP-mailer To verify the status, type :: $ sudo service coreERP-mailer status If you run into any problems, look into the log file situated in /var/log/syslog Install Backup Utility ---------------------- All CoreERP data is stored in postgreSQL databases. It is very important to take backup of these databases and store them securely. In case of any data loss caused due to a hardware failure or for reasons unknown, the database backup is the only assured mode of retreiving data with minimalistic loss. CoreERP has a console based utility that can be setup to automate the tasks of database backup. This utility can be scheduled in pgAgent. Let us first install pgAgent .. _installpgAgent: Installing pgAdmin and pgAgent ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ On your Ubuntu node, you can install pgAdmin III via the *Ubuntu Software Center*. Open the software center and search for **pgAdmin**. Click on install. After successful installation, start **pgAdmin** from the desktop. Click on the **plug** icon to connect to a new server. Fill the properties as required. Mention your server hostname/ip and the authentication infromation for user *postgres*. If successful, it should connect to the server and display postgres database. - Select the *postgres* database in the *Databases* node and click on *SQL* icon. It will open a new sql window. - Click on *Open File* and select pgagent.sql file in ``/usr/share/pgadmin3`` - Click on *Execute Query* to create the pgagent objects on the server Open a ssh terminal to the server and type the following command to install pgAgent :: $ sudo apt-get install pgagent Let us start the **pgAgent** deamon. Follow the steps carefully. 1. Create a script file in */etc/systemd/system* as follows :: $ sudo nano /etc/systemd/system/pgagent.service Copy the following contents into that script file. The **hostaddr** and **PGPASSWORD** are two important variables. Please set the values based on the server you want to connect and the postgres password that was set while installing postgreSQL. :: [Unit] Description=pgAgent Service Requires=postgresql.service [Service] Type=oneshot Environment=PGPASSWORD=YOUR_PASSWORD ExecStart=/usr/bin/pgagent hostaddr=127.0.0.1 dbname=postgres user=postgres RemainAfterExit=on [Install] WantedBy=multi-user.target Remember to change **YOUR_PASSWORD** in the file before save. Save (ctrl+o), Enter, Exit(ctrl+X) 2. Reload systemctl :: $ sudo systemctl daemon-reload 3. Start the service :: $ sudo systemctl start pgagent.service This should start the pgAgent as a deamon. To autostart after every reboot, run the following: :: $ sudo systemctl enable pgagent.service Creating and scheduling Backup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Return to your node and reconnect/refresh pgAdmin. It will now display a new **jobs** node. - Click on the **jobs** node and create a new job. Refer `pgAgent Jobs Help `_ on how to create a new pgAgent job. - The job step must be a **Batch** step with the following *definition* :: php /opt/coreERP/CoreWebApp/yii utils/dbutil/backup - To ceanup and discard old files, you can create the following additional step :: php /opt/coreERP/CoreWebApp/yii utils/dbutil/agefile Your cwfconfig.php script should include the following items: :: 'dbBackup' => [ 'compress' => 'singleFile', 'path' => '/path/to/dbbackup/' ], The compress attribute accepts one of the following options: - **none** - each database backup would be stored as sql file without any compression in a subfolder named by the database. - **singleFile** - all backups would be compressed (using Gzip) into a single *tar.gz* file within the backup folder - **multiFile** - each database backup would be compressed seperately using Gzip and stored in a subfolder named by the database. Modify the **/path/to/** a folder on the server with appropriate access previleges and sufficient space for storage. This should preferably be a seperate drive mounted on the server or a network path via nfs. CoreERP Session Management -------------------------- Session management and cleanup of cached user files can be managed via a service in pgAgent. This utility is installed by default as part of the main system. To install pgAgent, follow the steps mentioned in :ref:`installpgAgent`. If you have already installed and configured pgAgent, proceed with the following steps. - Create a new job in pgAgent using pgAdmin. Refer `pgAgent Jobs Help `_ on how to create a new pgAgent job. - Schedule the job for every minute or every 5 minutes. - In job step, select **Batch** and enter the following *definition* :: php /opt/coreERP/CoreWebApp/yii utils/session/killexpired '/path/to/cwf.xconfig' :Note: If you have installed CoreERP in a virtual path, then mention the appropriate source path that leads to *CoreWebApp* and *cwf.xconfig*. The default setting is to invalidate a session without activity for 20 minutes. All cached files are also removed upon session logout by this service. The service requires access to the files and folders on the server inside web/reportcache. Hence, it would run under higher previlege account used by pgAgent. Install ClamAV (Antivirus) -------------------------- Linux system are not usually prone to viruses. However, any system that allows for file uploads could possibly act as a intermediary to transfer infected files from one user to another. It is therefore recommended to use a Antivirus package on the server. We recommend using ClamAV as it is Open Source and under active development. It does not repair infected files and does not conduct realtime file scans. Hence, there is minimum overhead on the server. :: $ sudo apt-get install clamav clamav-daemon $ sudo freshclam -- This will get the latest virus definitions $ sudo service clamav-daemon start -- This will start the daemon In the cwfconfig of the application, you can enable fileAVScan :: 'fileAVScan' => [ 'class' => 'app\cwf\vsla\utils\ClamScan', 'tmpPath' => '/opt/scan/' //Ensure that daemon or www-data has access to this folder. also include user: clamav in the daemon/www-data group ], Install ImageMagick (for Captcha) --------------------------------- Certain forms in the application use Captcha for additional security. This helps bots/scripts from hitting the server. A dependency of captcha is ImageMagick. To install php libraries for ImageMagick, :: $ sudo apt-get install php-imagick $ sudo systemctl restart apache2.service Generate phpinfo() output and verify that it displays imagick module. Reset admin password -------------------- To reset the admin password, run the following command :: php yii installer/install/changesu This command will change the admin password to the one mentioned in the cwfconfig file.