一.前言
初次接触linux,想要实现部署一个vue+node的网站,所以需要安装mysql,nginx,node,pm2,在mysql上面花了尤其多的时间.
1.首先我使用的是albaba的免费服务器,在下载mysql的时候遇到了一些问题,感觉他的alibaba linux可能和centos linux有点差别,为了排除一些可能存在的问题,我在腾讯云买了一个centos7.6服务器,学生服务器最基础的1年112元。
学生云服务器_学生云主机_学生云数据库_云+校园特惠套餐 - 腾讯云
2.在使用centos 7.6服务器安装mysql的时候,参考了不下10篇教程,无一例外都有问题,最多的问题就是mysql服务启动不成功,基本都会报以下的错误,最终找到了下方说明的博客才成功启动mysql。
mysqld.service - MySQL Server
Loaded: loaded (/etc/systemd/system/mysqld.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 三 2023-05-17 13:06:48 CST; 2min 7s ago
Process: 14815 ExecStart=/usr/bin/mysqld --defaults-file=/etc/mysql/my.cnf --datadir=/var/lib/mysql --socket=/var/run/mysqld/mysqld.sock User=mysql (code=exited, status=203/EXEC)
Main PID: 14815 (code=exited, status=203/EXEC)
二:各个参考博客
1.mysql
mysql参考博客:https://blog.csdn.net/weixin_39464426/article/details/117953907
参考以上博客后navicat远程连接mysql不上,结果是我的腾讯云服务器没有配置防火墙
2.nginx
nginx参考博客:Centos7.6安装和配置最新版Nginx服务_jackchen10的博客-CSDN博客
nginx.conf配置文件如下,以下有两个重点标注,请具体看看描述。
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
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 /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html; //重点标注!!!这个意味着访问该服务器的访问基础目录。
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location ^~/ztjy/ {
client_max_body_size 100m;
proxy_set_header Connection keep-alive;
proxy_pass http://127.0.0.1:0726/;
}!!!重点标注,这是配置返代理的,ztjy是前端返代理名称,0726是后端返代理端口号
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
3.node
node参考博客:CentOS 7 安装 node.js_centos7安装nodejs18_西瓜那么甜的博客-CSDN博客