To install the http-server
package on Ubuntu, you can follow these steps:
- Open a terminal on your Ubuntu system. You can do this by pressing
Ctrl + Alt + T
or by searching for “Terminal” in the application launcher. - Update the packages list to ensure you have the latest versions by running the following command:
sudo apt update
- Once the update is complete, you can install
http-server
usingnpm
(Node Package Manager). Ensure that you have Node.js installed on your system by typing:node --version
If Node.js is not installed, you can install it by running:sudo apt install nodejs
- Next, install
http-server
globally by running the following command:sudo npm install --global http-server
This command will installhttp-server
globally on your system, making it accessible from anywhere. - After the installation is complete, you can use
http-server
by navigating to the directory containing your website files and running the following command:http-server
This will start the HTTP server, and it will print the available URLs where you can access your website locally. - By default,
http-server
will serve your files on port 8080. If you want to use a different port, you can provide it as an argument when starting the server. For example, to use port 3000, run:http-server -p 3000
That’s it! You have successfully installed and started http-server
on Ubuntu. You can now access your website by opening a web browser and navigating to the provided URL, such as http://localhost:8080
.