使用者工具

網站工具


myservice:edserver

差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

兩邊的前次修訂版前次修改
myservice:edserver [2025/05/11 06:13] – [安裝 net tool] eddiemyservice:edserver [2025/11/25 05:32] (目前版本) – 移除 eddie
行 1: 行 1:
-====== 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 <code>$ sudo nano /etc/netplan/50-cloud-init.yaml</code> Original <code> 
-network: 
-  version: 2 
-  ethernets: 
-    ens192: 
-      dhcp4: true 
-    ens36: 
-      dhcp4: true 
-</code> New <code> 
-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 
-</code> 
-  - apply <code>$ sudo netplan apply</code> 
-==== 設定時區 ==== 
-  * Set Timezone to Asia/Taipei <code>$ sudo timedatectl set-timezone Asia/Taipei</code> 
-==== PPPoE ==== 
-  * Set PPPoE (不要 apt upgrade, 不然pppoe 會有問題?) 
-  - PPPoE package installation <code>$ sudo apt install pppoeconf</code> 
-  - Set up PPPoE connection <code>$ sudo pppoeconf</code> 
-  - 把 LAN IP gateway 取消, only ppp 對外 <code>$ sudo nano /etc/netplan/50-cloud-init.yaml</code><code> 
-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 
-</code> 
-==== 安裝 net tool ==== 
-  * Install net-tools (for ifconfig, router...) <code>$ sudo apt install net-tools</code> 
  
-==== Installing Crontab ==== 
-ref: https://www.uptimia.com/questions/how-to-install-crontab-in-ubuntu 
-<code> 
-Problem: Installing Crontab on Ubuntu 
-Ubuntu users often need to schedule tasks to run automatically at set times. Crontab is a tool for this purpose, but setting it up can be hard for new users. Users may have trouble with the installation process and understanding how to set up crontab on their Ubuntu systems. 
- 
-Installing Crontab on Ubuntu 
-Using the Command Line to Install Cron 
-To install cron on Ubuntu using the command line, follow these steps: 
- 
-Open the terminal on your Ubuntu system. 
- 
-Update the package list: 
- 
-sudo apt update 
- 
-Install cron: 
- 
-sudo apt install cron 
- 
-Start the cron service: 
- 
-sudo systemctl start cron 
- 
-Enable cron to start on system boot: 
- 
-sudo systemctl enable cron 
- 
-To verify the installation: 
- 
-Check the cron service status: 
- 
-sudo systemctl status cron 
- 
-This shows if cron is active and running. 
- 
-Confirm the crontab version: 
- 
-crontab -V 
- 
-This displays the installed crontab version. 
- 
-List current cron jobs: 
- 
-crontab -l 
- 
-This shows existing cron jobs for the current user. 
- 
-Setting Up Your First Cron Job in Ubuntu 
-Understanding Cron Job Syntax 
-Cron job syntax uses a schedule format with five time fields: 
- 
-* * * * * command_to_execute 
- 
-These fields represent: 
- 
-Minute (0-59) 
-Hour (0-23) 
-Day of the month (1-31) 
-Month (1-12) 
-Day of the week (0-7, where 0 and 7 represent Sunday) 
-An asterisk () in any field means "every" unit of time. For example, " " means "every minute of every hour of every day". 
- 
-You can use numbers, ranges (1-5), lists (1,3,5), and step values (*/2 for every two units) in these fields. 
- 
-Creating a Crontab File 
-To create or edit your crontab file: 
- 
-Open the crontab editor: 
- 
-crontab -e 
- 
-If it's your first time, you'll need to choose an editor (e.g., nano). 
- 
-Add new cron jobs, one per line. For example: 
- 
-0 2 * * * /path/to/backup_script.sh 
- 
-This runs a backup script every day at 2:00 AM. 
- 
-Save the file and exit the editor. In nano, press Ctrl+X, then Y, then Enter. 
- 
-After saving, the system installs the new crontab. You can view your cron jobs with the crontab -l command. 
- 
-Managing Cron Jobs in Ubuntu 
-Listing Existing Cron Jobs 
-To view your current cron jobs, use the following command in the terminal: 
- 
-crontab -l 
- 
-This command shows all the cron jobs for the current user. To view cron jobs for another user (requires root privileges), use: 
- 
-sudo crontab -u username -l 
- 
-Replace "username" with the actual username. 
- 
-Editing Cron Jobs 
-To change existing cron jobs: 
- 
-Open the crontab file: 
- 
-crontab -e 
- 
-Go to the job you want to change. 
- 
-Edit the job as needed. You can change the schedule or the command to run. 
- 
-Save the changes and exit the editor. In nano, press Ctrl+X, then Y, then Enter. 
- 
-The system installs the updated crontab after you save and exit. 
- 
-Deleting Cron Jobs 
-To remove specific cron jobs: 
- 
-Open the crontab file: 
- 
-crontab -e 
- 
-Find the job you want to delete. 
- 
-Remove the entire line for that job. 
- 
-Save and exit the editor. 
- 
-To clear all cron jobs for the current user: 
- 
-crontab -r 
- 
-This command removes the entire crontab file. Use it carefully. 
- 
-To remove all cron jobs for a specific user (requires root privileges): 
- 
-sudo crontab -r -u username 
- 
-Replace "username" with the actual username. 
- 
-It's a good idea to back up your crontab before making big changes. You can do this by running: 
- 
-crontab -l > crontab_backup 
- 
-This saves your current crontab to a file named "crontab_backup" in your current directory. 
- 
-Advanced Cron Usage in Ubuntu 
-System-Wide Crontab Files 
-System-wide crontab files in Ubuntu are in the /etc/cron.d/ directory. These files let you set up cron jobs for the whole system, not just for users. 
- 
-To edit system-wide cron jobs: 
- 
-Open the terminal. 
- 
-Use a text editor with root privileges to open or create a file in /etc/cron.d/: 
- 
-sudo nano /etc/cron.d/my_system_jobs 
- 
-Add cron jobs using the cron syntax, including the user to run the job: 
- 
-0 4 * * * root /path/to/daily_cleanup.sh 
- 
-Save the file and exit the editor. 
- 
-The system reads and applies these cron jobs without restarting the cron service. 
- 
-Redirecting Cron Job Output 
-Cron sends job output to the user's email by default. You can redirect this output to log files or other email addresses. 
- 
-To log cron job results: 
- 
-Redirect output and error to a file: 
- 
-0 5 * * * /path/to/script.sh > /path/to/logfile.log 2>&1 
- 
-This runs the script daily at 5 AM and logs output and errors to logfile.log. 
- 
-Add output to an existing log file: 
- 
-0 6 * * * /path/to/script.sh >> /path/to/logfile.log 2>&1 
- 
-This adds the output to logfile.log instead of overwriting it. 
- 
-To send output to a specific email: 
- 
-Use the MAILTO variable at the top of your crontab file: 
- 
-MAILTO="user@example.com" 
-0 7 * * * /path/to/script.sh 
- 
-This sends the script's output to the specified email address. 
- 
-For individual job emails, use the mail command: 
- 
-0 8 * * * /path/to/script.sh | mail -s "Cron Job Result" user@example.com 
- 
-This sends the output of the job to the email address with a custom subject line. 
- 
-Troubleshooting Cron Jobs in Ubuntu 
-Checking Cron Logs 
-To find and read cron log files in Ubuntu: 
- 
-Open the terminal. 
- 
-View the main system log: 
- 
-sudo grep CRON /var/log/syslog 
- 
-This shows cron-related entries in the system log. 
- 
-For real-time monitoring, use: 
- 
-sudo tail -f /var/log/syslog | grep CRON 
- 
-This displays new cron log entries as they occur. 
- 
-To identify issues with cron job execution: 
- 
-Look for error messages in the log output. 
-Check the timestamps to see if jobs run at scheduled times. 
-Look for "command not found" errors, which often indicate path problems. 
-Common Cron Job Errors and Solutions 
-Addressing permission problems: 
- 
-Make sure the user running the cron job has the right permissions for the task. 
-For scripts, check file permissions: 
-chmod +x /path/to/your/script.sh 
- 
-Use sudo in the crontab if the job needs root privileges: 
-0 * * * * sudo /path/to/script.sh 
- 
-Resolving path-related issues: 
- 
-Use full paths for commands and scripts in cron jobs. 
-Set the PATH variable in your crontab: 
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 
- 
-Source the user's profile in the cron job: 
-0 * * * * . $HOME/.profile; /path/to/script.sh 
- 
-Alternative Task Scheduling Methods in Ubuntu 
-Using Systemd Timers 
-Systemd timers are an alternative to cron jobs in Ubuntu. They are part of the systemd init system and offer some benefits: 
- 
-Systemd timers can start services, not just run commands. 
-They provide more timing control. 
-Systemd logs timer events, making troubleshooting easier. 
-To create a systemd timer: 
- 
-Create a service file (e.g., myjob.service) in /etc/systemd/system/: 
- 
-[Unit] 
-Description=My Job 
- 
-[Service] 
-ExecStart=/path/to/myscript.sh 
- 
-Create a timer file (e.g., myjob.timer) in the same directory: 
- 
-[Unit] 
-Description=Run My Job 
- 
-[Timer] 
-OnCalendar=*-*-* 02:00:00 
-Persistent=true 
- 
-[Install] 
-WantedBy=timers.target 
- 
-Enable and start the timer: 
- 
-sudo systemctl enable myjob.timer 
-sudo systemctl start myjob.timer 
- 
-Compared to cron jobs, systemd timers offer better system integration and more detailed logging. However, they can be harder to set up. 
- 
-At Command for One-Time Task Scheduling 
-The 'at' command is useful for scheduling one-time tasks in Ubuntu. Here's how to use it: 
- 
-Schedule a task: 
- 
-at 2:00 PM 
- 
-This opens a prompt where you can enter commands. 
- 
-Enter the command to run, then press Ctrl+D to save. 
- 
-View scheduled tasks: 
- 
-atq 
- 
-Remove a scheduled task: 
- 
-atrm [job number] 
- 
-The 'at' command differs from cron in several ways: 
- 
-'at' is for one-time tasks, while cron is for recurring tasks. 
-'at' uses a more natural language syntax for time. 
-'at' jobs run only once and then are removed from the queue. 
-'at' is good for tasks that don't need to repeat, such as one-time system maintenance or scheduled shutdowns. 
- 
-Best Practices for Using Cron in Ubuntu 
-When using cron in Ubuntu, following these practices helps keep your system secure and running well. Here are some key points: 
- 
-Security: 
- 
-Limit access to crontab files. Only give users the ability to create cron jobs if needed. 
- 
-Use specific user accounts for cron jobs instead of running all as root. 
- 
-Don't put passwords directly in cron commands. Use environment variables or secure files. 
- 
-Check your crontab files often to remove old jobs. 
- 
-Improving cron job performance: 
- 
-Schedule big jobs during quiet hours to reduce system load. 
- 
-Put multiple small tasks into one script to lower system work. 
- 
-Use anacron for jobs that don't need to run at exact times, especially on systems that aren't always on. 
- 
-Set nice values for CPU-heavy cron jobs to avoid affecting system performance. 
- 
-Maintaining crontab files: 
- 
-Check your crontab files monthly to remove or update old jobs. 
- 
-Write the purpose of each cron job in comments in the crontab file. 
- 
-Use version control or backups for your crontab files to track changes and fix mistakes. 
- 
-Test new cron jobs well before adding them to main systems. 
- 
-Check the output of your cron jobs often to find and fix issues quickly. 
- 
-By following these practices, you can keep a secure, efficient, and easy-to-manage cron setup on your Ubuntu system. 
-</code> 
-====== Mount Raid5 NFS ====== 
-==== Mount NFS ==== 
-  - Install NFS common <code>$ apt install nfs-common</code> 
-  - List NFS Server Folder <code>$ showmount -e 192.168.123.12</code> 
-  - Mount NFS <code>$ sudo mount -t nfs 192.168.123.12:/export/Raid5 /mnt/Raid5/</code> 
-  - Check NFS <code>$ df -hT</code> 
-==== Auto Mount NFS ==== 
-  - Set NFS auto mount when system resrt <code>$ nano /etc/fstab</code><code> 
-# /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 
-</code> 
- 
-====== Install Apache + PHP ====== 
-  * ref: https://mailserverguru.com/install-nextcloud-on-ubuntu-24-04-lts/ 
-==== Update and Upgrade the system ==== 
-  - Update and Upgrade the system. <code> 
-$ apt update && apt upgrade -y 
-(但怕 upgrade 後 pppoe 會有問題, 僅 update 就好) 
-$ apt update 
-</code> 
- 
-==== Install Apache2 and PHP Modules ==== 
-  - install Apache2 <code>$ apt install apache2 -y</code> 
-  - Install PHP and other Dependencies <code> 
-$ 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</code> 
-  - Enable required Apache modules <code>$ a2enmod env rewrite dir mime headers setenvif ssl</code> 
-  - Now, Restart, Enable and Check Apache is Running Properly. <code> 
-$ systemctl restart apache2 
-$ systemctl enable apache2</code> 
-  - Apache service should be in running state. <code>$ systemctl status apache2</code><code> 
-  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 
-</code> 
-  - Check modules are loaded on Apache (Output omitted) <code>$ apache2ctl -M</code><code> 
-Loaded Modules: 
- core_module (static) 
- so_module (static) 
- watchdog_module (static) 
- http_module (static) 
- log_config_module (static) 
-............ 
-</code> 
- 
-==== 解除 PHP 上傳大檔案限制 ==== 
-  * ref: https://blog.gtwang.org/linux/php-ini-large-file-upload-configuration/ 
-  - 編輯 PHP 的 php.ini 設定檔,放寬檔案上傳大小相關的設定:<code>$ nano /etc/php/8.3/apache2/php.ini</code><code> 
-; 上傳檔案大小上限(單一檔案大小) 
-upload_max_filesize = 2G 
- 
-; POST 大小上限(所有檔案大小加總) 
-post_max_size = 2G 
- 
-; 記憶體用量上限 
-memory_limit = 2G 
-</code>這三個設定值可以依照自己的需求來調整,大原則就是「記憶體用量上限」一定要比「POST 大小上限」更大,而「POST 大小上限」則要比「上傳檔案大小上限」更大,也就是這樣:\\ 記憶體用量上限 > POST 大小上限 > 上傳檔案大小上限 
-  - 上傳大型檔案通常都會需要比較久的時間,而 PHP 預設的設定不允許 PHP 指令稿執行太久,如果這部分沒有調整的話,可能會造成檔案上傳到一半,程式就被系統終止了,這樣也是傳不上去,所以要再調整 PHP 指令稿執行時間的設定值,讓 PHP 指令稿可以執行比較久一點,讓檔案可以傳的完。<code> 
-; PHP 指令稿執行時間上限(秒) 
-max_execution_time = 600 
- 
-; PHP 指令稿解析輸入資料時間上限(秒) 
-max_input_time = 600 
-</code> 
-  - 若擔心網路不穩造成傳大檔案時容易斷線的話,可以嘗試將 socket 等待逾時的設定調大一點:<code> 
-; socket 等待逾時(秒) 
-default_socket_timeout = 600 
-</code> 
- 
-====== Install Database(MariaDB) ====== 
-==== Install MariaDB Server ==== 
-  - Install mariadb-server package <code>$ apt install mariadb-server -y</code> 
-  - Now, restart and enable MariaDB service. <code> 
-$ systemctl restart mariadb 
-$ systemctl enable mariadb 
-</code> 
-  - check MariaDB is Running.<code>$ systemctl status mariadb</code><code> 
-● 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 
-</code> 
-==== Configure MariaDB Server ==== 
-  * [MariaDB 允許外部連線的設定] \\ 不管是 MariaDB 還是 Mysql ,安裝好後都是只允許從 localhost連進資料庫,如果要從遠端連線的話需要修改一些設定和權限。 
-  - 修改設定檔 \\ MariaDB的設定檔預設是 <code>/etc/mysql/mariadb.conf.d/50-server.cnf</code> 進入檔案後看到 <code>bind-address = 127.0.0.1</code> 在這行前加入 # 註解掉。 
-  - 給予使用者外部連線的權限 \\ 先連入 mariaDB <code>mysql -uroot -p</code> 之後輸入 <code>grant privileges on *.* to 'root'@'%' identified by 'yourpassword';</code> 記得把 root 改成自己的使用者名稱,yourpassword改成自己設的密碼 \\ 再輸入 <code>flush privileges; </code>更新新的權限。\\ 做完這些之後,可能還不會立即生效,即使用 <code>service mysql restart</code> 也不會立即套用新的設定。\\ 機器必須重啟過後才能套用新設定 <code>sudo reboot</code> 
- 
-==== 將 Mysql 移至 Fileserver ==== 
-  * 以下請以 root 權限下執行 
-  - 建立新的mysql資料夾<code> 
-$ cd /mnt/Raid5/Service2/ 
-$ mkdir MySQL_10.11.11-MariaDB 
-</code> 
-  - 更改權限<code> 
-$ chown mysql:mysql MySQL_10.11.11-MariaDB 
-</code> 
-  - 關閉 mysql 服務<code> 
-$ systemctl stop mysqld 
-</code> 
-  - 更改 mysql 位置<code> 
-$ 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/ 
-</code> 
-  - 啟動 mysql<code> 
-$ systemctl start mysqld 
-</code> 
-  - 測試 mysql<code> 
-$ systemctl status mysqld 
-</code> 
- 
-====== Install NextCloud ====== 
-https://mailserverguru.com/install-nextcloud-on-ubuntu-24-04-lts/ 
-==== Create Directory for Nextcloud ==== 
-  * from /usr/local create a Symbolic link for Nextcloud<code> 
-$ cd /usr/local/ 
-$ ln -s /mnt/Raid5/Service2 Service2 
-</code> 
- 
-==== Download Nextcloud ==== 
-  - Download Nextcloud with latest version<code> 
-$ cd /usr/local/Server2/ 
-$ wget https://download.nextcloud.com/server/releases/latest.zip 
-</code> 
-  - Unzip <code>$ unzip latest.zip</code> 
-  - Remove the zip file, which is not necessary now. <code>$ rm -rf latest.zip</code> 
-  - Change the ownership of the nextcloud directory to the HTTP user. <code>$ chown -R www-data:www-data /usr/local/Server2/nextcloud/</code> 
- 
-==== Set Apache Virtual Host ==== 
-  - Confirm Apache is installed <code>$ systemctl status apache2</code> 
-  - Create a directory structure.\\ Create a directory structure for your websites. In this example, we’ll set up directories for cloud.lang.idv.tw<code> 
-$ mkdir -p /usr/local/Server2/nextcloud 
-</code> 
-  - Create Virtual Configuration\\ Create a new virtual host configuration file for cloud.lang.idv.tw:<code> 
-$ vi /etc/apache2/sites-available/cloud.lang.idv.tw.conf 
-</code>Add the following content to the file;<code> 
-<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> 
-</code> 
-  - Enable the Virtual Host\\ Enable the new virtual host with the following command:<code> 
-$ a2ensite cloud.lang.idv.tw.conf</code> 
-  - Test the Configuration\\ Check the configuration for syntax errors:<code> 
-$ apache2ctl configtest</code> 
-  - Restart\\ Restart Apache to apply the changes:<code> 
-$ systemctl restart apache2</code> 
-  - **訪問 FollowSymLinks 須要把目錄加上 執行權限, 包含上層目錄**<code> 
-$ chmod o+x /usr/local/Server2/nextcloud 
-$ chmod o+x /usr/local/Server2 
-</code> 
-  
-==== Create Database ==== 
-  - Create Database and User for Nextcloud and Provide User Permissions. <code> $ mysql</code><code> 
-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; 
-</code> 
- 
-==== 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 install<code> 
-http://[hostname]/install.php)</code>  * Run the below command to install nextcloud (provide your own credentials)<code> 
-$ 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"</code> 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.<code>$ vi /usr/local/Server2/nextcloud/config/config.php</code><code> 
-  'trusted_domains' => 
-  array ( 
-    0 => 'localhost', 
-    1 => 'cloud.lang.idv.tw',   // we Included the Sub Domain 
-  ), 
-  ..... 
-:x 
-</code> 
-==== Nextcloud的一些錯誤提示 ==== 
-ref: https://www.cnblogs.com/Athenavi/p/17168460.html\\ 
-ref: https://docs.ossii.com.tw/books/nextcloud-G0B/page/nextcloud-Acd 
-  - PHP 內存限制低於建議值 512MB\\ 您可以通過以下步驟增加PHP內存限制:\\ 打開php.ini文件 在終端中輸入以下命令打開php.ini文件:<code>$ sudo nano /etc/php/<version>/apache2/php.ini</code> 更改內存限制\\ 使用Ctrl+W搜索memory_limit。找到並更改下面一行中的內存限制值:<code>memory_limit = 512M</code> 將值更改為建議的內存限制,如1G或2G:<code>memory_limit = 1G</code> 保存並關閉文件\\ 使用Ctrl+O保存更改,然後使用Ctrl+X退出nano。 ' 
-  - other<code> 
-; The OPcache shared memory storage size. 
-opcache.memory_consumption=512 
- 
-; The amount of memory for interned strings in Mbytes. 
-opcache.interned_strings_buffer=32 
-</code> 
-  - 重啟Apache服務器\\ 在終端中輸入以下命令以重啟Apache服務器:<code>$ sudo systemctl restart apache2</code> 現在,您的PHP內存限制已更改為建議值。 
- 
-====== Install DokuWiki ====== 
- 
-==== Update Your System ==== 
-  * Open your terminal and run:<code> 
-$ sudo apt update && sudo apt upgrade -y</code> 
- 
-==== Install Required Packages ==== 
-  * Install Apache, PHP, and other necessary packages:\\ maybe these have installed, but you also can install again<code> 
-$ sudo apt install apache2 php php-xml libapache2-mod-php unzip -y</code> 
- 
-==== Download DokuWiki ==== 
-  * Navigate to the web directory and download the latest DokuWiki version:<code> 
-$ cd /usr/local/Service2 
-$ sudo wget https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz 
-</code> 
- 
-==== Extract DokuWiki ==== 
-  * Extract the downloaded file and rename the directory:<code> 
-$ sudo tar xvf dokuwiki-stable.tgz 
-$ sudo ln -s dokuwiki-*/ dokuwiki 
-</code> 
- 
-==== Set Permissions ==== 
-  * Adjust permissions for the DokuWiki directory:<code> 
-$ sudo chown -R www-data:www-data /usr/local/Service2/dokuwiki 
-$ sudo chmod -R 755 /usr/local/Service2/dokuwiki 
-</code> 
- 
-==== Configure Apache ==== 
-  * Create a new Apache configuration file:<code> 
-$ sudo nano /etc/apache2/sites-available/wiki.lang.idv.tw.conf</code> 
-  * Add the following content:<code> 
-<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> 
-</code> 
-  * Save and exit. 
- 
-==== Enable the Site and Rewrite Module ==== 
-  * Enable the new site and the rewrite module:<code> 
-$ sudo a2ensite wiki.lang.idv.tw.conf 
-$ sudo a2enmod rewrite 
-$ sudo systemctl restart apache2 
-</code> 
- 
-==== Complete Installation in Browser ==== 
-  * Open your browser and navigate to <code>http://wiki.lang.idv.tw/install.php</code> 
-  * Follow the on-screen instructions to complete the setup. 
- 
-==== Secure Your Installation ==== 
-  * After installation, remove the install.php file:<code> 
-$ sudo rm /var/www/html/dokuwiki/install.php</code> 
-  * 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<code> 
-$ cd /usr/local/Server2/ 
-$ wget https://wordpress.org/latest.tar.gz 
-</code> 
-  - Rename latest.tar.gz to wordpress-6.8.1.tar.gz\\ please reference https://tw.wordpress.org/download/ that will show the download version<code> 
-$ mv latest.tar.gz wordpress-6.8.1.tar.gz 
-</code> 
-  - extract the package\\ The WordPress package will extract into a folder called wordpress in the same directory<code> 
-$ tar -xzvf wordpress-6.8.1.tar.gz 
-</code> 
-  - Rename directory to wordpress_Pingtek<code> 
-$ mv wordpress wordpress_Pingtek 
-</code> 
-  - Change the ownership of the wordpress_Pingtek directory to the HTTP user<code> 
-$ chown -R www-data:www-data wordpress_Pingtek/ 
-</code> 
- 
-==== Create Database ==== 
-  - Create Database and User for Wordpress_Pingtek and Provide User Permissions. <code> $ mysql</code><code> 
-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; 
-</code> 
- 
- 
-==== Set Apache Virtual Host ==== 
-  - Confirm Apache is installed <code>$ systemctl status apache2</code> 
-  - Create a directory structure.\\ Create a directory structure for your websites. In this example, we’ll set up directories for pingtek.com.tw<code> 
-$ mkdir -p /usr/local/Service2/wordpress_Pingtek 
-</code> 
-  - Create Virtual Configuration\\ Create a new virtual host configuration file for pingtek.com.tw:<code> 
-$ vi /etc/apache2/sites-available/pingtek.com.tw.conf 
-</code>Add the following content to the file;<code> 
-<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> 
-</code> 
-  - Enable the Virtual Host\\ Enable the new virtual host with the following command:<code> 
-$ a2ensite pingtek.com.tw.conf</code> 
-  - Test the Configuration\\ Check the configuration for syntax errors:<code> 
-$ apache2ctl configtest</code> 
-  - Restart\\ Restart Apache to apply the changes:<code> 
-$ systemctl restart apache2</code> 
-  - **訪問 FollowSymLinks 須要把目錄加上 執行權限, 包含上層目錄**<code> 
-$ chmod o+x /usr/local/Server2/nextcloud 
-$ chmod o+x /usr/local/Server2 
-</code> 
- 
-==== Setup Wordpress ==== 
-  - Setup Wordpress by Web GUI<code> 
-$ http://www.pingtek.com.tw 
-</code> 
-  - 依畫面完成設定 
-{{ :myservice:install-step3_v47.webp |}} 
-{{ :myservice:install-step5_v47.webp |}} 
- 
-==== 還原備份檔 ==== 
-  * 原以使用 "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<code> 
-$ mysql -u root -p 
-or 
-# used root user direct into mysql 
-$ mysql  
-</code> 
-    - check the WordPress database\\ that can used below command show all database and check the WordPress database <code> 
-show databases; 
-</code><code> 
-+--------------------+ 
-| Database           | 
-+--------------------+ 
-| information_schema | 
-| mysql              | 
-| nextcloud          | 
-| performance_schema | 
-| sys                | 
-| wordpress_pingtek  | 
-+--------------------+ 
-6 rows in set (0.007 sec) 
-</code> 
-    - select WordPress database<code> 
-use wordpress_pingtek; 
-</code> 
-    - you’re looking for a table name with “users” at the end<code> 
-show tables; 
-</code><code> 
-+-------------------------------------------------+ 
-| Tables_in_wordpress_pingtek                     | 
-+-------------------------------------------------+ 
-| wp_commentmeta                                  | 
-| wp_comments                                     | 
-| wp_formmaker                                    | 
-| .                                               | 
-| .                                               | 
-| .                                               | 
-| wp_users                                        | 
-| .                                               | 
-| .                                               | 
-| .                                               | 
-+-------------------------------------------------+ 
-50 rows in set (0.001 sec) 
-</code> 
-    - select USER and check whick user will be reset<code> 
-SELECT ID, user_login, user_pass FROM wp_users; 
-</code><code> 
-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) 
-</code> 
-    - actually changes the password(this sample will change admin user<code> 
-UPDATE wp_users SET user_pass = MD5('new-password') WHERE ID = 1; 
-</code> 
-    - confirm that it was changed<code> 
-SELECT ID, user_login, user_pass FROM wp_users; 
-</code> 
-    - exit mysql client<code>exit</code> 
-  - remove "All-in-One WP Migration", 因為這外掛改為商業, 免費版有檔案大小限制 
-  - 安裝另一個備份程式"UpdraftPlus" 
-  - That all 
- 
-set php\\ https://blog.gtwang.org/linux/php-ini-large-file-upload-configuration/ 
myservice/edserver.1746944025.txt.gz · 上一次變更: 由 eddie

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki