--------------- <> -----------------
--- KHOA HỌC - CÔNG NGHỆ - GIÁO DỤC - VIỆC LÀM ---
--- Học để đi cùng bà con trên thế giới ---

Tìm kiếm trong Blog

WordPress (2) - XAMPP

Bài trước: WordPress (1) - Tổng quan
-----

2. XAMPP

2.1 XAMPP là gì?

Như đã biết, Web Server gồm có phần cứng, hệ điều hành, phần mềm Web Server (hay HTTP Server) và nội dung của Website.

Phần này sẽ dựng một Web Server xem hình hài của nó như thế nào. Hiện tại, máy bạn đã có sẵn phần cứng là cái laptop (desktop), hệ điều hành là Windows (Windows 10, 11). Vậy còn thiếu phần mềm Web Server và nội dung của Website.

Có nhiều phần mềm Web Server đang được sử dụng hiện nay, ví dụ: Apache, Nginx, IIS, GWS.

Vì phần mềm Apache được tích hợp trong XAMPP, nên chúng ta sẽ cài đặt XAMPP.

XAMPP là chương trình tạo Web Server, ngoài Apache, XAMPP còn được tích hợp sẵn: PHP, MySQL, FTP Server, Mail Server và các công cụ như phpMyAdmin, FileZilla.


Các kí hiệu của XAMPP có nghĩa là:

- X: viết tắt của Linux, Windows, Solaris và MacOS (cross-platform: đa nền tảng); XAMPP có thể chạy trên các hệ điều hành này

- A: viết tắt của Apache, phần mềm Web Server, là phần mềm mã nguồn mở, miễn phí, xử lý các yêu cầu gửi tới máy chủ dựa trên giao thức HTTP

- M: viết tắt của MariaDB (tên cũ là mySQL); hệ quản trị cơ sở dữ liệu mã nguồn mở, miễn phí

- P: viết tắt của PHP; biên dịch mã nguồn PHP

- P: viết tắt của Perl; biên dịch mã nguồn Perl

Các phần mềm có chức năng tương tự như XAMPP gồm:

- WAMP: Windows, Apache, Mysql, PHP

- LAMP: Linux, Apache, Mysql, PHP

- MAMP: Macintosh, Apache, Mysql, PHP

- WIMP: Windows, IIS, Mysql, PHP

2.2 Tải và cài đặt XAMPP

Tải XAMPP

- Để tải XAMPP, vào trang web: https://www.apachefriends.org/download.html

- Chọn bản XAMPP phù hợp với máy của bạn, ví dụ máy đang chạy Windows sẽ chọn bản XAMPP for Windows (145MB).

Cài đặt XAMPP

- Sau khi tải XAMPP về máy, bấm đúp chuột vào tập tin vừa tải về để cài đặt

- Bạn sẽ nhận được thông báo sau:



- Bạn nên tập thói quen đọc để hiểu các thông báo lỗi hoặc cảnh báo, khi hiểu rồi, bạn sẽ suy đoán được “chuyện gì” đã xảy ra, và có được định hướng để tìm kiếm giải pháp hoặc có luôn giải pháp.

- Như thông báo trên, là một cảnh báo của quá trình cài đặt XAMPP, nó nói rằng hệ thống UAC của Windows đang hoạt động, và UAC sẽ hạn chế một số hoạt động của XAMPP, như không cho quyền ghi vào thư mục C:\Program Files. Giải pháp là bạn không nên cài đặt XAMPP vào C:\Program Files, hoặc bạn có thể tắt UAC. 

- Bạn không nên tắt UAC vì nó ảnh hưởng đến an toàn của máy tính, vậy chúng ta sẽ cài đặt XAMPP vào C:\

- Trong quá trình cài đặt, bạn chỉ cần chọn theo các thiết lập mặc định, bấm Next để hoàn thành

- Sau khi cài đặt xong, bạn sẽ được gợi ý để chạy XAMPP, bạn có thể đồng ý hoặc không. Vì phần tiếp theo chúng ta sẽ cùng tìm hiểu chi tiết hơn về quá trình chạy XAMPP.

2.3 Chạy chương trình XAMPP

Kiểm tra xem trên máy đã cài đặt XAMPP hay chưa?

Ở bước trước, bạn đã thực hiện cài đặt XAMPP, tuy nhiên, không phải khi nào quá trình cài đặt cũng thành công. Hoặc khi bạn sử dụng một máy tính mới thì bạn không thể biết được là trên máy tính đã có cài XAMPP hay chưa?

Có một số cách để kiểm tra XAMPP đã được cài đặt thành công trên máy tính Windows của bạn hay chưa:

Cách 1: Kiểm tra biểu tượng và menu Start

- Gõ từ khóa "XAMPP Control Panel" vào thanh tìm kiếm của Windows. Nếu ứng dụng đã được cài đặt, nó sẽ hiện ra trong kết quả tìm kiếm

- Kiểm tra xem có biểu tượng XAMPP nào trên màn hình nền (desktop) hoặc trong thanh tác vụ (taskbar) hay không. Lưu ý: khi cài đặt, bạn không chọn chế độ này thì sẽ không thấy XAMPP, mặc dù bạn đã cài đặt XAMPP thành công

Cách 2: Kiểm tra thư mục cài đặt

Vì XAMPP thường được khuyên cài đặt vào một thư mục gốc để tránh xung đột quyền ghi (của UAC), bạn có thể kiểm tra trực tiếp ổ đĩa:

- Mở File Explorer (hoặc My Computer, This PC)

- Tìm thư mục có tên là xampp (hoặc XAMPP) tại gốc ổ đĩa (C:\)

- Nếu bạn tìm thấy thư mục này, tức là XAMPP đã được cài đặt. Bên trong thư mục này, bạn sẽ thấy tập tin thực thi chính: xampp-control.exe

Cách 3: Kiểm tra qua chương trình đã cài đặt (áp dụng trên Windows)

- Nếu 2 các cách trên không thấy, bạn có thể kiểm tra danh sách chương trình đã cài đặt

- Vào Settings > Apps > Apps & features 

- Tìm kiếm trong danh sách các ứng dụng được cài đặt trên máy tính của bạn với từ khóa "XAMPP"

- Nếu tìm thấy ứng dụng XAMPP, nghĩa là phần mềm đã được cài đặt

Chạy XAMPP

Để chạy XAMPP, bạn vào gõ từ khóa XAMPP vào thanh tìm kiếm của Windows, hoặc tìm trong menu Start. Chạy chương trình có tên là XAMPP Control Panel (bảng điều khiển XAMPP).

Xem hình minh họa:


Các dịch vụ quan trọng của XAMPP

Trong Bảng điều khiển XAMPP, có 5 dịch vụ (service):

Dịch vụ

Chức năng

Cổng Mặc định

Mô tả

Apache

Web Server

80, 443 (SSL)

Bắt buộc phải chạy để xem website (HTML, PHP) trên trình duyệt

MySQL

Database Server

3306

Bắt buộc phải chạy để chạy WordPress và các ứng dụng cần lưu trữ dữ liệu

FileZilla

FTP Server

21

Tùy chọn, dùng để giả lập môi trường FTP nếu cần

Mercury

Mail Server

25

Tùy chọn, dùng để kiểm thử chức năng gửi email trong ứng dụng

Tomcat

Java Servlet Container

8080

Tùy chọn, chỉ dùng cho các ứng dụng được viết bằng ngôn ngữ Java

Vì bạn đang học PHP và WordPress, nên cần quan tâm tới 2 dịch vụ là Apache và MySQL. Hai dịch vụ này giúp bạn có thể chạy một ứng dụng web trên máy cục bộ (localhost).

Chạy XAMPP

Thông thường, khi bạn chạy XAMPP Control Panel và bấm nút Start, các module (Apache, MySQL) sẽ chạy dưới chế độ ứng dụng (application mode). Tuy nhiên, bạn có thể thiết lập để Apache và MySQL chạy như các dịch vụ của Windows (Windows service).

Để đơn giản, chúng ta sẽ chạy Apache và MySQL theo chế độ ứng dụng: mở XAMPP Control Panel > bấm nút Start bên cột Actions tương ứng.

Kiểm tra xem Apache và MySQL đã chạy hay chưa

Có 3 cách để xem Apache và MySQL đã chạy hay chưa:

Cách 1: Kiểm tra qua XAMPP Control Panel

- Sau khi bấm Start cho Apache và MySQL, nút Start phải chuyển thành nút Stop

- Kiểm tra cột PID(s) và Port(s). Nếu các số cổng (ví dụ: 80, 443 cho Apache; 3306 cho MySQL) đã xuất hiện, nghĩa là dịch vụ đang chạy

Cách 2: Kiểm tra Apache bằng trình duyệt

- Mở trình duyệt web của bạn (Chrome, Firefox)

- Truy cập địa chỉ: http://localhost hoặc http://127.0.0.1

- Nếu xuất hiện trang chào mừng của XAMPP (Dashboard), nghĩa là dịch vụ Apache đang chạy bình thường

Cách 3: Kiểm tra MySQL

- Từ trang Dashboard của XAMPP, nhấp vào phpMyAdmin (thường ở góc trên bên phải)

- Nếu bạn thấy giao diện quản lý cơ sở dữ liệu (phpMyAdmin), nghĩa là dịch vụ MySQL đang chạy bình thường

Một số lỗi hay gặp phải và cách khắc phục

Với Apache và MySQL, thường gặp lỗi sau:

- Cài đặt vào thư mục mà bạn không có quyền ghi, ví dụ cảnh báo của UAC khi bạn cài XAMPP vào C:\Program Files. Vì vậy, bạn không nên cài vào thư mục này.

- Lỗi xung đột cổng (port conflict) là nguyên nhân phổ biến nhất khiến Apache hoặc MySQL không khởi động được. Cụ thể:

Nguyên nhân gây xung đột

Mô tả

IIS (Windows)

Internet Information Services của Microsoft có thể chiếm cổng 80

Skype

Phiên bản cũ của Skype có thể sử dụng cổng 80/443

World Wide Web Publishing Service

Dịch vụ tích hợp của Windows chiếm cổng 80

Ứng dụng khác

Bất kỳ Web Server hoặc dịch vụ nào khác đang chạy (ví dụ: TeamViewer, dịch vụ VPN)

Cách khắc phục xung đột cổng với Apache

Cách 1: Thay đổi cổng Apache (bạn nên chọn cách này)

- Trong XAMPP Control Panel, nhấp vào nút Config của Apache > chọn httpd.conf

- Tìm và thay đổi dòng: Listen 80 thành Listen 8080

- Nhấp vào nút Config của Apache > chọn httpd-ssl.conf > Tìm và thay đổi dòng: Listen 443 thành Listen 4433

- Lưu lại các tập tin vừa bị sửa và khởi động lại Apache. Sau khi thay đổi, bạn phải truy cập website bằng cổng mới: http://localhost:8080.

Cách 2: Tắt chương trình, dịch vụ gây xung đột cổng

- Tìm trong Services Manager của Windows các chương trình, dịch vụ mà bạn nghi ngờ nó chiếm cổng của Apache và MySQL, tắt chúng đi. Ví dụ: IIS, Skype, World Wide Web Publishing Service, VPN, TeamViewer.

Cách khắc phục xung đột cổng với MySQL

Cách 1: Thay đổi cổng MySQL (bạn nên chọn cách này)

- Trong XAMPP Control Panel, nhấp vào nút Config của MySQL > chọn my.ini

- Tìm và thay đổi dòng: port = 3306 thành port = 3307 (hoặc một số khác)

- Lưu tập tin và khởi động lại MySQL

Cách 2: Tắt hoặc dừng dịch vụ database khác đang chạy trên cổng 3306

2.4 Bài tập và câu hỏi

Bài tập 2a. Cấu hình để Apache chạy trên cổng 8080 và 4433. Mục tiêu: khi mở trình duyệt, gõ 2 đường dẫn sau sẽ xuất hiện trang web chào mừng của XAMPP (dashboard). http://localhost:8080 và https://localhost:4433.

Bài tập 2b. Cấu hình để MySQL chạy trên cổng 3307. Mục tiêu: từ trang Dashboard của XAMPP, nhấp vào phpMyAdmin, sẽ thấy giao diện quản lý cơ sở dữ liệu (phpMyAdmin).

Câu hỏi 1. Trong XAMPP có các dịch vụ sau, phát biểu nào không đúng?

A. Apache

B. MySQL

C. IIS

D. Tomcat

Câu 2. Một số phát biểu về XAMPP, phát biểu nào không đúng?

A. Không nên cài XAMPP vào thư mục C:\Program Files

B. Apache và MySQL có thể chạy ở chế độ ứng dụng và chế độ dịch vụ

C. Apache và MySQL không chạy được, thường là do xung đột cổng với các dịch vụ/ứng dụng khác

D. Bạn không thể sửa cổng chạy mặc định của Apache và MySQL

-----
Bài sau: WordPress (3) - Tải và chạy WordPress

Math_English_Grade6 (5) - Applications of rates

Previous: Math_English_Grade6 (4) - Tables of Ratios
-----

6.5 Applications of rates

Introduction

Janelle and her family are traveling around Europe. They're spending a few days in Spain and plan to travel to France, Switzerland, and Italy later. When they take a train from Madrid to Barcelona, Janelle asks her brother Andrew how long the journey will take. Andrew tells her that they will reach Barcelona in three hours.

Janelle is surprised to see that their train reaches Barcelona in three hours, just as Andrew said. She wonders if there's a relationship between the distance traveled and the time taken.

In this lesson, you'll relate the distance traveled to the time taken using a rate. You'll also study how rates apply to other everyday situations.

Watch the video on the next screen how a rate can be used to find the speed of a train.

Transcript

There are many types of rates. One of the most common rates is speed.

An object speed is the distance it travels over one unit of time. We can use this equation to find an object’s speed.

Let's look at an example, Janelle is traveling by train from Madrid to Barcelona. She knows that the distance between these two cities is three hundred and ninety miles because she also knows that the train covers this distance in three hours. Janelle can find the train speed using the speed formula.

She divides the distance traveled. By the time it takes to get from Madrid to Barcelona. Let's look at the map to see if this calculation makes sense.

The distance between Madrid and Barcelona is three hundred and ninety miles divided by three hours of travel. Each hour the train moves a distance of one hundred thirty miles, so the rate of travel is one hundred thirty miles per hour.

Next stop. Barcelona.


Question

Select the correct answer.

Rosemarie drove from Philadelphia, Pennsylvania, to Pittsburgh, Pennsylvania. The distance between Philadelphia and Pittsburgh is 305 miles. Rosemarie reached Pittsburgh 5 hours after she left Philadelphia. What is the speed at which she drove her car?

A. 81 miles/hour

B. 61 miles/hour

C. 51 miles/hour

D. 71 miles/hour

Distance

You can find the distance between two places if you know the speed and the travel time by writing the formula Speed = Distance / Time so that distance is on the left side: Distance = Speed x Time

Here's an example of how we can use the formula. Theodore is riding a bicycle at a speed of 15 miles/hour. We'll find the distance he covers in 5 hours:

distance = speed × time
distance = 15 miles/hour × 5 hours = 75 miles.

You can use another version of this formula to find the time taken to travel a given distance if you know the speed:

Time = Distance / Speed

Questions

Answer the question below. Type your response in the space provided.

Althea traveled 280 miles at a speed of 70 miles/hour. How much time did she take to cover this distance?

[     ]

Unit Price

Unit prices are another type of ratio. We come across unit prices in everyday situations such as buying groceries. The unit price is the amount of money paid for a single item. A unit price is equal to the ratio of the total cost to the number of units sold:

unit price = total cost / total number of units sold

You can also use this formula to find total cost when you already know the unit cost. To do so, rewrite the equation above in this form: 

total cost = unit price x total number of units sold

For example, let's say that oranges cost $2 per pound, and you want to find the cost of 4 pounds of oranges. You can plug the known values into this equation:

total cost = 4 pounds x $2 per pound 

So, 4 pounds of oranges will cost $8.

Let's look at another example involving unit price. Annie bought 6 pounds of berries for $12 and wants to buy another 10 pounds. She wants to know how much money she needs to pay for 10 pounds.

Annie first needs to find the unit price, or the price of 1 pound:

cost of 6 pounds of berries = $12

unit price = total cost / total number of units

unit price of berries = $12 / 6 = $2 per pound

Now that we know the cost per pound, we can calculate the cost of 10 pounds:

total cost of 10 pounds = unit price × number of pounds
total cost = $2 per pound × 10 pounds = $20.

Lesson Activity

Applications of Rates

The Lesson Activity will help you meet these educational goals:

- Content Knowledge—You will solve unit rate problems, including those that involve unit pricing and constant speed.

- Mathematical Practices—You will make sense of problems and solve them.

- STEM—You will use mathematical processes and analysis in scientific investigation to solve real-world design problems.

- 21st Century Skills—You will use critical-thinking and problem-solving skills.

Directions

Read the instructions for this self-checked activity. Type in your response to each question, and check your answers. At the end of the activity, write a brief evaluation of your work.

Activity

Janelle and her family are traveling around Europe by train. Their trip will begin in Madrid, Spain, and will end in Rome, Italy.

The first part of their train journey, from Madrid, Spain, to Barcelona, Spain, took 3 hours. Use this information to solve the problems below.


Part A

If the train went 390 miles in 3 hours, what was the speed of the train in miles per hour?

[      ]

Part B

The distance from Barcelona, Spain, to Paris, France, is 650 miles. If the train from Barcelona to Paris travels 130 miles per hour, how long does it take to get from Barcelona to Paris?

[    ]

Part C

If the trip from Paris, France, to Geneva, Switzerland, takes 5 hours, and the train travels at 130 miles per hour, how many miles from Paris is Geneva?

Part D

The train from Geneva, Switzerland, to Milan, Italy, travels at 100 miles per hour, and the two cities are 200 miles apart. How long does the journey from Geneva to Milan take?

Part E

If the train from Milan, Italy, to Rome, Italy, takes 6 hours at a speed of 130 miles per hour, how many miles from Milan is Rome?

Part F

Janelle’s parents got a special offer of $75 per person for each train trip. If there are 4 people in Janelle’s family, what is the total cost of each train trip?

Part G

What is the cost of 5 train trips for all 4 family members?

-----

Question 11/15

Gaston is buying fruit at a local grocery store. This table shows the cost per pound of each type of fruit. Match each quantity of fruit with its total cost. Drag the items on the left to the correct location on the right.


12/15

Other Ways to Use Rates

In the Lesson Activity, you used the speed to find the distance traveled and the time taken. You can apply the concept of rates to other situations too.

Let's look at an example of a rate calculation. If someone mows 8 lawns in 2 days, the rate at which the person works is

number of lawn mowed per day = (number of lawns mowed / number of days = 8/2 = 4

The person mows 4 lawns per day.

Let's look at another example in which we know the unit rate. If someone who can mow 3 lawns per day mows 18 lawns, you can find the time needed to mow 18 lawns:

number of days need to mow 18 lawns = number of lawn mowed / number of lawns mowed per day

number of days needed to mow 18 lawns = 18/3 = 6 days

13/15

Another way you can use rates is to find a worker's wages for a specific number of units of work: total wages = wages per unit × number of units of work. Units of work can be days, hours, or items such as lawns mowed, cars washed, and windows cleaned.

Here's an example of how to apply wages per unit of work. Tony washes cars at the local garage. He earned $400 for washing 10 cars last week. This week, his wage for washing each car has been increased by $3. Let's calculate how much he will earn if he washes 10 cars this week.

First we calculate Anthony's wages per car last week:

wages per car = total wages / number of cars washed = $400 / 10 = $40

Because Anthony's wage has gone up by $3 per car, he will earn $43 per car this week. If he again washes 10 cars:

total wages = wages per car x number of cars washed = $43 per car x 10 cars = $430

Anthony will earn $430 if he washes 10 cars this week.

-----
Next: