运行环境:
R710
os:ubuntu18.10
设置静态ip:
libo@ubuntu1810:~$ sudo passwd root
[sudo] password for libo:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
libo@ubuntu:~$ su - root
Password:
root@ubuntu1810:~# vim /etc/netplan/*.yaml
network:
ethernets:
ens33:
addresses:
- 10.0.0.41/24 #这里改成自己的IP地址
dhcp4: false
gateway4: 10.0.0.1 #这里改成自己的网关地址
nameservers:
addresses:
- 10.0.0.1
search: []
version: 2
改dns
vi /etc/systemd/resolved.conf
[Resolve]
DNS=8.8.8.8 8.8.4.4
#FallbackDNS=
#Domains=
LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes
网络服务配置即时生效:
sudo netplan apply
在Ubuntu中限制普通用户使用1024以下的端口号,所以使用root用户。
(1)安装jdk1.8
tomcat9下载地址
https://tomcat.apache.org/download-90.cgi
root@ubuntu1810:~# mkdir /test
root@ubuntu1810:~# chmod 777 -R /test/
root@ubuntu1810:~# cd /test
root@ubuntu1810:/test# ll
total 8
drwxrwxrwx 2 root root 4096 Jan 6 02:28 ./
drwxr-xr-x 24 root root 4096 Jan 6 02:28 ../
root@ubuntu1810:/test# ll
total 190988
drwxrwxrwx 2 root root 4096 Jan 6 02:29 ./
drwxr-xr-x 24 root root 4096 Jan 6 02:28 ../
-rw-r--r-- 1 libo libo 9912675 Oct 14 08:51 apache-tomcat-9.0.12.tar.gz
-rw-r--r-- 1 libo libo 185646832 Oct 14 08:48 jdk-8u181-linux-x64.tar.gz
root@ubuntu1810:/test# mkdir -p /usr/local/jdk
root@ubuntu1810:/test# mkdir -p /usr/local/tomcat
root@ubuntu1810:/test# chmod 777 -R /usr/local/jdk
root@ubuntu1810:/test# chmod 777 -R /usr/local/tomcat
root@ubuntu1810:/test# ll
total 190988
drwxrwxrwx 2 root root 4096 Jan 6 02:29 ./
drwxr-xr-x 24 root root 4096 Jan 6 02:28 ../
-rw-r--r-- 1 libo libo 9912675 Oct 14 08:51 apache-tomcat-9.0.12.tar.gz
-rw-r--r-- 1 libo libo 185646832 Oct 14 08:48 jdk-8u181-linux-x64.tar.gz
root@ubuntu1810:/test# tar xf apache-tomcat-9.0.12.tar.gz
root@ubuntu1810:/test# tar xf jdk-8u181-linux-x64.tar.gz
root@ubuntu1810:/test# ll
total 190996
drwxrwxrwx 4 root root 4096 Jan 6 02:32 ./
drwxr-xr-x 24 root root 4096 Jan 6 02:28 ../
drwxr-xr-x 9 root root 4096 Jan 6 02:32 apache-tomcat-9.0.12/
-rw-r--r-- 1 libo libo 9912675 Oct 14 08:51 apache-tomcat-9.0.12.tar.gz
drwxr-xr-x 7 uucp 143 4096 Jul 7 2018 jdk1.8.0_181/
-rw-r--r-- 1 libo libo 185646832 Oct 14 08:48 jdk-8u181-linux-x64.tar.gz
root@ubuntu1810:/test# mv apache-tomcat-9.0.12 /usr/local/tomcat/
root@ubuntu1810:/test# mv jdk1.8.0_181/ /usr/local/jdk/
root@ubuntu1810:/test# vim /etc/profile
在末尾处添加
#java
export JAVA_HOME=/usr/local/jdk/jdk1.8.0_181
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}
root@ubuntu1810:/test# source /etc/profile
root@ubuntu1810:/test# java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
安装tomcat9
root@ubuntu1810:/test# cd /usr/local/tomcat/
root@ubuntu1810:/usr/local/tomcat# ll
total 12
drwxrwxrwx 3 root root 4096 Jan 6 02:33 ./
drwxr-xr-x 12 root root 4096 Jan 6 02:30 ../
drwxr-xr-x 9 root root 4096 Jan 6 02:32 apache-tomcat-9.0.12/
root@ubuntu1810:/usr/local/tomcat# chmod 777 -R apache-tomcat-9.0.12/
root@ubuntu1810:/usr/local/tomcat# cd apache-tomcat-9.0.12/conf/
root@ubuntu1810:/usr/local/tomcat/apache-tomcat-9.0.12/conf# vim server.xml
把字符集改为UTF-8
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" />
root@ubuntu1810:/usr/local/tomcat/apache-tomcat-9.0.12/conf# cd ../bin/
root@ubuntu1810:/usr/local/tomcat/apache-tomcat-9.0.12/bin# vim startup.sh
在空白地方添加配置项
fi
#java
JAVA_HOME=/usr/local/jdk/jdk1.8.0_181
JRE_HOME=${JAVA_HOME}/jre
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
#tomcat
TOMCAT_HOME=/usr/local/tomcat/apache-tomcat-9.0.12
exec "$PRGDIR"/"$EXECUTABLE" start "$@"
开启tomcat9(80端口)
root@ubuntu1810:/usr/local/tomcat/apache-tomcat-9.0.12/bin# sh startup.sh
Using CATALINA_BASE: /usr/local/tomcat/apache-tomcat-9.0.12
Using CATALINA_HOME: /usr/local/tomcat/apache-tomcat-9.0.12
Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-9.0.12/temp
Using JRE_HOME: /usr/local/jdk/jdk1.8.0_181
Using CLASSPATH: /usr/local/tomcat/apache-tomcat-9.0.12/bin/bootstrap.jar:/usr/local/tomcat/apache-tomcat-9.0.12/bin/tomcat-juli.jar
Tomcat started.
安装mysql5.7
去https://downloads.mysql.com/archives/community/
下载mysql-server_5.7.28-1ubuntu19.04_amd64.deb-bundle.tar
一条一条的复制,中途有地方需要人工操作
mkdir -p /test/mysqlA
cd /test/
#mysql-server_5.7.28-1ubuntu19.04_amd64.deb-bundle.tar 下载到/test/下
tar xvf mysql-server_5.7.28-1ubuntu19.04_amd64.deb-bundle.tar -C mysqlA/
cd mysqlA
chmod +x *
apt-get update
apt-get upgrade -y
apt autoremove
apt-get upgrade -y
apt-get install libaio1
dpkg -i mysql-common_5.7.28-1ubuntu19.04_amd64.deb
dpkg-preconfigure mysql-community-server_5.7.28-1ubuntu19.04_amd64.deb
dpkg -i libmysqlclient20_5.7.28-1ubuntu19.04_amd64.deb
dpkg -i libmysqlclient-dev_5.7.28-1ubuntu19.04_amd64.deb
dpkg -i libmysqld-dev_5.7.28-1ubuntu19.04_amd64.deb
dpkg -i mysql-community-client_5.7.28-1ubuntu19.04_amd64.deb
dpkg -i mysql-client_5.7.28-1ubuntu19.04_amd64.deb
dpkg -i mysql-common_5.7.28-1ubuntu19.04_amd64.deb
apt-get -f install
apt-get -f install libmecab2
dpkg -i mysql-community-server_5.7.28-1ubuntu19.04_amd64.deb
dpkg -i mysql-server_5.7.28-1ubuntu19.04_amd64.deb
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
use mysql;
update user set Host="%" where User="root";
flush privileges;
exit
vim /etc/mysql/mysql.conf.d/mysqld.cnf
修改配置文件,改为bind-address = 0.0.0.0
systemctl restart mysql
sudo ufw enable
sudo ufw default deny
sudo ufw allow 3306
sudo ufw allow 80
sudo ufw allow 22
sudo /etc/init.d/mysql restart