wget https://nginx.org/download/nginx-1.21.2.tar.gz tar -zxvf https://nginx.org/download/nginx-1.21.2.tar.gz mv nginx-1.21.2 nginx cd nginx ./configure --prefix=/opt/nginx # 配置安装路径,默认安装 /usr/local/nginx,可根据自己喜好 make && make install # 如果系统是最小安装,需要执行 yum install make -y
[root@instance-1 sbin]# curl 34.125.204.106 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> html { color-scheme: light dark; } body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p>
<p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p> </body> </html>
添加环境变量
1 2 3 4 5
vim /etc/profile # 末尾处加上 export PATH=$PATH:/opt/nginx/sbin