sudo yum install yum-utils
创建文件,并添加如下内容(vim /etc/yum.repos.d/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=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
执行安装命令
sudo yum install nginx
启动nginx
nginx
打开浏览器
安装成功
常用命令
启动nginx后,就可以通过使用-s参数调用可执行文件来对其进行控制。使用以下语法:
nginx -s 信号
其中信号可能是以下之一:
stop —快速关机
quit —正常关机
reload —重新加载配置文件
reopen —重新打开日志文件
配置 nginx
找到默认配置文件
下载到本地进行编辑
upstream iot_system {
server localhost:8888 weight=5;
}
server {
listen 80;
# server_name localhost;
#SSL 访问端口号为 443
listen 443 ssl;
#填写绑定证书的域名
server_name ryiot.vip;
#证书文件名称
ssl_certificate /etc/nginx/conf.d/certs/1_ryiot.vip_bundle.crt;
#私钥文件名称
ssl_certificate_key /etc/nginx/conf.d/certs/2_ryiot.vip.key;
ssl_session_timeout 5m;
#请按照以下协议配置
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
# 允许所有跨域的方法
add_header Access-Control-Allow-Methods *;
# 带cookie请求需要加上这个字段,并设置为true
add_header Access-Control-Allow-Credentials true;
# 表示允许这个域跨域调用(客户端发送请求的域名和端口)
# $http_origin动态获取请求客户端请求的域 不用*的原因是带cookie的请求不支持*号
add_header Access-Control-Allow-Origin $http_origin;
# 表示请求头的字段 动态获取
add_header Access-Control-Allow-Headers
$http_access_control_request_headers;
# OPTIONS预检命令,预检命令通过时才发送请求
# 检查请求的类型是不是预检命令
if ($request_method = OPTIONS){
return 200;
}
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-NginX-Proxy true;
proxy_pass http://iot_system;
}
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
# location / {
# root /usr/share/nginx/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 /usr/share/nginx/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;
#}
}
go 环境
yum info golang
sudo yum install golang
go version
export GOPROXY=https://mirrors.aliyun.com/goproxy/
MySQL
yum update -y
sudo yum install -y wget
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
sudo yum localinstall mysql80-community-release-el7-3.noarch.rpm
sudo yum install -y yum-utils
yum repolist enabled | grep "mysql.*-community.*"
yum repolist all | grep mysql
# 禁用 mysql8.0
sudo yum-config-manager --disable mysql80-community
# 启用 mysql 5.7
sudo yum-config-manager --enable mysql57-community
# 校验当前启用(enable)的 mysql 版本是否为 5.7:
yum repolist enabled | grep mysql
sudo yum install -y mysql-community-server
sudo service mysqld start
sudo service mysqld status
# 查看生成的初始密码:
sudo grep 'temporary password' /var/log/mysqld.log
# 登录
mysql -u root -p
# 设置密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
设置 MySQL开机启动
MySLQ 安装完成之后运行的服务名称为: mysqld
CentOS 7 使用 systemctl 命令工具操作服务:
启动 | 停止 | 重启 | 开机启动 | 关闭开机启动 |
---|---|---|---|---|
start | stop | restart | enable | disable |
开机启动命令:
systemctl enable mysqld
设置远程连接
登录 mysql(使用新设置的密码)
mysql -u root -p
登录成功之后执行以下命令:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'yourNewPassword' WITH GRANT OPTION;
其中 yourNewPassword 即为刚才设置的新密码
刷新权限
FLUSH PRIVILEGES;
到这里远程连接已经设置成功