linux 安装步骤
-
安装JDK
1.1 查看云端目前支持安装的jdk版本
[root@localhost ~]# yum search java|grep jdk
1.2 选择版本后,安装(执行以下命令会自动安装jdk相关依赖
[root@localhost ~]# yum install -y java-1.8.0-openjdk
1.3 安装完成,验证是否安装成功
[root@localhost ~]# java -version
-
安装mysql
1.1 获取mysql yum社区的下载文件
关闭防火墙
1.2 放到 root路径下
yum localinstall mysql80-community-release-el8-1.noarch.rpm
1.4 查看是否挂载成功
yum repolist enabled | grep "mysql.-community."
1.5 禁用centos8.0自带的mysql模块:
yum module disable mysql
1.6 安装mysql:
yum install mysql-community-server
1.7 启动mysql服务 service mysqld start 如果报错 执行
systemctl restart mysqld.service
1.8 查看mysql服务启动状态
service mysqld status
mysql服务相关命令
启动服务:service mysqld start
停止服务:service mysqld stop
重启服务:service mysqld restart
查看服务状态:service mysqld status
设置mysql开机自启:
systemctl enable mysqld
systemctl daemon-reload1.9 查看mysql安装时生成的随机密码:
grep 'temporary password' /var/log/mysqld.log
2.0 登录mysql
mysql -uroot -p'刚获取到的随机密码'
2.1 安装mysql后第一次登录需要修改密码
ALTER USER 'root' @'localhost' IDENTIFIED BY '你的密码';
2.2 开放mysql远程访问
创建权限记录:
CREATE user 'root'@'%' IDENTIFIED BY 'root123';
授权:
GRANT ALL PRIVILEGES ON *.* TO 'root' @'%' WITH GRANT OPTION;
修改密码过期策略:
ALTER USER 'root' @'localhost' IDENTIFIED BY '你的密码' PASSWORD EXPIRE NEVER;
重新修改密码:
ALTER USER 'root' @'%' IDENTIFIED WITH mysql_native_password BY '你的密码';
刷新权限:
FLUSH PRIVILEGES; -
安装redis (都在根目录下)
1.1 服务器设置相应的端口号
1.2 安装redis数据库
yum install redis
1.3 下载fedora的epel仓库
yum install epel-release
1.4 启动redis服务
systemctl start redis
1.5 查看redis状态
systemctl status redis
systemctl stop redis 停止服务
systemctl restart redis 重启服务
6.设置开机自启动
systemctl enable redis
7.开放端口号
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=6379/tcp --permanent
8.查看端口
netstat -lnp|grep 6379
9.设置redis 远程连接和密码
输入命令vi /etc/redis.conf进入编辑模式
注释 bind 127.0.01
protected-mode no
密码可设可不设
10.重启redis
systemctl restart redis
11.进入redis
命令redis-cli -h 127.0.0.1 -p 6379
然后输入info,提示必须验证
-
安装nginx
1.1 执行如下 创建nginx yum配置文件
[root@localhost ~] cd /etc/yum.repos.d/
touch nginx.repo
不要复制下面的
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=truechmod -R 755 nginx.repo
1.2 执行如下命令进行yum安装nginx
yum install nginx
1.3 查看nginx版本
# 查看nginx版本
nginx -v
# 查看编译参数
nginx -V
这里一定要看编译参数 放前端打包的地址 默认为 /usr/share/nginx
1.4 nginx.conf配置
vi /etc/nginx/nginx.conf
user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/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 /var/log/nginx/access.log main; #内存小的话 可以注释掉 # sendfile on; #tcp_nopush on; # keepalive_timeout 65; proxy_connect_timeout 600s; proxy_send_timeout 600s; proxy_read_timeout 600s; send_timeout 600s; #access_log /var/log/nginx/access.log main; client_max_body_size 1024M; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 300; types_hash_max_size 2048; #gzip on; include /etc/nginx/conf.d/*.conf; }
1.5 子配置 示例
vi /etc/nginx/conf.d/test.conf
server { listen 80; server_name localhost; location / { # 一定要有 “/” # add_header Cache-Control "no-cache, no-store"; # add_header Access-Control-Allow-Origin *; # add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS'; root /data/web; try_files $uri $uri/ /index.html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location /api{ #proxy_pass http://localhost:8888; } }
这个是我的
server { listen 80; server_name pay.aiqingyinghang.com; #error_page 500 502 503 504 /50x.html; location / { root /usr/share/nginx/vue/dist; try_files $uri $uri/ /index.html; } location /org { alias /usr/share/nginx/pay; try_files $uri $uri/ /index.html; } location /50x.html { root html; } }
1.6 测试nginx配置是否OK
执行 nginx -t
出现 success 即可
1.7 启动nginx
找到路径 cd /usr/sbin
./nginx
1.8 停止
nginx -s stop
1.9 重新启动nginx
nginx -s reload