自学: Ubuntu安装nginx(仅供自己学习)

1.打开XShell,连接服务器,输入服务器IP,点击连接。
自学: Ubuntu安装nginx(仅供自己学习)
2.输入用户名和密码,点击确定。

3.更新库。

apt-get update

4.安装nginx

apt-get install nginx

5.查看nginx进程

ps -ef|grep nginx

自学: Ubuntu安装nginx(仅供自己学习)
6.修改配置文件

vi /etc/nginx/nginx.conf

i 键进入编辑状态,按如下图修改
自学: Ubuntu安装nginx(仅供自己学习)

server {
               listen 80;
               server_name localhost;
               root /root/wwww;
               index index.html;
               location ^~ / {
                        proxy_pass http://127.0.0.1:8081/;
               }
        }

编辑好后,按Esc退出编辑状态,再按输入:wq!保存退出。

7.配置好后,重启nginx

nginx -s reload

8.查看是否有配置错误。

nginx -t

另:停止以及重新运行nginx
自学: Ubuntu安装nginx(仅供自己学习)