云服务器配置流程
-
apt-get update
-
修改源 vi /etc/apt/sources.list
阿里源:
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
apt-get update -
安装jdk
sudo apt-get install openjdk-8-jdk
java -version 测试 -
安装tomcat
cd /opt
wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.35/bin/apache-tomcat-8.5.35.tar.gz
wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.30/bin/apache-tomcat-8.5.30.tar.gz
tar zxvf apache-tomcat-8.5.35.tar.gz
设置角色
sudo vim /opt/tomcat8/conf/tomcat-users.xml再tomcat8开始, 只修改tomcat-users还是会出现403, 禁止访问.
原因是tomcat8开始, 默认只能本机访问管理项目, 再host-manager和manager项目下的/META-INF/下有个context.xml
里面默认启用了访问控制:
注释掉可以了
-
安全端口设置
tcpdump tcp port 80 查看端口的流量 -
配置https
-
配置dns
-
maven的配置
org.apache.tomcat.maven
tomcat7-maven-plugin
2.2tomcat7
/
http://114.116.85.172:80/manager/text
username
password -
配置nginx
apt-get install nginx
Ubuntu安装之后的文件结构大致为:所有的配置文件都在/etc/nginx下,并且每个虚拟主机已经安排在了/etc/nginx/sites-available下
程序文件在/usr/sbin/nginx
日志放在了/var/log/nginx中
并已经在/etc/init.d/下创建了启动脚本nginx
默认的虚拟主机的目录设置在了/var/www/nginx-default (有的版本 默认的虚拟主机的目录设置在了/var/www, 请参考/etc/nginx/sites-available里的配置)
upstream book_pool{
server 127.0.0.1:9000;
}server {
listen 80;
server_name 114.116.85.172;
access_log logs/blog.log;
error_log logs/blog.error;#将所有请求转发给demo_pool池的应用处理 location / { proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://book_pool; }
}
最后 nginx -s reload
-
tomcat-user.xml 的配置
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="xjtu" password="xjtu28xjtu28xjtu" roles="manager-gui,manager-script"/>
- tomcat的server.xml配置
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
- springboot的启动
nohup java -jar ./xxxx.jar > ./xxxx.log 2>&1 &