2018年10月22日 星期一

TestLink setup on CentOS 7

#Install PostgreSQL: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-centos-7
# sudo yum install postgresql-server postgresql-contrib
# sudo postgresql-setup initdb
# sudo systemctl start postgresql
# sudo systemctl enable postgresql

https://dotblogs.com.tw/jovepaterlab/2017/04/17/222958
[root@localhost peter]# su - postgres
-bash-4.2$ psql -U postgres
psql (9.6.2)
Type "help" for help.

postgres=# ALTER USER postgres WITH PASSWORD 'password'
postgres-# \q
-bash-4.2$ exit
logout

Edit /var/lib/pgsql/data/pg_hba.conf
local    all             all                                    md5
host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5

https://www.tecmint.com/install-php-7-in-centos-7/
# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
# yum-config-manager --enable remi-php72
# yum install php php-mcrypt php-cli php-gd php-curl php-pgsql php-ldap php-zip php-fileinfo
# php -v

Enable Apache2
# systemctl start httpd
# systemctl enable httpd

Edit /etc/php.ini
session.gc_maxlifetime = 2400
max_input_vars = 3000
memory_limit = 256M
upload_max_filesize = 20M
max_execution_time = 120


Set MySQL password
mysqladmin -u root password password

# Copy Testlink source code
# wget -e use_proxy=yes -e https_proxy=jack_lin3.compal.com:3128 https://github.com/TestLinkOpenSourceTRMS/testlink-code/archive/testlink_1_9.zip
   47  unzip
# unzip testlink_1_9.zip -d /var/www/html/
# cd /var/www/html/
# ls
# mv testlink-code-testlink_1_9/ testlink/
# ls
# chown -R apache:apache testlink
mkdir  /var/testlink
mkdir /var/testlink/logs
mkdir /var/testlink/upload_area
chown apache:apache /var/testlink/logs
chown apache:apache /var/testlink/upload_area


Check firewall setting
https://linuxhint.com/list_open_ports_firewalld/
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-using-firewalld-on-centos-7

Add http service in firewall
# sudo firewall-cmd --zone=public --permanent --add-service=http

link1
link2
# sudo chcon -Rv --type httpd_sys_rw_content_t /var/www/html/testlink/gui/templates_c
##### chcon -Rv --type httpd_sys_rw_content_t /var/www/html/testlink
https://tripal.info/tutorials/v3.x/installation/server-setup/centos7
# setsebool -P httpd_can_network_connect_db on

Remove line 872~879
/install/sql/postgres/testlink_create_tables.sql
https://github.com/TestLinkOpenSourceTRMS/testlink-code/blob/testlink_1_9/install/sql/postgres/testlink_create_tables.sql


Open http:///testlink, Follow steps to install.

YOU NEED TO RUN MANUALLY Following Script on your DB CLIENT Application

/var/www/html/testlink/install/sql/postgres/testlink_create_udf0.sql


YOUR ATTENTION PLEASE:
To have a fully functional installation You need to configure mail server settings, following this steps

    copy from config.inc.php, [SMTP] Section into custom_config.inc.php.
    complete correct data regarding email addresses and mail server.


Installation was successful!
You can now log in to Testlink (using login name:admin / password:admin - Please Click Me!).

2018年10月18日 星期四

Deploying Flask App with mod_wsgi (Python3) in Ubuntu 1804

1. Install apache2
2. Install mod_wsgi
# sudo apt install libapache2-mod-wsgi-py3
3. Create a Python3 virtualenv with Flask installed
# mkvirtualenv -p $(which python3) flask
(flask)# pip install flask
4. Create a .wsgi file for project (put in project folder)
newsite.wsgi:

activate_this = '/home/jack/.virtualenvs/flask/bin/activate_this.py'
with open(activate_this) as file_:
    exec(file_.read(), dict(__file__=activate_this))
import sys
sys.path.insert(0, '/home/jack/Documents/Projects/newsite')
from app import app as application

5. Open Apache2 ports. Edit file /etc/apache2/ports.conf

Listen 4002

6. Create a file for new site in /etc/apache2/sites-available
newsite.conf:


    ServerName newsite

    WSGIDaemonProcess newsite user=jack group=jack threads=5
    WSGIScriptAlias / /home/jack/Documents/Projects/newsite/newsite.wsgi

   
        WSGIProcessGroup newsite
        WSGIApplicationGroup %{GLOBAL}
        Require all granted
   


7. Enable the newsite
# sudo a2ensite newsite
(a2dissite for disable)

8. Reload the Apache2
# sudo systemctl reload apache2

9. Allow port 4002 by ufw
# sudo ufw allow 4002
(sudo ufw delete allow 4002) to disable

10. Open broswer to browse http://:4002

Note1. Apache2 error log is in /var/log/apache2/error.log

Note2. If you are using open() in app.py, need to instead to app.open_resource() to prevent FileNotFoundException

Reference:
http://flask.pocoo.org/docs/1.0/deploying/mod_wsgi/
http://flask.pocoo.org/docs/0.12/api/#flask.Flask.open_resource