We need to install a web-server to our EC2 server, to actually serve our web-project.
- To install NginX enter:
root@ip-172-31-44-101:~# apt-get install nginx
- Check the status of the NginX server using
systemctl status nginx:
root@ip-172-31-44-101:~# systemctl status nginx● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2022-11-09 17:18:47 UTC; 13min ago Docs: man:nginx(8) Main PID: 1679 (nginx) Tasks: 2 (limit: 1143) Memory: 1.7M CPU: 20ms CGroup: /system.slice/nginx.service ├─1679 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;" └─1680 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
Thanks for this amazing tutorial.. when run this command : apt-get install nginx, have an error E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
You probably aren't logged in as root, this is covered in previous lessons about SSH connection and logging in, from what I remember.
I runed all commands of last lectures and no error but this command the same problem
This is not a very serious error.
This error usually occurs when a process is functioning to update the system and you try to access the for some other operation. This can be checked if any of apt processes are running by entering
ps aux | grep -i apt. If that is the case you should wait until the process is finished and try again, this is common during system updates, note that security updates are being installed automatically.Another solution might be to reboot the server
sudo reboot, and try installing nginx again.If it does not solve the issue try to kill the process with
sudo kill <process id>. Process ids are shown using the previousps aux | grep -i aptcommand.Sometimes the issue may come across a more complex situation, and the issue could be the "lock" files. Lock files restrict access to the system files until a specific operation is performed. Upon completion of the process, the lock will automatically be released to perform further operations of the system. So, to solve this issue you are required to delete the files. Firstly check the lock file using
sudo lsof /var/lib/dpkg/lock-frontend.If you see something "unattended" in the output, wait for this process to complete because the system is working on updates.
Otherwise, get the process ids and terminate them using
sudo kill -9 <process id>.After that, you can delete the lock file
sudo rm /var/lib/dpkg/lock-frontend.Make sure you reconfigure "dpkg" after deleting the lock file
sudo dpkg --configure -arealy thanks you i solved it