centos7.5 64位安装完整部署环境

8 篇文章 0 订阅
4 篇文章 0 订阅

一、安装nodejs和npm

1. 下载node最新安装包setup_12.x(12.x表示12.0.0版本最新安装版本查看官网
curl --silent --location https://rpm.nodesource.com/setup_12.x | bash -
2.安装
sudo yum install -y nodejs

在这里插入图片描述

3.测试显示版本信息安装完成
node -v
npm -v

在这里插入图片描述

二、安装mysql5.7

1.wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm --下载mysql5.7
2.rpm -ivh mysql57-community-release-el7-9.noarch.rpm --进行repo的安装
3.yum install mysql-server --使用yum命令即可完成安装
4.systemctl start mysqld --启动MySQL
5.grep ‘temporary password’ /var/log/mysqld.log --获取安装时的临时密码:

在这里插入图片描述

6.mysql -u root -p --登录
输入密码 m&y6d#7<J&i3
7.ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘SongLei_2012.’; --修改密码
8.授权其他机器可以登录
> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'SongLei_2012.' WITH GRANT OPTION;

> FLUSH  PRIVILEGES;

三、安装pm2

将已经打包好的前端项目和后端项目放入根目录下data文件夹下

四、安装pm2

1.npm install pm2 -g
进入项目 cd /data/vue_shop_start
启动项目 pm2 start app.js --name fore-end
进入项目 cd //data/vueShop-api-server 
启动项目 pm2 start app.js --name back-end
2.查看启动的项目
pm2 list

在这里插入图片描述

3.停止项目
pm2 delete 0 (0是id)

五、安装nginx进行配置代理(官网

1.一键安装所有依赖
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
安装完成后
cd /usr/local
2.下载nginx并且解压缩
wget http://nginx.org/download/nginx-1.19.0.tar.gz
tar -xvf nginx-1.19.0.tar.gz
3.安装nginx
cd /usr/local/nginx-1.19.0
./configure
make
make install
4.测试nginx是否安装完毕及一些常用命令
在根目录下执行./usr/local/nginx/sbin/nginx -t
查看是否启动 ps -aux|grep nginx

在这里插入图片描述

5.配置/usr/local/nginx/conf/nginx.conf
5.1在nginx目录下创建ssl文件夹将nginx证书放入
5.2进入/usr/local/nginx/conf下打开nginx.conf进行配置
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#gzip  on;

server {
    listen       80;
    server_name  127.0.0.1;# 服务器IP或者是域名
	
	location /shopServer/ {#微信小程序支付回调使用访问后端接口的url
		client_max_body_size 2000m;
        proxy_pass   http://127.0.0.1:8888/;
    }
    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        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;
    #}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#    listen       8000;
#    listen       somename:8080;
#    server_name  somename  alias  another.alias;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}


# HTTPS server
server {
    listen       443 ssl;
    server_name  127.0.0.1;# 服务器IP或者是域名

    ssl_certificate      /usr/local/nginx/ssl/***.crt;
    ssl_certificate_key  /usr/local/nginx/ssl/***.key;

    ssl_session_cache    shared:SSL:1m;
    ssl_session_timeout  5m;

    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;
	
	location /shopServer/ {#访问后端接口的url
		client_max_body_size 2000m;
        proxy_pass   http://127.0.0.1:8888/;
    }
	location ^~ /shop/img/ {#访问前端静态图片路径
        alias   /data/vue_shop_start/dist/img/;
        autoindex on;
    }
	location / {#访问前端页面
		client_max_body_size 2000m;
        proxy_pass   http://127.0.0.1:3005/;
    }
	location ^~ /images/ {
        alias   /data/vueShop-api-server/uploads/goodspics/;
        autoindex on;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

}
6.重启nginx
pkill -9 nginx --停止nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf -- 启动nginx

7.报错

1.Linux下nginx配置https出现ssl错误解决
1.1 Nginx如果未开启SSL模块,配置Https时提示错误
nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:37

1.2 Nginx开启SSL模块
先停止nginx
pkill -9 nginx
切换到源码包:
cd /usr/local/nginx-1.19.0

1.3执行语句,重新安装ssl模块:
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
运行上面的命令即可,等配置完

1.4配置完成后,运行命令
make

1.5等待make结束后备份nginx文件
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak

1.6然后将刚刚编译好的nginx覆盖掉原有的nginx(这个时候nginx要停止状态)
cp ./objs/nginx /usr/local/nginx/sbin/

1.7然后就是启动nginx。在启动之前,也可以在测试一次配置文件是否已经生效:
先切换到sbin目录
cd /usr/local/nginx/sbin/
检测nginx的配置文件是否有错误
./nginx -t

1.8启动nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
2npm ERR! code MODULE_NOT_FOUND
2.1.先卸载npm  sudo npm uninstall npm -g
2.2卸载node
yum remove nodejs npm -y
看看是否有残留
	进入 /usr/local/lib 删除所有 node 和 node_modules文件夹
	进入 /usr/local/include 删除所有 node 和 node_modules 文件夹
	进入 /usr/local/bin 删除 node 的可执行文件
2.3清除yum缓存
	sudo yum clean all 
2.4首先执行
	rm -rf /usr/local/lib/node_modules/npm 
2.5在执行 
	curl --silent --location https://rpm.nodesource.com/setup_12.x | bash - 下载最新的node包
2.6安装
	sudo yum install -y nodejs

工具

.netstat   -nultp --查看端口
3306 --数据库
3005 --前端
8888 --后端
ps -aux|grep nginx --查看是否启动
pkill -9 nginx --停止nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf -- 启动nginx
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值