服务器配置:1G 2核心 Ubuntu 16.04.3 LTS \n \l
准备工作:在windows中首先下载好需要使用的东西,然后通过xftp将文件传到服务器中。上传文件成功之后的截图如下:
搜狐mysql镜像站:http://mirrors.sohu.com/mysql/MySQL-5.7/
jdk版本:jdk-8u191-linux-x64.tar.gz
tomcat版本:apache-tomcat-9.0.13.tar.gz
一、安装mysql,操作步骤如下:
1. 全自动安装方式:apt-get install mysql-server
root@Turing:/usr/local/mysql# apt-get install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.0-5 libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl
libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl liburi-perl mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7
mysql-server-core-5.7
Suggested packages:
libdata-dump-perl libipc-sharedcache-perl libwww-perl tinyca
The following NEW packages will be installed:
libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.0-5 libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl
libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl liburi-perl mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server
mysql-server-5.7 mysql-server-core-5.7
0 upgraded, 19 newly installed, 0 to remove and 215 not upgraded.
Need to get 18.9 MB of archives.
After this operation, 162 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 mysql-common all 5.7.24-0ubuntu0.16.04.1 [15.3 kB]
Get:2 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 mysql-client-core-5.7 amd64 5.7.24-0ubuntu0.16.04.1 [6,030 kB]
Get:3 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 mysql-client-5.7 amd64 5.7.24-0ubuntu0.16.04.1 [1,720 kB]
Get:4 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 mysql-server-core-5.7 amd64 5.7.24-0ubuntu0.16.04.1 [7,757 kB]
Get:5 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 libevent-core-2.0-5 amd64 2.0.21-stable-2ubuntu0.16.04.1 [70.6 kB]
Get:6 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 mysql-server-5.7 amd64 5.7.24-0ubuntu0.16.04.1 [2,726 kB]
Get:7 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 libhtml-tagset-perl all 3.20-2 [13.5 kB]
Get:8 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 liburi-perl all 1.71-1 [76.9 kB]
Get:9 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 libhtml-parser-perl amd64 3.72-1 [86.1 kB]
Get:10 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 libcgi-pm-perl all 4.26-1 [185 kB]
Get:11 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 libfcgi-perl amd64 0.77-1build1 [32.3 kB]
Get:12 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 libcgi-fast-perl all 1:2.10-1 [10.2 kB]
Get:13 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 libencode-locale-perl all 1.05-1 [12.3 kB]
Get:14 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 libhtml-template-perl all 2.95-2 [60.4 kB]
Get:15 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 libhttp-date-perl all 6.02-1 [10.4 kB]
Get:16 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 libio-html-perl all 1.001-1 [14.9 kB]
Get:17 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 liblwp-mediatypes-perl all 6.02-1 [21.7 kB]
Get:18 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 libhttp-message-perl all 6.11-1 [74.3 kB]
Get:19 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 mysql-server all 5.7.24-0ubuntu0.16.04.1 [10.8 kB]
Fetched 18.9 MB in 0s (24.4 MB/s)
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 100151 files and directories currently installed.)
Preparing to unpack .../mysql-common_5.7.24-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-common (5.7.24-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-client-core-5.7.
Preparing to unpack .../mysql-client-core-5.7_5.7.24-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-client-core-5.7 (5.7.24-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-client-5.7.
Preparing to unpack .../mysql-client-5.7_5.7.24-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-client-5.7 (5.7.24-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-server-core-5.7.
Preparing to unpack .../mysql-server-core-5.7_5.7.24-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-server-core-5.7 (5.7.24-0ubuntu0.16.04.1) ...
Selecting previously unselected package libevent-core-2.0-5:amd64.
Preparing to unpack .../libevent-core-2.0-5_2.0.21-stable-2ubuntu0.16.04.1_amd64.deb ...
Unpacking libevent-core-2.0-5:amd64 (2.0.21-stable-2ubuntu0.16.04.1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Setting up mysql-common (5.7.24-0ubuntu0.16.04.1) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mysql-server-5.7.
(Reading database ... 100312 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.24-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-server-5.7 (5.7.24-0ubuntu0.16.04.1) ...
Selecting previously unselected package libhtml-tagset-perl.
Preparing to unpack .../libhtml-tagset-perl_3.20-2_all.deb ...
Unpacking libhtml-tagset-perl (3.20-2) ...
Selecting previously unselected package liburi-perl.
Preparing to unpack .../liburi-perl_1.71-1_all.deb ...
Unpacking liburi-perl (1.71-1) ...
Selecting previously unselected package libhtml-parser-perl.
Preparing to unpack .../libhtml-parser-perl_3.72-1_amd64.deb ...
Unpacking libhtml-parser-perl (3.72-1) ...
Selecting previously unselected package libcgi-pm-perl.
Preparing to unpack .../libcgi-pm-perl_4.26-1_all.deb ...
Unpacking libcgi-pm-perl (4.26-1) ...
Selecting previously unselected package libfcgi-perl.
Preparing to unpack .../libfcgi-perl_0.77-1build1_amd64.deb ...
Unpacking libfcgi-perl (0.77-1build1) ...
Selecting previously unselected package libcgi-fast-perl.
Preparing to unpack .../libcgi-fast-perl_1%3a2.10-1_all.deb ...
Unpacking libcgi-fast-perl (1:2.10-1) ...
Selecting previously unselected package libencode-locale-perl.
Preparing to unpack .../libencode-locale-perl_1.05-1_all.deb ...
Unpacking libencode-locale-perl (1.05-1) ...
Selecting previously unselected package libhtml-template-perl.
Preparing to unpack .../libhtml-template-perl_2.95-2_all.deb ...
Unpacking libhtml-template-perl (2.95-2) ...
Selecting previously unselected package libhttp-date-perl.
Preparing to unpack .../libhttp-date-perl_6.02-1_all.deb ...
Unpacking libhttp-date-perl (6.02-1) ...
Selecting previously unselected package libio-html-perl.
Preparing to unpack .../libio-html-perl_1.001-1_all.deb ...
Unpacking libio-html-perl (1.001-1) ...
Selecting previously unselected package liblwp-mediatypes-perl.
Preparing to unpack .../liblwp-mediatypes-perl_6.02-1_all.deb ...
Unpacking liblwp-mediatypes-perl (6.02-1) ...
Selecting previously unselected package libhttp-message-perl.
Preparing to unpack .../libhttp-message-perl_6.11-1_all.deb ...
Unpacking libhttp-message-perl (6.11-1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.24-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-server (5.7.24-0ubuntu0.16.04.1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu19) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up mysql-client-core-5.7 (5.7.24-0ubuntu0.16.04.1) ...
Setting up mysql-client-5.7 (5.7.24-0ubuntu0.16.04.1) ...
Setting up mysql-server-core-5.7 (5.7.24-0ubuntu0.16.04.1) ...
Setting up libevent-core-2.0-5:amd64 (2.0.21-stable-2ubuntu0.16.04.1) ...
Setting up mysql-server-5.7 (5.7.24-0ubuntu0.16.04.1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
insserv: can not symlink(../init.d/aegis, ../rc2.d/S02aegis): File exists
insserv: can not symlink(../init.d/aegis, ../rc3.d/S02aegis): File exists
insserv: can not symlink(../init.d/aegis, ../rc4.d/S02aegis): File exists
insserv: can not symlink(../init.d/aegis, ../rc5.d/S02aegis): File exists
Setting up libhtml-tagset-perl (3.20-2) ...
Setting up liburi-perl (1.71-1) ...
Setting up libhtml-parser-perl (3.72-1) ...
Setting up libcgi-pm-perl (4.26-1) ...
Setting up libfcgi-perl (0.77-1build1) ...
Setting up libcgi-fast-perl (1:2.10-1) ...
Setting up libencode-locale-perl (1.05-1) ...
Setting up libhtml-template-perl (2.95-2) ...
Setting up libhttp-date-perl (6.02-1) ...
Setting up libio-html-perl (1.001-1) ...
Setting up liblwp-mediatypes-perl (6.02-1) ...
Setting up libhttp-message-perl (6.11-1) ...
Setting up mysql-server (5.7.24-0ubuntu0.16.04.1) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Processing triggers for systemd (229-4ubuntu19) ...
Processing triggers for ureadahead (0.100.0-19) ...
root@Turing:/etc# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.24-0ubuntu0.16.04.1 (Ubuntu)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
安装成功!!!
2.开启root用户的全称访问权限
2.1.修改数据库中user的host
update user set host = '%' where user ='root';
grant all privileges on *.* to 'root'@'%' identified by '数据库密码';
flush privileges;
2.2.修改my.conf的中的ip绑定
# 进入编辑/etc/mysql/mysql.conf.d/mysqld.conf
vi /etc/mysql/mysql.conf.d/mysqld.conf
# 修改ip绑定
# 源文件中为:
bind-address 127.0.0.1
# 将其修改为:
bind-address 0.0.0.0
# 覆盖保存
esc:wq
2.3.重启数据库
# 重启命令
service mysql restart
2.4 新增用户并允许远程访问
# 新增用户并允许远程访问只需要在user表中增加一个用户,将host设置为%即可
# 下例默认将所有权限分配给新用户,例如:
grant all privileges on *.* to 'root'@'%' identified by '数据库密码';
flush privileges;
#开启mysql 开机自启动
systemctl enable mysql
2.5 测试远程连接
二、安装jdk jdk-8u191-linux-x64.tar.gz
1.安装步骤步骤如下:
给它一个执行的权限:chmod u+x jdk-8u191-linux-x64.tar.gz
#解压jdk 压缩包
tar -xvf jdk-8u191-linux-x64.tar.gz
#查看解压出来的文件
cd ..
cd jdk-8u191-linux-x64
2.配置jdk环境
cd /etc
vi environment
#末尾加入以下配置(JAVA_HOME 后的路径就是jdk的文件位置)
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$JAVA_HOME/bin"
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export JAVA_HOME=/usr/local/jdk/jdk1.8.0_191
#修改完成之后保存关闭,并输入以下命令使环境变量立即生效
source /etc/environment
#输入java -version,显示JDK版本说明恭喜你,环境变量配置正确
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
3.等等还未结束,为了防止chu出现其他用户不能用的情况,配置所有用户的环境变量
vi /etc/profile
在文件的最后添加以下内容:
#set Java environment
#Java_HOME 是 安装jdk的目录 每个人的安装目录可能会不一样
export JAVA_HOME=/usr/local/jdk/jdk1.8.0_191
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
同样使得环境变量立即生效
source /etc/profile
9.重启电脑,能正常进入系统,且java -version命令有效
安装jdk 全部结束!!!
三、安装tomcat apache-tomcat-9.0.13.tar.gz
1.切换到tomcat文件夹,操作步骤如下:
#给 安装包一个执行权限
chmod u+x apache-tomcat-9.0.13.tar.gz
#解压 tar.gz文件
tar -xvf apache-tomcat-9.0.13.tar.gz
#查看压缩文件
cd ..
cd apache-tomcat-9.0.13.tar.gz
ll
2.#配置tomcat环境
#打开vi /etc/profile 目录下
vi /etc/profile
#在jdk环境下 加入tomcat 环境
#tomcat
export TOMCAT_HOME=/usr/local/tomcat/apache-tomcat-9.0.13
#使环境立即生效
source /etc/profile
3.保存退出以后,使用:
#进入到 apache-tomcat-9.0.13 下 执行
#开启tomcat
./bin/startup.sh
开启信息如下:
Using CATALINA_BASE: /usr/local/tomcat/apache-tomcat-9.0.13
Using CATALINA_HOME: /usr/local/tomcat/apache-tomcat-9.0.13
Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-9.0.13/temp
Using JRE_HOME: /usr/local/jdk/jdk1.8.0_191/jre
Using CLASSPATH: /usr/local/tomcat/apache-tomcat-9.0.13/bin/bootstrap.jar:/usr/local/tomcat/apache-tomcat-9.0.13/bin/tomcat-juli.jar
Tomcat started.
4.修改 server.xml配置文件,修改端口为80,查看防火墙,开启80端口
#修改server.ml 文件
#首先 解决乱码问题 修改端口为80 找到如下代码
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
修改后:
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8"/>
保存退出
5.查看防火墙开启的端口(Ubuntu 16.04)
#首先 关闭tomcat 服务器
./bin/shutdown.sh
#查看防火墙状态 为Status: inactive 则为未开启
u为w status
#开启防火墙 出现Firewall is active and enabled on system startup 开启成功
ufw enable
#关闭防火墙 出现:Firewall stopped and disabled on system startup 关闭成功
ufw disable
#开启开启自启动防火墙
ufw default deny
#开发端口
ufw allow 80/tcp #设置允许访问 http
#查看 开启的端口
netstat -naptu
6.部署JavaWeb项目,访问
之前我写了一篇云服务器部署JavaWeb项目的博客,部署可以参考一下! 查看部署过程
7.访问
(责任编辑:IT) |