myservice:edserver
這是本文件的舊版!
目錄表
Install Ubuntu 24.04
Set First User
- username/pasword: administrator/a784026
- uid=1000, that same as OMVServer
Set IP
- ens192:LAN(192.168.123.0/24), ens36:WAN(192.168.2.0/24)
- set LAN to static
$ sudo nano /etc/netplan/50-cloud-init.yaml
Original
network: version: 2 ethernets: ens192: dhcp4: true ens36: dhcp4: trueNew
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 - apply
$ sudo netplan apply
設定時區
- Set Timezone to Asia/Taipei
$ sudo timedatectl set-timezone Asia/Taipei
PPPoE
- Set PPPoE (不要 apt upgrade, 不然pppoe 會有問題?)
- PPPoE package installation
$ sudo apt install pppoeconf
- Set up PPPoE connection
$ sudo pppoeconf
- 把 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
- Install NFS common
$ apt install nfs-common
- List NFS Server Folder
$ showmount -e 192.168.123.12
- Mount NFS
$ sudo mount -t nfs 192.168.123.12:/export/Raid5 /mnt/Raid5/
- Check NFS
$ df -hT
Auto Mount NFS
- 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
- Update and Upgrade the system.
$ apt update && apt upgrade -y (但怕 upgrade 後 pppoe 會有問題, 僅 update 就好) $ apt update
Install Apache2 and PHP Modules
- install Apache2
$ apt install apache2 -y
- 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
- Enable required Apache modules
$ a2enmod env rewrite dir mime headers setenvif ssl
- Now, Restart, Enable and Check Apache is Running Properly.
$ systemctl restart apache2 $ systemctl enable apache2
- 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 - 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) ............
解除 PHP 上傳大檔案限制
- ref: ttps://blog.gtwang.org/linux/php-ini-large-file-upload-configuration/
set php
h
Install Database(MariaDB)
Install MariaDB Server
- Install mariadb-server package
$ apt install mariadb-server -y
- Now, restart and enable MariaDB service.
$ systemctl restart mariadb $ systemctl enable mariadb
- 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連進資料庫,如果要從遠端連線的話需要修改一些設定和權限。
- 修改設定檔
MariaDB的設定檔預設是/etc/mysql/mariadb.conf.d/50-server.cnf
進入檔案後看到
bind-address = 127.0.0.1
在這行前加入 # 註解掉。
- 給予使用者外部連線的權限
先連入 mariaDBmysql -uroot -p
之後輸入
grant privileges on *.* to 'root'@'%' identified by 'yourpassword';
記得把 root 改成自己的使用者名稱,yourpassword改成自己設的密碼
再輸入flush privileges;
更新新的權限。
做完這些之後,可能還不會立即生效,即使用service mysql restart
也不會立即套用新的設定。
機器必須重啟過後才能套用新設定sudo reboot
將 Mysql 移至 Fileserver
- 以下請以 root 權限下執行
- 建立新的mysql資料夾
$ cd /mnt/Raid5/Service2/ $ mkdir MySQL_10.11.11-MariaDB
- 更改權限
$ chown mysql:mysql MySQL_10.11.11-MariaDB
- 關閉 mysql 服務
$ systemctl stop mysqld
- 更改 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/
- 啟動 mysql
$ systemctl start mysqld
- 測試 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
- Download Nextcloud with latest version
$ cd /usr/local/Server2/ $ wget https://download.nextcloud.com/server/releases/latest.zip
- Unzip
$ unzip latest.zip
- Remove the zip file, which is not necessary now.
$ rm -rf latest.zip
- 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
- Confirm Apache is installed
$ systemctl status apache2
- 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
- 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> - Enable the Virtual Host
Enable the new virtual host with the following command:$ a2ensite cloud.lang.idv.tw.conf
- Test the Configuration
Check the configuration for syntax errors:$ apache2ctl configtest
- Restart
Restart Apache to apply the changes:$ systemctl restart apache2
- 訪問 FollowSymLinks 須要把目錄加上 執行權限, 包含上層目錄
$ chmod o+x /usr/local/Server2/nextcloud $ chmod o+x /usr/local/Server2
Create Database
- 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
- Install Nextcloud\\You can install Nextcloud via the web GUI or command line, and you can choose your preferred method.
* Used web GUI to installhttp://[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”.
- 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
- 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。 - 重啟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
- Download Nextcloud with latest version
$ cd /usr/local/Server2/ $ wget https://wordpress.org/latest.tar.gz
- Rename latest.tar.gz to wordpress-6.8.1.tar.gz
please reference https://tw.wordpress.org/download/ that will show the download version$ mv latest.tar.gz wordpress-6.8.1.tar.gz
- extract the package
The WordPress package will extract into a folder called wordpress in the same directory$ tar -xzvf wordpress-6.8.1.tar.gz
- Rename directory to wordpress_Pingtek
$ mv wordpress wordpress_Pingtek
- Change the ownership of the wordpress_Pingtek directory to the HTTP user
$ chown -R www-data:www-data wordpress_Pingtek/
Create Database
- Create Database and User for Wordpress_Pingtek and Provide User Permissions.
$ mysql
CREATE USER 'wordpress_pingtek'@'localhost' IDENTIFIED BY 'wordpress_pingtek'; CREATE DATABASE wordpress_pingtek CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; GRANT ALL PRIVILEGES ON wordpress_pingtek.* TO 'wordpress_pingtek'@'localhost'; FLUSH PRIVILEGES; quit;
Set Apache Virtual Host
- Confirm Apache is installed
$ systemctl status apache2
- Create a directory structure.
Create a directory structure for your websites. In this example, we’ll set up directories for pingtek.com.tw$ mkdir -p /usr/local/Service2/wordpress_Pingtek
- Create Virtual Configuration
Create a new virtual host configuration file for pingtek.com.tw:$ vi /etc/apache2/sites-available/pingtek.com.tw.conf
Add the following content to the file;
<VirtualHost *:80> ServerAdmin eddie@lang.idv.tw ServerName pingtek.com.tw ServerAlias www.pingtek.com.tw DocumentRoot /usr/local/Service2/wordpress_Pingtek <Directory /usr/local/Service2/wordpress_Pingtek> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/pingtek.com.tw_error.log CustomLog ${APACHE_LOG_DIR}/pingtek.com.tw_access.log combined </VirtualHost> - Enable the Virtual Host
Enable the new virtual host with the following command:$ a2ensite pingtek.com.tw.conf
- Test the Configuration
Check the configuration for syntax errors:$ apache2ctl configtest
- Restart
Restart Apache to apply the changes:$ systemctl restart apache2
- 訪問 FollowSymLinks 須要把目錄加上 執行權限, 包含上層目錄
$ chmod o+x /usr/local/Server2/nextcloud $ chmod o+x /usr/local/Server2
Setup Wordpress
還原備份檔
- 原以使用 “All-in-One WP Migration” 備份, 故須將其還原
- 安裝外掛 “All-in-One WP Migration”
- From “All-in-One WP Migration” import backup files
NextCloud_PingTek\WebSite\www.pingtek.com.tw-20210830-094829-kpqkhp.wpress - 還原後若忘了管理者密碼, 可透過 mysql 重設, 步驟即下
- 登入 mysql
$ mysql -u root -p or # used root user direct into mysql $ mysql
- check the WordPress database
that can used below command show all database and check the WordPress databaseshow databases;
+--------------------+ | Database | +--------------------+ | information_schema | | mysql | | nextcloud | | performance_schema | | sys | | wordpress_pingtek | +--------------------+ 6 rows in set (0.007 sec)
- select WordPress database
use wordpress_pingtek;
- you’re looking for a table name with “users” at the end
show tables;
+-------------------------------------------------+ | Tables_in_wordpress_pingtek | +-------------------------------------------------+ | wp_commentmeta | | wp_comments | | wp_formmaker | | . | | . | | . | | wp_users | | . | | . | | . | +-------------------------------------------------+ 50 rows in set (0.001 sec)
- select USER and check whick user will be reset
SELECT ID, user_login, user_pass FROM wp_users;
MariaDB [wordpress_pingtek]> SELECT ID, user_login, user_pass FROM wp_users; +----+------------+-----------------------------------------------------------------+ | ID | user_login | user_pass | +----+------------+-----------------------------------------------------------------+ | 1 | admin | $w******************************1K | | 2 | e***e | $w******************************JW | | 3 | j**f | $P******************************g1 | | 4 | w***e | $P******************************v/ | +----+------------+-----------------------------------------------------------------+ 4 rows in set (0.001 sec)
- actually changes the password(this sample will change admin user
UPDATE wp_users SET user_pass = MD5('new-password') WHERE ID = 1; - confirm that it was changed
SELECT ID, user_login, user_pass FROM wp_users;
- exit mysql client
exit
- remove “All-in-One WP Migration”, 因為這外掛改為商業, 免費版有檔案大小限制
- 安裝另一個備份程式“UpdraftPlus”
- That all
set php
https://blog.gtwang.org/linux/php-ini-large-file-upload-configuration/
myservice/edserver.1746934237.txt.gz · 上一次變更: 由 eddie


