使用者工具

網站工具


myservice:edserver

這是本文件的舊版!


Install Ubuntu 24.04

Set First User

  1. username/pasword: administrator/a784026
  2. uid=1000, that same as OMVServer

Set IP

  1. ens192:LAN(192.168.123.0/24), ens36:WAN(192.168.2.0/24)
  2. set LAN to static
    $ sudo nano /etc/netplan/50-cloud-init.yaml

    Original

    network:
      version: 2
      ethernets:
        ens192:
          dhcp4: true
        ens36:
          dhcp4: true

    New

    network:
      version: 2
      ethernets:
        ens192:
    #     link-local: [ ipv4 ]  # 禁用 IPv6
          addresses:
            [192.168.123.11/24]
          routes:
            - to: default
            via: 192.168.123.249
    #     metric: 100
          nameservers:
            search: [local]
            addresses:  [192.168.123.249, 168.95.1.1, 8.8.8.8, 8.8.4.4]
    #     dhcp4: false
        ens36:
          dhcp4: true
    #     link-local: [ ipv4 ]  # 禁用 IPv6
  3. apply
    $ sudo netplan apply

設定時區

  • Set Timezone to Asia/Taipei
    $ sudo timedatectl set-timezone Asia/Taipei

PPPoE

  • Set PPPoE (不要 apt upgrade, 不然pppoe 會有問題?)
  1. PPPoE package installation
    $ sudo apt install pppoeconf
  2. Set up PPPoE connection
    $ sudo pppoeconf
  3. 把 LAN IP gateway 取消, only ppp 對外
    $ sudo nano /etc/netplan/50-cloud-init.yaml
    network:
      version: 2
      ethernets:
        ens192:
    #      link-local:
    #        [ipv4]
          addresses:
            [192.168.123.11/24]
    #      nameservers:
    #        addresses:
    #          [192.168.123.249]
    #        search:
    #          []
    #      routes:
    #         - to: "default"
    #           via: "192.168.123.249"
        ens36:
    #      link-local:
    #        [ipv4]
          addresses:
            [192.168.2.11/24]
          #dhcp4: true

安裝 net tool

  • Install net-tools (for ifconfig, router…)
    $ sudo apt install net-tools

Mount Raid5 NFS

Mount NFS

  1. Install NFS common
    $ apt install nfs-common
  2. List NFS Server Folder
    $ showmount -e 192.168.123.12
  3. Mount NFS
    $ sudo mount -t nfs 192.168.123.12:/export/Raid5 /mnt/Raid5/
  4. Check NFS
    $ df -hT

Auto Mount NFS

  1. Set NFS auto mount when system resrt
    $ nano /etc/fstab
    # /etc/fstab: static file system information.
    #
    # Use 'blkid' to print the universally unique identifier for a
    # device; this may be used with UUID= as a more robust way to name devices
    # that works even if disks are added and removed. See fstab(5).
    #
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    # / was on /dev/sda2 during curtin installation
    /dev/disk/by-uuid/b5b3be75-3c6c-4573-aeb6-3e2af16fa2ef / ext4 defaults 0 1
    /swap.img       none    swap    sw      0       0
    192.168.123.12:/export/Raid5    /mnt/Raid5      nfs     default 0       0

Install Apache + PHP

Update and Upgrade the system

  1. Update and Upgrade the system.
    $ apt update && apt upgrade -y
    (但怕 upgrade 後 pppoe 會有問題, 僅 update 就好)
    $ apt update

Install Apache2 and PHP Modules

  1. install Apache2
    $ apt install apache2 -y
  2. Install PHP and other Dependencies
    $ apt install php php-common libapache2-mod-php php-bz2 php-gd php-mysql \
    php-curl php-mbstring php-imagick php-zip php-common php-curl php-xml \
    php-json php-bcmath php-xml php-intl php-gmp zip unzip wget -y
  3. Enable required Apache modules
    $ a2enmod env rewrite dir mime headers setenvif ssl
  4. Now, Restart, Enable and Check Apache is Running Properly.
    $ systemctl restart apache2
    $ systemctl enable apache2
  5. Apache service should be in running state.
    $ systemctl status apache2
      apache2.service - The Apache HTTP Server
         Loaded: loaded (/usr/lib/systemd/system/apache2.service; 
         enabled; preset: enabled)
         Active: active (running) since Tue 2024-06-18 04:39:09 UTC; 8s ago
           Docs: https://httpd.apache.org/docs/2.4/
       Main PID: 16319 (apache2)
          Tasks: 6 (limit: 2269)
         Memory: 16.1M (peak: 16.3M)
            CPU: 97ms
         CGroup: /system.slice/apache2.service
                 ├─16319 /usr/sbin/apache2 -k start
                 ├─16326 /usr/sbin/apache2 -k start
  6. Check modules are loaded on Apache (Output omitted)
    $ apache2ctl -M
    Loaded Modules:
     core_module (static)
     so_module (static)
     watchdog_module (static)
     http_module (static)
     log_config_module (static)
    ............

Install Database(MariaDB)

Install MariaDB Server

  1. Install mariadb-server package
    $ apt install mariadb-server -y
  2. Now, restart and enable MariaDB service.
    $ systemctl restart mariadb
    $ systemctl enable mariadb
  3. check MariaDB is Running.
    $ systemctl status mariadb
    ● mariadb.service - MariaDB 10.11.7 database server
         Loaded: loaded (/usr/lib/systemd/system/mariadb.service; 
         enabled; preset: enabled)
         Active: active (running) since Tue 2024-06-18 04:43:21 UTC; 10s ago
           Docs: man:mariadbd(8)
                 https://mariadb.com/kb/en/library/systemd/
       Main PID: 17589 (mariadbd)
         Status: "Taking your SQL requests now..."
          Tasks: 12 (limit: 14975)
         Memory: 78.8M (peak: 81.8M)
            CPU: 573ms
         CGroup: /system.slice/mariadb.service
                 └─17589 /usr/sbin/mariadbd

Configure MariaDB Server

  • [MariaDB 允許外部連線的設定]
    不管是 MariaDB 還是 Mysql ,安裝好後都是只允許從 localhost連進資料庫,如果要從遠端連線的話需要修改一些設定和權限。
  1. 修改設定檔
    MariaDB的設定檔預設是
    /etc/mysql/mariadb.conf.d/50-server.cnf

    進入檔案後看到

    bind-address = 127.0.0.1

    在這行前加入 # 註解掉。

  2. 給予使用者外部連線的權限
    先連入 mariaDB
    mysql -uroot -p

    之後輸入

    grant privileges on *.* to 'root'@'%' identified by 'yourpassword';

    記得把 root 改成自己的使用者名稱,yourpassword改成自己設的密碼
    再輸入

    flush privileges; 

    更新新的權限。
    做完這些之後,可能還不會立即生效,即使用

    service mysql restart

    也不會立即套用新的設定。
    機器必須重啟過後才能套用新設定

    sudo reboot

將 Mysql 移至 Fileserver

  • 以下請以 root 權限下執行
  1. 建立新的mysql資料夾
    $ cd /mnt/Raid5/Service2/
    $ mkdir MySQL_10.11.11-MariaDB
  2. 更改權限
    $ chown mysql:mysql MySQL_10.11.11-MariaDB
  3. 關閉 mysql 服務
    $ systemctl stop mysqld
  4. 更改 mysql 位置
    $ cd /var/lib/
    $ mv mysql mysql_backup
    $ ln -s /mnt/Raid5/Service2/MySQL_10.11.11-MariaDB mysql
    $ mv mysql_backup/* mysql/
    $ rm -rf mysql_backup/
  5. 啟動 mysql
    $ systemctl start mysqld
  6. 測試 mysql
    $ systemctl status mysqld

Install NextCloud

Create Directory for Nextcloud

  • from /usr/local create a Symbolic link for Nextcloud
    $ cd /usr/local/
    $ ln -s /mnt/Raid5/Service2 Service2

Download Nextcloud

  1. Download Nextcloud with latest version
    $ cd /usr/local/Server2/
    $ wget https://download.nextcloud.com/server/releases/latest.zip
  2. Unzip
    $ unzip latest.zip
  3. Remove the zip file, which is not necessary now.
    $ rm -rf latest.zip
  4. Change the ownership of the nextcloud directory to the HTTP user.
    $ chown -R www-data:www-data /usr/local/Server2/nextcloud/

Set Apache Virtual Host

  1. Confirm Apache is installed
    $ systemctl status apache2
  2. Create a directory structure.
    Create a directory structure for your websites. In this example, we’ll set up directories for cloud.lang.idv.tw
    $ mkdir -p /usr/local/Server2/nextcloud
  3. Create Virtual Configuration
    Create a new virtual host configuration file for cloud.lang.idv.tw:
    $ vi /etc/apache2/sites-available/cloud.lang.idv.tw.conf

    Add the following content to the file;

    <VirtualHost *:80>
        ServerAdmin eddie@lang.idv.tw
        ServerName cloud.lang.idv.tw
        #ServerAlias box.lang.idv.tw
        DocumentRoot /usr/local/Server2/nextcloud
    
        <Directory /usr/local/Server2/nextcloud>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>
    
        ErrorLog ${APACHE_LOG_DIR}/cloud.lang.idv.tw_error.log
        CustomLog ${APACHE_LOG_DIR}/cloud.lang.idv.tw_access.log combined
    </VirtualHost>
  4. Enable the Virtual Host
    Enable the new virtual host with the following command:
    $ a2ensite cloud.lang.idv.tw.conf
  5. Test the Configuration
    Check the configuration for syntax errors:
    $ apache2ctl configtest
  6. Restart
    Restart Apache to apply the changes:
    $ systemctl restart apache2
  7. 訪問 FollowSymLinks 須要把目錄加上 執行權限, 包含上層目錄
    $ chmod o+x /usr/local/Server2/nextcloud
    $ chmod o+x /usr/local/Server2

Create Database

  1. Create Database and User for Nextcloud and Provide User Permissions.
     $ mysql
    CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'nextcloud';
    CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
    GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
    FLUSH PRIVILEGES;
    quit;

Install Nextcloud

  1. Install Nextcloud\\You can install Nextcloud via the web GUI or command line, and you can choose your preferred method.
    * Used web GUI to install
    http://[hostname]/install.php)

    * Run the below command to install nextcloud (provide your own credentials)

    $ cd /usr/local/Server2/nextcloud
    $ sudo -u www-data php occ  maintenance:install --database \
     "mysql" --database-name "nextcloud"  --database-user "nextcloud" --database-pass \
     'nextcloud' --admin-user "admin" --admin-pass "a784026"

    If everything goes well the command will output “Nextcloud was successfully installed”.

  2. Add access domain
    Nextcloud allows access only from localhost, it could through error “Access through untrusted domain”. we need to allow accessing Nextcloud by using ip or domain name.
    $ vi /usr/local/Server2/nextcloud/config/config.php
      'trusted_domains' =>
      array (
        0 => 'localhost',
        1 => 'cloud.lang.idv.tw',   // we Included the Sub Domain
      ),
      .....
    :x

Nextcloud的一些錯誤提示

ref: https://www.cnblogs.com/Athenavi/p/17168460.html

  1. PHP 內存限制低於建議值 512MB
    您可以通過以下步驟增加PHP內存限制:
    打開php.ini文件 在終端中輸入以下命令打開php.ini文件:
    $ sudo nano /etc/php/<version>/apache2/php.ini

    更改內存限制
    使用Ctrl+W搜索memory_limit。找到並更改下面一行中的內存限制值:

    memory_limit = 512M

    將值更改為建議的內存限制,如1G或2G:

    memory_limit = 1G

    保存並關閉文件
    使用Ctrl+O保存更改,然後使用Ctrl+X退出nano。

  2. 重啟Apache服務器
    在終端中輸入以下命令以重啟Apache服務器:
    $ sudo systemctl restart apache2

    現在,您的PHP內存限制已更改為建議值。

Install DokuWiki

Update Your System

  • Open your terminal and run:
    $ sudo apt update && sudo apt upgrade -y

Install Required Packages

  • Install Apache, PHP, and other necessary packages:
    maybe these have installed, but you also can install again
    $ sudo apt install apache2 php php-xml libapache2-mod-php unzip -y

Download DokuWiki

  • Navigate to the web directory and download the latest DokuWiki version:
    $ cd /usr/local/Service2
    $ sudo wget https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz

Extract DokuWiki

  • Extract the downloaded file and rename the directory:
    $ sudo tar xvf dokuwiki-stable.tgz
    $ sudo ln -s dokuwiki-*/ dokuwiki

Set Permissions

  • Adjust permissions for the DokuWiki directory:
    $ sudo chown -R www-data:www-data /usr/local/Service2/dokuwiki
    $ sudo chmod -R 755 /usr/local/Service2/dokuwiki

Configure Apache

  • Create a new Apache configuration file:
    $ sudo nano /etc/apache2/sites-available/wiki.lang.idv.tw.conf
  • Add the following content:
    <VirtualHost *:80>
        ServerAdmin eddie@lang.idv.tw
        ServerName wiki.lang.idv.tw
        #ServerAlias box.lang.idv.tw
        DocumentRoot /usr/local/Service2/dokuwiki
    
        <Directory /usr/local/Service2/dokuwiki>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>
    
        ErrorLog ${APACHE_LOG_DIR}/wiki.lang.idv.tw_error.log
        CustomLog ${APACHE_LOG_DIR}/wiki.lang.idv.tw_access.log combined
    </VirtualHost>
  • Save and exit.

Enable the Site and Rewrite Module

  • Enable the new site and the rewrite module:
    $ sudo a2ensite wiki.lang.idv.tw.conf
    $ sudo a2enmod rewrite
    $ sudo systemctl restart apache2

Complete Installation in Browser

  • Open your browser and navigate to
    http://wiki.lang.idv.tw/install.php
  • Follow the on-screen instructions to complete the setup.

Secure Your Installation

  • After installation, remove the install.php file:
    $ sudo rm /var/www/html/dokuwiki/install.php
  • DokuWiki is now installed and ready to use on your Ubuntu 24.04 LTS system.

Install Wordpress for Pingtek

Download and unzip the WordPress

  1. Download Nextcloud with latest version
    $ cd /usr/local/Server2/
    $ wget https://wordpress.org/latest.zip
  2. Rename latest.zip to wordpress-6.8.1.zip
    $ mv latest.zip wordpress-6.8.1.zip
  3. Unzip
    $ unzip wordpress-6.8.1.zip
  4. Rename directory to wordpress_Pingtek
    $ mv wordpress wordpress_Pingtek
  5. Change the ownership of the wordpress_Pingtek directory to the HTTP user
    $ chown -R www-data:www-data wordpress_Pingtek/
myservice/edserver.1746890668.txt.gz · 上一次變更: 由 eddie

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki