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

一、安装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
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页