用到的工具
寶塔,xftp,xshell
開放端口
寶塔
阿里云的話就是在實例那里點遠程連接,輸入:
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh
中途輸入y確定安裝
安裝成功就是這樣的頁面:
在軟件商店下好常用的軟件
Mysql
服務器買的核數小,每次在寶塔安裝mysql都會崩,得自己手動裝T T
卸載系統(tǒng)自帶的mariadb
CentOS7自帶了另外一款數據庫mariadb,mysql在安裝時會和mariadb產生沖突。
因此需要先卸載mariadb , 再安裝mysql。
查看
rpm -qa | grep -i mariadb
卸載
rpm -e --nodeps mariadb-libs-xxxx
下載mysql
下載rpm包
去官網找要下載的mysql版本,復制進來
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.13-1.el7.x86_64.rpm-bundle.tar
解壓
tar xvf mysql-5.7.13-1.el7.x86_64.rpm-bundle.tar
按照以下命令的先后順序依次安裝(包與包之間有依賴關系)
[root@centos-linux ~]# rpm -ivh mysql-community-common-5.7.13-1.el7.x86_64.rpm
[root@centos-linux ~]# rpm -ivh mysql-community-libs-5.7.13-1.el7.x86_64.rpm
[root@centos-linux ~]# rpm -ivh mysql-community-client-5.7.13-1.el7.x86_64.rpm
[root@centos-linux ~]# rpm -ivh mysql-community-server-5.7.13-1.el7.x86_64.rpm
數據庫初始化
mysqld --initialize --user=mysql
這里演示使用的 --initialize 初始化的,會生成一個 root 賬戶密碼,密碼在log文件里:
啟動數據庫,使用上面的密碼登錄
[root@centos-linux ~]# systemctl start mysqld
[root@centos-linux ~]# mysql -uroot -p*****
修改密碼
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
注意,密碼不要設置得太簡單,有被黑掉的風險
開放遠程連接權限
use mysql;
update user set host = '%' where user = 'root';
如果報錯 去防火墻檢查3306端口是否放開
查詢想要的端口是否放開
firewall-cmd --query-port=3306/tcp
添加指定的想要放開的端口
firewall-cmd --add-port=3306/tcp --permanent
然后再查一次放開沒,如果成功了就重新加載配置
firewall-cmd --reload
運行jar包
先用xftp把jar包放到服務器上
注意:jar包內置tomcat不用下tomcat,下了反而會8080沖突
nohup java -jar cardiovascular-0.0.1-SNAPSHOT.jar ?>> card.log 2>&1 &
查看日志看跑起來沒有:
tail -f card.log
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 443 ssl;
server_name www.域名.cn;
ssl on;
ssl_certificate ../ssl/www.域名.cn.pem;
ssl_certificate_key ../ssl/www.域名.cn.key;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host:$server_port;
}
}
# 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 localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
把申請域名后得到的key和pem文件,放到nginx的ssl文件夾中文章來源:http://www.zghlxwxcb.cn/news/detail-815715.html
完美收官!!文章來源地址http://www.zghlxwxcb.cn/news/detail-815715.html
到了這里,關于服務器從零開始配環(huán)境的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!