2022/06/27

安裝project-open

project-open 有提供 docker image,也可以直接安裝,以下記錄安裝 project-open 的過程。

CentOS7

參考網頁

http://www.project-open.com/en/install-rhel-7

  1. system tools

    timedatectl set-timezone Asia/Taipei
    
    yum -y install system-config-*
    
    yum -y group install "System Administration Tools" --setopt=group_package_types=mandatory,default,optional
  2. KDE Plasma Workspaces Install "KDE Plasma Workspaces" Graphical Environment GNOME 3 on CentOS 7 has a number of important issues, so the ]po[ team recommends to switch to KDE:

    #yum -y group install "KDE Plasma Workspaces" "X Window System"
    #yum -y group install "Graphical Administration Tools" --setopt=group_package_types=mandatory,default,optional
    yum -y install net-tools setools policycoreutils-python
    #ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target
  3. Development Tools

    yum -y group install "Development Tools" --setopt=group_package_types=mandatory,default,optional
    yum -y group install "Compatibility Libraries"
    yum -y install vim emacs-nox
    yum -y install cvs svn git wget libXaw expat expat-devel pango graphviz graphviz-devel ImageMagick
    yum -y install libdbi-dbd-pgsql openldap-clients openldap-devel mlocate sharutils psmisc
  4. Perl Libraries

    yum -y install graphviz-perl perl perl-Archive-Tar perl-Archive-Zip perl-CGI perl-CGI-Session
    yum -y install perl-CPAN perl-CPAN-Changes perl-CPAN-Meta perl-CPAN-Meta-Requirements perl-CPAN-Meta-YAML
    yum -y install perl-Carp perl-Compress-Raw-Bzip2 perl-Crypt-DES perl-Crypt-OpenSSL-RSA
    yum -y install perl-Crypt-OpenSSL-Random perl-Crypt-PasswdMD5 perl-Crypt-SSLeay perl-DBD-Pg
    yum -y install perl-DBD-Pg-tests perl-DBI perl-Data-Dumper perl-DateTime perl-Digest-MD5
    yum -y install perl-Encode perl-File-Slurp perl-GSSAPI perl-IO-Socket-IP perl-IO-Socket-SSL
    yum -y install perl-JSON perl-LDAP perl-LWP-MediaTypes perl-LWP-Protocol-https perl-Net-DNS
    yum -y install perl-Net-HTTP perl-Net-SSLeay perl-Params-Check perl-Params-Util perl-Params-Validate
    yum -y install perl-Socket perl-TimeDate perl-WWW-Curl perl-YAML perl-core perl-devel perl-gettext
    yum -y install perl-libs perl-libwww-perl rrdtool-perl perl-YAML
  5. OpenOffce/LibreOffice

    yum -y install libreoffice libreoffice-headless
  6. 將 projop 加入 wheel

    vi /etc/group
    
    wheel:x:10:projop
  7. 修改 hosts

    vi /etc/hosts
    
    127.0.0.1 localhost
    10.140.0.3 po
  8. download files

    wget http://sourceforge.net/projects/project-open/files/project-open/Support%20Files/naviserver-4.99.8.tgz 
    wget http://sourceforge.net/projects/project-open/files/project-open/Support%20Files/web_projop-aux-files.5.0.0.0.0.tgz 
    wget http://sourceforge.net/projects/project-open/files/project-open/V5.0/update/project-open-Update-5.0.3.0.0.tgz 
  9. po installer

    groupadd projop                                                              # create a group called "projop"
    mkdir /web/                                                                  # super-directory for all Web servers /web/ by default
    useradd -d /web/projop -g projop projop                                      # create user "projop" with home directory /web/projop
    cd /web/projop/
    tar xzf /usr/src/web_projop-aux-files.5.0.0.0.0.tgz                          # extract auxillary files
    tar xzf /usr/src/project-open-Update-5.0.3.0.0.tgz                           # extract the ]po[ product source code - latest
    chown -R projop:projop /web/projop                                           # set ownership to all files
    
    cd /usr/local
    tar xzf /usr/src/naviserver-4.99.8.tgz                                       # extract the NaviServer binary 64 bit
  10. Setup PostgreSQL 9.2

    yum -y install postgresql postgresql-server postgresql-contrib postgresql-devel postgresql-odbc postgresql-docs
    
    systemctl enable postgresql

    init PostgreSQL

    /usr/bin/postgresql-setup initdb
    systemctl start postgresql
  11. Database

    su - postgres -c "createuser -s projop"                             # database user "projop" with admin rights
    su - projop -c "createdb --encoding=utf8 --owner=projop projop"     # new database
    su - projop -c "createlang plpgsql projop"                          # enable PlPg/SQL, may already be installed
  12. verify

    su - projop -c psql
    
    # Enter "\q" or press Ctrl-D to exit

    匯入 DB sql

    # import db
    
    su - projop
    psql -f ~/pg_dump.5.0.3.0.0.sql > import.log 2>&1
    
    # verify
    
    psql -c "select count(*) from users"
  13. 修改 postgresql.conf

    vi /var/lib/pgsql/data/postgresql.conf
    
    listen_addresses = '*'
    max_connections = 100
    
    #shared_buffers = 512MB
    shared_buffers = 256MB
    
    work_mem = 64MB
    maintenance_work_mem = 16MB
    
    checkpoint_segments = 64
    
    log_timezone = 'Asia/Taipei'
    timezone = 'Asia/Taipei'
  14. update pg_hba.conf

    vi /var/lib/pgsql/data/pg_hba.conf
    
    local   all             all                                     peer
    host    all             all             127.0.0.1/32            trust
    host    all             all             ::1/128                 ident
  15. update po config

    vi /web/projop/etc/config.tcl
    
    set httpport            8000
    set httpsport           8443
    
    set servername   "maxkit \]project-open\[ Server"
    set homedir      /usr/local/ns
  16. manual startup

    /usr/local/ns/bin/nsd -f -t /web/projop/etc/config.tcl -u projop -g projop
  17. service

    vi /usr/lib/systemd/system/projop.service
    
    [Unit]
    Description=NaviServer Web Server as user projop
    After=postgresql.service network.target
    Wants=postgresql.service
    
    [Service]
    Type=forking
    PIDFile=/web/projop/log/nsd.pid
    
    ExecStartPre=/usr/bin/rm -f /web/projop/log/nsd.pid
    ExecStart=/usr/local/ns/bin/nsd -t /web/projop/etc/config.tcl -u projop -g projop &
    ExecReload=/bin/kill -s HUP $MAINPID
    ExecStop=/bin/kill -s 9 $MAINPID
    
    Restart=always
    
    # Restart=on-abort
    
    # Restart=on-abnormal
    
    KillMode=process
    
    [Install]
    WantedBy=multi-user.target
    # init service
    chmod 755 /usr/lib/systemd/system/projop.service
    systemctl daemon-reload
    systemctl enable projop.service
    systemctl start projop.service
    
    tail -f /web/projop/log/error.log
  18. nginx

    yum -y install epel-release
    yum -y install nginx
    vi /etc/nginx/nginx.conf
    
    user nginx;
    worker_processes auto;
    error_log /var/log/nginx/error.log;
    pid /run/nginx.pid;
    
    events {
       worker_connections 1024;
    }
    
    http {
       log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                         '$status $body_bytes_sent "$http_referer" '
                         '"$http_user_agent" "$http_x_forwarded_for"';
       access_log          /var/log/nginx/access.log  main;
       sendfile            on;
       tcp_nopush          on;
       tcp_nodelay         on;
       keepalive_timeout   601;
       types_hash_max_size 2048;
       default_type        application/octet-stream;
       include             /etc/nginx/mime.types;
       include             /etc/nginx/conf.d/*.conf;
    
       server {
           listen 80;
           location / {
               # pass all communication to NaviServer on port 8000
               proxy_pass           http://127.0.0.1:8000;
               # add information about the original IP
               proxy_set_header     X-Forwarded-For $remote_addr;
               # upload files to file storage up to 1G
               client_max_body_size 1024M;
           }
    
           # error_page    500 502 503 504 /err/50x.html;
           # error_page    404             /err/404.html;
           # location /err/ {
           #     root /usr/share/nginx/html;
           # }
    
       }
    
    }

    先用 port 80 瀏覽一次網頁

    cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M mynginx
    semodule -i mynginx.pp

Add Swap to CentOS 7

ref: How to Add Swap Space on CentOS 7 - Google Cloud

```
# 1G

dd if=/dev/zero of=/swapfile bs=1024 count=1048576

# 2G

dd if=/dev/zero of=/swapfile bs=1024 count=2097152

# 4G

dd if=/dev/zero of=/swapfile bs=1024 count=4194304

chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile

swapon --show

```

```
vi /etc/fstab

/swapfile swap swap defaults 0 0

```

Docker

ref: http://www.project-open.com/en/install-docker-centos7

  1. CentOS 7安裝 docker

    yum install -y yum-utils device-mapper-persistent-data lvm2
    yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    yum install docker-ce
    
    systemctl enable docker
    systemctl start docker
  2. 下載 project-open

    mkdir -p download/project-open
    
    cd download/project-open
    
    wget --no-check-certificate https://sourceforge.net/projects/project-open/files/project-open/V5.0/older/project-open-Docker-Community-5.0.2.4.0.beta5.zip/download -O project-open-Docker-Community-5.0.2.4.0.beta5.zip
    
    unzip project-open-Docker-Community-5.0.2.4.0.beta5.zip
    cd po5-centos7
  3. 修改 setup line 24

    if ! wget --no-check-certificate -nv "$url" ; then
  4. 安裝

    ./setup
    ./build
    
    docker images
    
    REPOSITORY TAG IMAGE ID CREATED SIZE
    local/po5-centos7 latest acc4736e6a0c 7 minutes ago 1.81GB
  5. 啟動

    ./run
    
    docker start po5_centos7
    docker update --restart unless-stopped po5_centos7

沒有留言:

張貼留言