2025年5月10日 星期六

Ubuntu 24.04 安裝 chcweb 專案的過程記錄

系列文章:
1.Ubuntu 24.04 安裝 chcweb 專案的過程記錄
2.Ubuntu 24.04 安裝 laravel 5.7 的過程記錄
3.laravel 5.7 初始相關設定與注意事項
4.想修改 chcweb 出現的問題解決集

感恩和東國小王麒富組長的指導

一、系統更新:
sudo apt-get update
sudo apt-get upgrade

二、安裝解壓縮工具、wget 與 git
sudo apt-get install unzip zip wget git

三、安裝apache2
sudo apt-get install apache2

四、安裝php 7.3 、擴充包與 apache2 模組
//安裝軟體源拓展工具
sudo apt -y install software-properties-common apt-transport-https lsb-release ca-certificates
//安裝php 7.3 ppa
sudo add-apt-repository ppa:ondrej/php
sudo apt update
//安裝php 7.3 、擴充包
sudo apt-get install php7.3 php7.3-fpm php7.3-cli php7.3-json php7.3-mbstring php7.3-gd php7.3-xml php7.3-ldap php7.3-mysql php7.3-curl php7.3-zip php7.3-imap -y
//安裝php 7.3  apache2 模組
sudo apt-get install libapache2-mod-php7.3 -y

//檢查 php 版本
php -v

五、安裝 mariadb
sudo apt-get install mariadb-server -y
sudo -i
//設定安全相關
mysql_secure_installation
exit

六、安裝composer
//下載composer
wget -c https://getcomposer.org/composer.phar

//將composer.phar設為可執行
chmod +x composer.phar

//移到/usr/local/bin,並改名composer,隨時可呼叫
sudo mv composer.phar /usr/local/bin/composer

//測試
composer

七、於html下安裝chcschool,放置在/home/webadmin/html/
cd /home/webadmin/
mkdir html
cd /var/www/
sudo mv html html2
sudo ln -s /home/webadmin/html /var/www/html    (此時 /var/www/ 有兩個目錄 html html2)
cd /home/webadmin/html/

八、建立資料庫chcweb
//建立資料庫chcweb
mysqladmin -uroot -p create chcweb

九、下載、匯入資料庫chcweb、安裝與設定 chcweb
//下載 chcweb
git clone https://github.com/wangchifu/chcweb.git
//進入chcweb目錄
cd /home/webadmin/html/chcweb
//匯入資料庫chcweb
mysql -uroot -p  chcweb < /home/webadmin/html/chcweb/database/chcweb.sql
//安裝
composer install
cp .env.example .env
sudo nano .env
.env 中 DB_DATABASE=chcweb
.env 中 DB_USERNAME 及 DB_PASSWORD 填上正確資料
php artisan key:generate
php artisan storage:link
sudo chmod 777 -R storage bootstrap/cache

帳密
帳號 admin 密碼 demo1234

十、加入apache虛擬主機
sudo nano /etc/apache2/sites-available/chcweb.conf 
寫入:
-------------------------------------------------------------------------------------
<VirtualHost *:80>
   ServerName localhost

   ServerAdmin webmaster@localhost
   DocumentRoot /home/webadmin/html/chcweb/public


<Directory /home/webadmin/html/chcweb/public>
         Options -Indexes
         AllowOverride All
         Require all granted
   
</Directory>

   ErrorLog ${APACHE_LOG_DIR}/error.log
   CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

-------------------------------------------------------------------------------------

//如果要取消原本80網頁
sudo a2dissite 000-default.conf
//啟用新網頁
sudo a2ensite chcweb.conf
sudo a2enmod rewrite
sudo service apache2 restart
//更改特定目錄擁有者為www-data,及777
cd /home/webadmin/html/chcweb/
sudo chown -R www-data storage/ bootstrap/cache/
sudo chmod -R 777 storage/ bootstrap/cache/

注意網站運行的重大設定
/etc/php/7.3/apache2/php.ini
sudo nano /etc/php/7.3/apache2/php.ini
注意事項:
1.檢查已安裝的php 版本
update-alternatives --list php
2.切換php 版本
sudo update-alternatives --config php
3.確認是否切換成功
php -v
4.切換 Apache 用的 PHP 版本
(1). 停用舊版本
sudo a2dismod php8.4
(2). 啟用新版本
sudo a2enmod php7.3
(3). 重啟 Apache
sudo systemctl restart apache2
5.Mysql 注意事項
(1)創建該使用者並設置密碼:
CREATE USER 'webadmin'@'localhost' IDENTIFIED BY '密碼';
(2)如果想給這個使用者更多權限:
GRANT ALL PRIVILEGES ON *.* TO 'webadmin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;


資料來源:


2025年2月7日 星期五

Ubuntu 22.04 建立PHP 7.3 的網頁伺服器LAMP 相關備忘

        最近,要將網頁Xoops 移機到虛擬機。需要將虛擬機內的LAMP環境弄成原先LAMP環境。經查詢,發現原先LAMP環境如下:



所以,開始要進行相關的措施:
一、系統更新:
sudo apt-get update
sudo apt-get upgrade

二、安裝apache2
sudo apt-get install apache2

三、安裝php 7.3 、擴充包與 apache2 模組
安裝php 7.3 ppa
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
安裝php 7.3 、擴充包
sudo apt-get install php7.3 php7.3-fpm  -y
sudo apt-get install php7.3-mysql php7.3-mbstring php7.3-xml php7.3-gd php7.3-curl php7.3-zip -y
安裝php 7.3  apache2 模組
sudo apt-get libapache2-mod-php7.3 -y

檢查 php 版本
php -v

三、安裝 mariadb
sudo apt-get install mariadb-server -y
sudo -i
設定安全相關
mysql_secure_installation

四、Xoops 舊機備份
1.舊網頁備份
sudo tar zcvf  /var/www  www.tar.gz
2.舊資料庫備份
mysqldump  -uroot  -p  --default-character-set=utf8  skjh > /home/webadmin/skjh.sql
3.編輯舊資料庫備份,將舊IP 改成新IP
sudo vi /home/webadmin/skjh.sql
例子
:1,$s/舊IP/新IP/s
:1,$s/172.20.4.1/192.168.10.2/g
4.將編輯過的舊資料庫匯入新機器
mysqladmin -uroot -p create skjh
mysql -uroot -p  skjh < /home/webadmin/skjh.sql
5.在新機器解壓舊網頁,並搬移至/var/www/
sudo tar zxvf www.tar.gz
sudo mv ~/var/www/skjh  /var/www/
sudo mv ~/var/www/html/skjh /var/www/html/
6.若發現舊資料庫編輯有誤,但已匯入新機器資料庫。則要進行刪除,可至
http://localhost/skjh/modules/tad_adm/pma.php 進行刪除

注意網站運行的重大設定
/etc/php/7.3/php.ini


資料來源:
1.Ubuntu22.04 开发环境配置(第七篇-Apache2+Php8.3)
https://blog.csdn.net/lanhai0859/article/details/1427129672.
2.如何在 Ubuntu 22.04 上安装 PHP 7.2/7.3/7.4
https://cn.linux-console.net/?p=30359
3.[教學][Ubuntu 架站] 在 Ubuntu 22.04 安裝 Apache 網頁伺服器,並架設多個網站(多網域)
https://ui-code.com/archives/622#:~:text=Apache%20%E6%98%AF%E5%85%A8%E7%90%83%E6%87%89%E7%94%A8%E6%9C%80%E5%BB%A3%E6%B3%9B%E7%9A%84%E7%B6%B2%E9%A0%81%E4%BC%BA%E6%9C%8D%E5%99%A8%EF%BC%88Web%20Server%EF%BC%89%EF%BC%8C%E5%9C%A8%E9%80%99%E4%BB%BD%E6%8C%87%E5%8D%97%E4%B8%AD%EF%BC%8C%E6%88%91%E5%80%91%E5%B0%87%E6%9C%83%E5%9C%A8%E9%81%8B%E8%A1%8CUbuntu%2022.04%20%E7%9A%84%E4%BC%BA%E6%9C%8D%E5%99%A8%E4%B8%8A%EF%BC%8C%E5%AE%89%E8%A3%9D%E4%B8%A6%E9%85%8D%E7%BD%AE,Apache2%20HTTP%20Web%20%E6%9C%8D%E5%8B%99%E5%99%A8%E3%80%82%20%E6%82%A8%E5%8F%AF%E4%BB%A5%E6%A0%B9%E6%93%9A%E9%80%99%E4%BB%BD%E6%8C%87%E5%8D%97%EF%BC%8C%E4%BE%86%E5%BB%BA%E7%AB%8B%E5%96%AE%E4%B8%80%E7%B6%B2%E5%9F%9F%E6%88%96%E6%98%AF%E5%A4%9A%E5%80%8B%E7%B6%B2%E5%9F%9F%EF%BC%88%E5%A4%9A%E7%B6%B2%E5%9F%9F%EF%BC%89%E7%9A%84%E8%99%9B%E6%93%AC%E4%B8%BB%E6%A9%9F%E3%80%82
4.在Ubuntu 7.3上安裝 PHP 22.04 的簡單方法
https://orcacore.com/install-php-7-3-ubuntu-22-04/
5.MySQL登入:root預設密碼,1個必學的設定命令
https://zanzan.tw/archives/20192
6.安裝 LAMP – 如何在 Ubuntu 上安裝 LAMP
https://www.taki.com.tw/blog/how-to-install-lamp-on-ubuntu/?srsltid=AfmBOopVtQehK_Culj4eo8z-K9V9l6gDY1KjRQsrbfRtEcZ_sawkFiyH
7.How to Set Static IP Address on Ubuntu Server 22.04
https://hackmd.io/@JGoK5hXkSQuAC32KMw8hHw/Hklw-U7aj
8.Xoops移機的步驟
https://dchesmis.blogspot.com/2016/09/xoops.html

2024年9月30日 星期一

只要點兩下,就能夠將InputAndOutput資料夾底下的子子孫孫資料夾內所有Word通通轉成PDF

系列文章:
01.python 不管何時何地,只要點兩下,資料夾內的所有pdf都會合併成一個pdf
https://skjhcreator.blogspot.com/2022/06/pythonpdfpdf.html
02.python 只要點兩下,分別對各資料夾內的pdf合併,合併後的檔名要讓人知道來自哪個資料夾 
https://skjhcreator.blogspot.com/2022/06/python-pdf.html
03. 只要點兩下,就能將一堆的Doc與Docx 轉成 PDF
03.https://skjhcreator.blogspot.com/2023/05/docdocx-pdf.html
04.只要點兩下,就能將一堆的JPG轉成一個PDF,並以JPG所在的資料夾名稱為PDF的檔名
04.https://skjhcreator.blogspot.com/2023/06/jpgpdfjpgpdf.html
05.只要點兩下,就能將放進input的一堆PDF轉成各自的WORD
05.https://skjhcreator.blogspot.com/2023/10/inputpdfword.html
06.只要點兩下,就能將放進input的一堆PDF轉成在ouput資料夾內的各自的WORD 
06.https://skjhcreator.blogspot.com/2023/10/inputpdfouputword.html
07.只要點兩下,就能夠將InputAndOutput資料夾底下的子子孫孫資料夾內所有Word通通轉成PDF
07.https://skjhcreator.blogspot.com/2024/09/word-word-pdf.html
08.只要點兩下,就可以將資料夾input內的所有Word通通轉成一個PDF
08.https://skjhcreator.blogspot.com/2025/07/inputwordpdf.html
09.只要點兩下兩次,就能依照設定拆分指定PDF頁數並合併成設定好的一個PDF
09.https://skjhcreator.blogspot.com/2025/09/pdfpdf.html
10.只要點兩下,就能將input資料夾內所有PDF進行容量壓縮
10.https://skjhcreator.blogspot.com/2026/04/inputpdf.html

        由於系列文章1~4 都是在Input資料夾內討論 Word 與 Pdf 互轉。面臨到資料夾內有子子孫孫資料夾,子子孫孫資料夾內有Word。那要如何將所有子子孫孫資料夾內的所有Word找出,並將之轉換成PDF?換句話說,可不可以有個程式,能夠將整理好的資料夾內所有Word 通通轉成PDF,即便資料夾內有很多個子資料夾,子資料夾內又有子資料夾。不管在哪個資料夾內的Word 都要將其找出並轉成PDF,轉出的PDF就在相對應的Word旁。

Since articles 1 to 4 discuss the conversion between Word and PDF within the Input folder, we are faced with the situation where there are nested subfolders containing Word documents. How can we find all the Word documents in these nested subfolders and convert them into PDF? In other words, is it possible to have a program that can convert all the Word documents in the organized folder, regardless of how many subfolders there are, and even if those subfolders contain their own subfolders? We need to find all the Word documents no matter where they are located within the folder structure and convert them into PDFs, with the resulting PDFs saved next to their corresponding Word files.

         下載檔案解壓密碼:demo1234
Here is the website where you can download the program and find instructions:
Download。Extraction Password: demo1234
使用教學(Instructional videos):





2024年9月26日 星期四

只要點兩下,就可以開機後自動清除2024年彰化縣中小學電腦教室學生機電腦D槽內學生資料

         2024年彰化縣中小學電腦教室學生機的磁碟空間分成C、D兩個槽。由於C槽會進行開機還原,而D槽卻不會開機還原。因此,學生會將自己的資料存放在D槽。換言之,學生會利用D槽空間建置自己的娛樂,進而影響上課。如果放任學生對D槽存取資料,恐怕學生日後上資訊科技課便不再專心。希望在減輕資訊組長或維護電腦教室的人員工作負擔下,能夠讓其點兩下,就可以開機後自動清除電腦教室學生機D槽內學生資料。

         In 2024, the disk space of student computers in the computer classrooms of elementary and secondary schools in Changhua County is divided into two partitions: C and D. The C partition undergoes system restore on boot, while the D partition does not. Therefore, students tend to store their data on the D partition. In other words, students use the D partition to create their own entertainment, which can disrupt their focus during class. If students are allowed unrestricted access to the D partition, they may become inattentive in future information technology classes. We hope to reduce the workload of the IT coordinator or the personnel maintaining the computer classrooms, allowing them to simply double-click to automatically clear student data from the D partition after booting the computers.

         問題描述:如何在Windows 10 或 Windows 11 作業系統,在開機時自動執行系列文章1.只要點兩下,就可以一鍵清除2024年彰化縣中小學電腦教室學生機電腦D槽內學生資料。將系列文章1.只要點兩下,就可以一鍵清除2024年彰化縣中小學電腦教室學生機電腦D槽內學生資料。的程式放入開機執行的資料夾即可。開機執行的資料夾為%HomePath%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\

       Problem Description: How to automatically execute a program on startup in Windows 10 or Windows 11 that can clear student data from the D partition of student computers in the computer classrooms of elementary and secondary schools in Changhua County with just a double-click. To achieve this, place the program that clears the student data into the startup folder. The startup folder is located at %HomePath%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.

         下載檔案解壓密碼:demo1234
Here is the website where you can download the program and find instructions:
Download。Extraction Password: demo1234
使用教學(Instructional videos):



程式名稱:Move2StartUp.bat
程式內容:
@echo off
@echo off
REM :: BatchGotAdmin (Run as Admin code starts)
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
REM :: BatchGotAdmin (Run as Admin code ends)
REM :: Your codes should start from the following line
move "%~dp0StuPCdelDall.exe" "%HomePath%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\"
pause
exit






只要點兩下,就可以一鍵清除2024年彰化縣中小學電腦教室學生機電腦D槽內學生資料

        2024年彰化縣中小學電腦教室學生機的磁碟空間分成C、D兩個槽。由於C槽會進行開機還原,而D槽卻不會開機還原。因此,學生會將自己的資料存放在D槽。換言之,學生會利用D槽空間建置自己的娛樂,進而影響上課。如果放任學生對D槽存取資料,恐怕學生日後上資訊科技課便不再專心。希望在減輕資訊組長或維護電腦教室的人員工作負擔下,能夠讓其點兩下,就可以一鍵清除電腦教室學生機D槽內學生資料。

        In 2024, the disk space of student computers in the computer classrooms of elementary and secondary schools in Changhua County is divided into two partitions: C and D. The C partition undergoes system restore on boot, while the D partition does not. Therefore, students tend to store their data on the D partition. In other words, students use the D partition to create their own entertainment, which can disrupt their focus during class. If students are allowed unrestricted access to the D partition, they may become inattentive in future information technology classes. We hope to reduce the workload of the IT coordinator or the personnel maintaining the computer classrooms, allowing them to simply double-click to automatically clear student data from the D partition after booting the computers.

        咦!電腦內原本就有直接清除D槽資料的方法。不就是對準D槽,按滑鼠右鍵。就會出現下拉是選單,點選格式化:

        Oh! There is already a method to directly clear the data on the D partition in the computer. Just right-click on the D partition, and a dropdown menu will appear. Then select "Format."

點選開始,就可以了。
Just click on "Start," and you're good to go.
而且格式化的速度還不賴。很快就能進行下一台電腦的清除資料。那幹嘛還要進行開發?
Moreover, the formatting speed is quite good. You can quickly proceed to clear the data on the next computer. So why do we still need to develop a program?

        問題描述:D槽空間原本就有兩個基本資料夾,這兩個資料夾名稱分別是os 與ventoy。如果對D槽進行快速格式化,這兩個資料夾就會被格式化掉。接下來就會導致系統崩潰。希望這兩個資料夾能夠保留,並且清空D槽內學生自建資料。

        Problem Description: The D partition originally contains two basic folders named "os" and "ventoy." If a quick format is performed on the D partition, these two folders will be erased, which could lead to system crashes. We hope to retain these two folders while clearing out the student-created data within the D partition.

         下載檔案解壓密碼:demo1234
Here is the website where you can download the program and find instructions:
Download。Extraction Password: demo1234
使用教學(Instructional videos):





2024年1月25日 星期四

只要點兩下,傳統右鍵選單改回Win11右鍵選單

上一篇提到只要點兩下,就能將Win11選單回到傳統選單。但是有沒有方法能夠回到Win11選單呢?
         
         下載檔案解壓密碼:demo1234
Here is the website where you can download the program and find instructions:
Download。Extraction Password: demo1234
使用教學(Instructional videos):



檔案名稱:傳統右鍵選單改回Win11右鍵選單.bat
檔案內容:
@echo off
REM :: BatchGotAdmin (Run as Admin code starts)
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
REM :: BatchGotAdmin (Run as Admin code ends)
REM :: Your codes should start from the following line
reg add HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32 /f /ve
shutdown /r /f /t 0

只要點兩下,就能將Win11 右鍵選單 回復 傳統右鍵選單

系列文章:

         It's so frustrating! Every time I use the right-click menu in Windows 11, I have to take an extra step to get back to the traditional menu. Especially when compressing or extracting files, it feels like an unnecessary extra step. Is there any way to go back to the traditional menu? I hope to find a method to revert to the traditional menu.
        好辛苦!,每次用Windows 11 的右鍵選單,都還要再多一步,才能回到傳統選單。特別是壓縮檔案或是解壓縮檔案,都會覺得多一步很麻煩,難道沒有方法能夠回到傳統選單?希望能找到方法回到傳統選單。
         下載檔案解壓密碼:demo1234
Here is the website where you can download the program and find instructions:
Download。Extraction Password: demo1234
使用教學(Instructional videos):



檔案名稱:Win11右鍵選單改回傳統右鍵選單.bat
檔案內容:
@echo off
REM :: BatchGotAdmin (Run as Admin code starts)
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
REM :: BatchGotAdmin (Run as Admin code ends)
REM :: Your codes should start from the following line
reg add HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32 /f /ve
shutdown /r /f /t 0

只要點兩下,就能將input資料夾內所有m4a 轉檔為 mp3

         最近需要將m4a檔案轉檔為mp3,所以寫python程式來處理。希望將很多的m4a放進input資料夾內,只要點兩下滑鼠就能將這些m4a 通通轉檔為 mp3。          Recently, I needed to convert M4A files in...