ubuntu服务器搭建记录

1.安装mysql

参考文献: https://www.jianshu.com/p/13d71125eec4

执行安装指令

#命令1 更新源
sudo apt-get update
#命令2 安装mysql服务
sudo apt-get install mysql-server
#初始化mysql的配置
sudo mysql_secure_installation

 

mysql配置

#1
VALIDATE PASSWORD PLUGIN can be used to test passwords...
Press y|Y for Yes, any other key for No: N (选择N ,不会进行密码的强校验)
#2
Please set the password for root here...
New password: (输入密码)
Re-enter new password: (重复输入)
#3
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them...
Remove anonymous users? (Press y|Y for Yes, any other key for No) : N (选择N,不删除匿名用户)
#4
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network...
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N (选择N,允许root远程连接)
#5
By default, MySQL comes with a database named 'test' that
anyone can access...
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N (选择N,不删除test数据库)
#6
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y (选择Y,修改权限立即生效)

配置数据库远程访问

#修改配置文件的bind-address 修改值为 0.0.0.0(如果需要远程访问)
vim /etc/mysql/mysql.conf.d/mysqld.cnf

#重启mysql
sudo /etc/init.d/mysql restart #重启mysql

 

 


登录mysql 并修改用户权限

#登录mysql
sudo mysql -uroot -p

#切换数据库
mysql>use mysql;
#查询用户表命令:
mysql>select User,authentication_string,Host from user;
#查看状态
mysql>
select host,user,plugin from user; #使用mysql_native_password修改加密规则 mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '密码'; #更新一下用户的密码 mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '密码' PASSWORD EXPIRE NEVER; #允许远程访问 mysql> UPDATE user SET host = '%' WHERE user = 'root'; #刷新cache中配置 刷新权限 mysql>flush privileges; mysql>quit;

 

 

2.安装sqlite3

sudo apt-get install sqlite3

 


3.安装Git

#安装
sudo apt-get install git
#查看版本
git --version

 


创建git用户

#创建一个新的系统用户git,作为Git应用的管理用户
#方式1: 新建Git用户
sudo adduser git
# 修改或新增git用户参数
sudo vi /etc/passwd

#方式2 用下面命令新建用户
sudo adduser --system --group --disabled-password --shell /bin/bash --home /home/git --gecos 'Git Version Control Tool' git
# 添加git用户密码
sudo passwd git

 




4.安装Tomcat

sudo apt update
sudo apt-cache search tomcat
sudo apt install tomcat9 tomcat9-admin
#打开文件创建Tomcat管理用户
vi /etc/tomcat9/tomcat-users.xml


在users标签下添加如下内容

<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<user username="tomcat" password="密码" roles="admin-gui,manager-gui"/>

 


访问管理页: http://ip:8080/manager/html


4.安装jekins

参考地址:https://blog.csdn.net/Prince39/article/details/109687179

 

下载deb文件 各版本地址: https://mirrors.tuna.tsinghua.edu.cn/jenkins/debian-stable/

wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/debian-stable/jenkins_2.249.3_all.deb

 


安装jekins,此时会报一个错误

dpkg -i jenkins_2.249.3_all.deb

 


修复报错

sudo apt-get -f -y install

 


重新安装

dpkg -i jenkins_2.249.3_all.deb

 


修改端口号:这里改为9999

vim /etc/default/jenkins #HTTP_PORT=9999

 

常用指令

启动指令
#启动Jenkins
systemctl start jenkins
#关闭Jenkins
systemctl stop jenkins
#重启Jenkins
systemctl restart jenkins
#查看Jenkins状态
systemctl status jenkins

 



#修改更新文件

vim /var/lib/jenkins/hudson.model.UpdateCenter.xml

 


url标签中的内容替换为:http://mirror.xmission.com/jenkins/updates/update-center.json

vim /var/lib/jenkins/updates/default.json

 


#在vim中把这个地址替换一下
:%s/https:\/\/updates.jenkins.io\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g


#访问:http://ip:9999/

查看默认密码:

vi /var/lib/jenkins/secrets/initialAdminPassword

 

5.安装maven https://www.cnblogs.com/wqlken/p/14090525.html

6.Jenkins构建vue项目: https://www.jianshu.com/p/1d07b986ab2c

7.Nginx安装与配置 : https://zhuanlan.zhihu.com/p/138007915

#安装
sudo apt install nginx
#一旦安装完成,Nginx 将会自动被启动。你可以运行下面的命令来验证它:
sudo systemctl status nginx

 


所有的 Nginx 配置文件都在/etc/nginx/目录下。
主要的 Nginx 配置文件是/etc/nginx/nginx.conf。

8.Nginx部署vue项目(注意:Nginx不能访问root目录)
#修改配置文件 把root后面的内容改为vue打包后的dist目录

vi /etc/nginx/sites-enabled/default

#或者在/etc/nginx/sites-enabled目录下新增一个应用配置文件,添加如下内容

server {
listen 8010;
listen [::]:8010;

#域名
server_name _;


location / {
# vue/dist/ 打包后的dist目录
root /var/www/web/site;
#指向下面的@router 否则会出现404
try_files $uri $uri/ @router;
index index.html index.htm;
}

# 对应上面的 @router,主要Vue请求并不是真实路径,无法找到文件,需要重定向到 index.html 中,然后交给路由处理
location @router {
rewrite ^.*$ /index.html last;
}
}

 

#重新加载配置

nginx -s reload

 

暂时先到这里,后面发现的再补充

posted @ 2021-08-24 17:34  coder木易  阅读(36)  评论(0编辑  收藏  举报