码迷,mamicode.com
首页 > 数据库 > 详细

jdk+tomcat8+nginx+mysql学习

时间:2020-06-02 09:25:45      阅读:70      评论:0      收藏:0      [点我收藏+]

标签:安装jdk   var   gpg   rect   ref   baseurl   tomcat服务器   toc   ase   

使用环境
CentOS Linux release 7.6.1810 (Core)

3.10.0-957.21.3.el7.x86_64

最小化安装,关闭防火墙,关闭SELLINUX

一、安装jdk
下载jkd
https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

jdk-8u251-linux-x64.rpm

安装
rpm -ivh jdk-8u251-linux-x64.rpm

验证
[root@localhost ~]# java -version
java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)

二、安装tomcat8
下载tomcat
https://tomcat.apache.org/

apache-tomcat-8.5.55.tar.gz

解压
tar -zxvf apache-tomcat-8.5.55.tar.gz

移至 root/apps下
mkdir -p /root/apps
mv apache-tomcat-8.5.55 /root/apps

运行tomcat
[root@localhost bin]# ./startup.sh
Using CATALINA_BASE: /root/apps/tomcat8
Using CATALINA_HOME: /root/apps/tomcat8
Using CATALINA_TMPDIR: /root/apps/tomcat8/temp
Using JRE_HOME: /usr
Using CLASSPATH: /root/apps/tomcat8/bin/bootstrap.jar:/root/apps/tomcat8/bin/tomcat-juli.jar
Tomcat started.

验证
浏览器访问
http://IP:8080

网页正常显示即可

修改tomcat端口
停止tomcat服务
./shutdown.sh
备份原配置文件
cp /tomcat8/conf/server.xml /tomcat8/conf/server.xml.bak
编辑配置文件
vi /tomcat8/conf/server.xml

<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

将默认8080 改为80

三、安装nginx
方法1:
增加nginx源
#vi /etc/yum.repos.d/nginx.repo

源的内容

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

查看源是否配置成功
yum list nginx
yum list |grep nginx

更新源
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

安装nginx
yum install -y nginx

方法2:
下载
http://nginx.org/en/download.html

http://nginx.org/download/nginx-1.18.0.tar.gz

解压
tar -zxvf nginx-1.18.0.tar.gz

移至root/apps 并改名
mv nginx-1.18.0 nginx

安装依赖
yum -y install gcc gcc-c++ autoconf automake make
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel

编译安装
./configure

make&make install

验证:
[root@localhost nginx]# whereis nginx
nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz

修改配置文件做反向代理
vi /etc/nginx/conf.d/default.conf

server {
listen 80;
server_name localhost;

#charset koi8-r;
#access_log  /var/log/nginx/host.access.log  main;

location / {
    proxy_pass http://127.0.0.1:8080;
    root   /usr/share/nginx/html;
    index  index.html index.htm;
}

加一句
proxy_pass http://127.0.0.1:8080; 如上

上面这句话的意思就是,把所有到80nginx服务器的请求全部丢给本地8080来出来,8080端口正是我们的tomcat服务器。这样nginx就把访问交给tomcat来做了。

四、安装mysql
yum install mariadb-server

启动
systemctl start mariadb

加入开机启动
systemctl enable mariadb.service

jdk+tomcat8+nginx+mysql学习

标签:安装jdk   var   gpg   rect   ref   baseurl   tomcat服务器   toc   ase   

原文地址:https://blog.51cto.com/airsky/2500197

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!