linux centos7 部署 nodejs 的 express

 

 

链接:https://www.youtube.com/watch?v=oGbLL1_0q64

 

yum install gcc-c++ openssl-devel make -y
cd /tmp
curl -sL https://rpm.nodesource.com/setup | bash -
yum install -y nodejs
npm install -g express-generator
useradd username
passwd username

mkdir first_project
cd first_project/
express
npm install
node ./bin/www &

查看进程那些:netstat  -tlpn

如果关掉就是kill端口:sudo kill $(sudo lsof -ti :3000)
or
express expressproject
cd expressproject
npm install
expressproject@0.0.0.0 start /exampleuser/expressproject
node ./bin/www

 

 

 

比如查看express的dome  192.0.0.1:3000

 

 

报错问题----------

 

 

如果按照npm失败应该事权限啥的那些问题

sudo yum install npm

 

 

如果是安装其他的,在contos7中

sudo npm install -g pm2

然后到node项目启动 pm2 start app.js

 

 

[root@VM-12-15-centos nginx-1.24.0]# ./configure
-bash: ./configure: Permission denied

出现 Permission denied 错误是由于缺少执行权限。请使用以下命令为 configure 添加执行权限:

Copy Code
chmod +x configure
sudo ./configure




server { listen 81; server_name 120.78.141.70; location / { proxy_pass http://127.0.0.1:8080; } }



参考
https://blog.csdn.net/weixin_41999594/article/details/125465176?spm=1001.2014.3001.5501
https://www.bilibili.com/video/BV11v4y1M7ry/?spm_id_from=333.337.search-card.all.click&vd_source=f47173c6ece362dfbe9a439ae6addcce


修改内容和重新发布需要重启的
重启nginx
sudo systemctl restart nginx # 如果您使用的是 systemd 管理器
sudo /usr/local/nginx/sbin/nginx -s reload # 如果您没有使用 systemd 管理器
第一条命令会发送重启信号给 Nginx 服务,而第二条命令会使用 Nginx 的控制程序重新加载配置文件。

 

 

 

 

查看端口:  

sudo netstat -tunlp | grep 80

 

 

 

 

连接的工具

 

 

 

 

   server {
        listen       80;
        server_name  www.****.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass http://localhost:3000;
            # root   html;
            # index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

 

posted @ 2023-10-19 13:03  漫漫长路</>  阅读(88)  评论(0编辑  收藏  举报