วันพฤหัสบดีที่ 20 ธันวาคม พ.ศ. 2561

[Linux Container] - การติดตั้ง OCS2 และ OJS2 บน Linux Container

จุดประสงค์ตามรายการต่อไปนี้
  1. ติดตั้ง Linux Container (LDX, LXC) และการใช้งานนิดหน่อย
  2. สร้างและใช้งาน Container ที่ลง CentOS 7
  3. เตรียมและติดตั้ง OCS and OJS ใน Container CentOS 7
    • ลง httpd, php, php-mysqlnd และ mariadb-server
    • ดาวน์โหลด OCS และ OJS
    • ปรับสิทธิ์การเข้าถึงไฟล์ และติดตั้งผ่านเว็บเบราว์เซอร์
  4. ตั้งค่า Reverse Proxy ที่ Ubuntu

ติดตั้ง Linux Ubuntu 18.04
ติดตั้ง Linux Container (LDX, LXC ใน Ubuntu 18.04)

ติดตั้ง Packages ผ่าน Snappy
1
sudo snap install lxd
เมื่อติดตั้งครั้งแรกให้ทำการตั้งค่าก่อนใช้งาน
1
sudo lxd init
เราจะเจอกับคำถามประมาณนี้
  
 Would you like to use LXD clustering? (yes/no) [default=no]:_
 Do you want to configure a new storage pool? (yes/no) [default=yes]:_
 Name of the new storage pool [default=default]:_
 Name of the storage backend to use (btrfs, ceph, dir, lvm, zfs) [default=zfs]:_
 Create a new ZFS pool? (yes/no) [default=yes]:_
 Would you like to use an existing block device? (yes/no) [default=no]:_
 Size in GB of the new loop device (1GB minimum) [default=15GB]: 10     
 Would you like to connect to a MAAS server? (yes/no) [default=no]:_
 Would you like to create a new local network bridge? (yes/no) [default=yes]:_
 What should the new bridge be called? [default=lxdbr0]:_
 What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:_
 What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:_
 Would you like LXD to be available over the network? (yes/no) [default=no]:_
 Would you like stale cached images to be updated automatically? (yes/no) [default=yes]:_
 Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]:_
  

ก่อนทำการสร้าง Container เราสามารถดูรายการ Image ที่ทาง Ubuntu เตรียมไว้ให้เรา (http://us.images.linuxcontainers.org/)
หรือใช้คำสั่งแสดงรายการ Image ในตัวอย่างนี้จะดูเฉพาะที่เป็น CentOS
1
sudo lxc image list image: | grep -C1 -i centos

สร้างและเริ่มใช้งาน Container
1
sudo lxc launch images:centos/7 centos7

แสดงรายการ Container ที่สร้างไว้
1
sudo lxc list
ทำการ Remote ไปยัง Container เหมือนกับ Secure Shell นั้นแหละ
1
2
3
sudo lxc exec centos 7 bash
# หรือ
sudo lxc exec centos7 -- /bin/bash
หากต้องการสั่งงานตรงๆ โดยไม่ SSH เข้าไป ก็สามารสั่งแบบนี้ได้
1
sudo lxc exec centos7 -- yum update

ติดตั้ง เว็บเซิร์ฟเวอร์ แล้ว ดาต้าเบสเซิร์ฟเวอร์ ใน Container ที่เราสร้างไว้เป็น CentOS 7
สิ่งที่ติดตั้งก็จะมี httpd 2.4.6, php 5.4.16 และ mariadb 5.5.60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
yum update
yum upgrade
 
yum install httpd
yum install php php-mysqlnd
 
systemctl start httpd
systemctl enable httpd
 
yum install mariadb-server
systemctl start mariadb
systemctl enable mariadb
 
mysql_secure_installation








ทำการดาวน์โหลดโปรแกรม OCS 2 และ OJS 2 มาติดตั้ง อันนี้ทำให้ดูแค่ OCS อย่างเดียวเนื่องจาก OJS ก็ติดตั้งเหมือนกัน
1
2
3
4
5
6
7
8
9
10
11
12
13
14
cd /var/www/html/
curl https://pkp.sfu.ca/ocs/download/ocs-2.3.6.tar.gz --output ocs-2.3.6.tar.gz
tar -xvzf ocs-2.3.6.tar.gz
cd ocs-2.3.6
 
mkdir files
chmod 777 files
chmod 777 public
 
mkdir cache/t_config
chmod -R 777 cache
# cache, _db, cache/t_cache, cache/t_compile, cache/t_config
 
chmod 777 config.inc.php
เมื่อทำการเตรียมไฟล์ติดตั้งของ OCS เสร็จแล้วก็ให้เราทำการเปิดเว็บเบราว์เซอร์แล้วเปิดเว็บและทำตามขั้นตอนการติดตั้ง
ดูหมายเลข IP ของ Container ก่อน แล้วเข้าไปตาม IP นั้นได้เลย
1
ip address



เสร็จแล้วให้เราทำการปิดสิทธิ์การแก้ไขไฟล์ config.ini.php
1
chmod 644 config.ini.php
เมื่อติดตั้งเสร็จแล้ว Container จะยังไม่สามารถเข้าจากข้างนอกได้ ให้เราทำการ Forward Proxy เพื่อให้ข้างนอกเข้ามาได้
โดยเราจะใช้ Apache2 ในการเป็น Proxy เริ่มติดตั้ง Apache2 และตั้งค่า Reverse Proxy
1
2
3
4
5
6
7
8
9
sudo apt-get update
sudo apt-get install apache2
 
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer
sudo a2enmon lbmethod_byrequests
 
sudo nano /etc/apache2/sites-enabled/000-default.conf
แก้ไขไฟล์ 000-default.conf
1
2
3
4
5
6
<VirtualHost *:80>
  ProxyPreserveHost On
 
  ProxyPass /ocs-2.3.6/ http://10.96.242.212/ocs-2.3.6/
  ProxyPassReverse /ocs-2.3.6/ http://10.96.242.212/ocs-2.3.6/
</VirtualHost>
เซฟไฟล์แล้วทำการ Restart Apache2 เพื่อให้รับค่าใหม่
1
sudo systemctl restart apache2
เสร็จแล้วลองเข้าจาก localhost ที่เป็น Apache2 บน Ubuntu ดู



ลองเข้าจากเครื่องอื่นที่อยู่ใน Network เดียวกัน






ขอขอบคุณแหล่งข้อมูลสำคัญ
Linux Containers Getting Started
DigitalOcean Tutorial / Apache Reverse Proxy Ubuntu 16.04
DigitalOcean Tutorial / Apache Reverse Proxy CentOS 7

Open Conference System 2.3.6 (Current Stable Release May 28, 2014)
Download: Official / Google Drive

System Requirements - Open Conference System 2.3.6
  • PHP:>= 4.2.x (including PHP 5.x); Microsoft IIS requires PHP 5.x
    OCS 2.x currently will not run on PHP 7.x.
  • MySQL:>= 3.23.23 (including MySQL 4.x) or PostgreSQL 7.1 (including PostgreSQL 8.x)
  • Apache:>=1.3.2x or >= 2.0.4x or Microsoft IIS 6
  • Operating system: Any OS that supports the above software,
    including Linux, BSD, Solaris, Mac OS X, Windows.

Open Journal System 2.4.8-3 (Current Stable Release January 16,2018)
Download: Official / Google Drive

System Requirements - Open Journal System 2.4.8-3
  • PHP:>= 4.2.x (including PHP 5.x); with MySQL or PostgreSQL support
  • A database server: MySQL 4.1 or later OR PostgreSQL 8.0 or later
  • UNIX-like OS recommended (such as Linux, FreeBSD, Solaris, Mac OS X, etc.).
    OJS 2.0.2 and above supports Windows server (including IIS).

ไม่มีความคิดเห็น:

แสดงความคิดเห็น