Skip to content

วันที่ 27 พฤษภาคม 68

1. การพัฒนา Website สำนักงานสาธารณสุขจังหวัดชัยภูมิ
- ศึกษาการใช้งาน และการแก้ไขข้อมูลจาก Forms ลงฐานข้อมูล
2. จำลองเครื่องแม่ข่าย
- ศึกษา Command Line Linux พื้นฐาน
- ติดตั้ง Package สำหรับบริการ Web Server

1. การพัฒนา Website สำนักงานสาธารณสุขจังหวัดชัยภูมิ
หน้าแสดงข่าวทั้งหมด
image.png

สร้างหน้าตอนกดดูข่าว
ng generate component news-detail
image.png
ใน news.service.ts เพิ่ม getNewsById
getNewsById(id: number): Observable<News> {
return this.http.get<News>(`${this.apiUrl}/${id}`);
}
ใน api server.js ใช้ GET ข่าวตาม id
app.get('/api/news/:id', (req, res) => {
const id = req.params.id;
const sql = 'SELECT * FROM news WHERE id = ?';
db.query(sql, [id], (err, results) => {
if (err || results.length === 0) return res.status(404).send('Not found');
res.json(results[0]);
});
});
image.png

แก้ไขข้อมูล
สร้างหน้าแก้ไขข่าว
ng generate component news-edit
image.png
ใน news.service.ts เพิ่ม updateNews
updateNews(id: number, newsData: Partial<News>): Observable<any> {
return this.http.put(`${this.apiUrl}/${id}`, newsData);
}
ใน api server.js ใช้ PUT
app.put('/api/news/:id', upload.array('images'), (req, res) => {...
const updateSql = 'UPDATE news SET title = ?, content = ?, images = ?, updated_at = ? WHERE id = ?';
}
image.png
image.png
แก้ไขได้แล้ว

2. จำลองเครื่องแม่ข่าย
- ศึกษา Command Line Linux พื้นฐาน
คำสั่งพื้นฐาน
คำสั่ง
ความหมาย
ตัวอย่าง
pwd
แสดง path ปัจจุบัน
pwd
ls
แสดงไฟล์/โฟลเดอร์ในไดเรกทอรี
ls -l
cd
เปลี่ยนไดเรกทอรี
cd Documents
mkdir
สร้างโฟลเดอร์
mkdir new_folder
touch
สร้างไฟล์เปล่า
touch file.txt
cp
คัดลอกไฟล์/โฟลเดอร์
cp file.txt backup.txt
mv
ย้าย/เปลี่ยนชื่อไฟล์
mv old.txt new.txt
rm
ลบไฟล์
rm file.txt
rmdir
ลบโฟลเดอร์เปล่า
rmdir empty_folder
cat
แสดงเนื้อหาไฟล์
cat file.txt
nano
เปิด editor แบบ command line
nano file.txt
man
อ่านคู่มือของคำสั่ง
man ls
There are no rows in this table
คำสั่งเกี่ยวกับสิทธิ์และผู้ใช้งาน
คำสั่ง
ความหมาย
ตัวอย่าง
chmod
เปลี่ยน permission
chmod 755 script.sh
chown
เปลี่ยนเจ้าของไฟล์
chown user:user file.txt
sudo
เรียกใช้คำสั่งในฐานะ root
sudo apt update
There are no rows in this table
คำสั่งเกี่ยวกับระบบและกระบวนการ
คำสั่ง
ความหมาย
ตัวอย่าง
ps
ดู process ที่กำลังทำงาน
ps aux
top
แสดง process แบบเรียลไทม์
top
kill
ยุติ process
kill 1234
df
แสดงพื้นที่ดิสก์
df -h
free
แสดง RAM ที่ใช้
free -m
There are no rows in this table

- ติดตั้ง Package สำหรับบริการ Web Server
รหัส 1234
เข้า Terminal
update ระบบด้วยคำสั่ง
sudo apt-get update
sudo apt-get upgrade

ที่ต้องติดตั้งสำหรับโปรเจกต์
ติดตั้ง Node.js และ npm
sudo apt update
sudo apt install nodejs npm -y
npm install express cors body-parser

ติดตั้ง Angular CLI
npm install -g @angular/cli
ติดตั้ง MySQL
sudo apt install mysql-server -y
npm install mysql2

ติดตั้ง Filezilla Server
ติดตั้งโปรแกรม vsftpd โดยใช้คำสั่ง (FTP Server)
sudo apt-get install vsftpd
ติดตั้งโปรแกรม FileZilla
sudo apt-get install filezilla

Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.