CentOS7.4 安装 jdk mysql tomcat nginx

xiaoxiao2021-02-28  36

1.安装jdk.

利用yum源来安装jdk(此方法不需要配置环境变量)

查看yum库中的java安装包 #yum -y list java*

安装需要的jdk版本的所有java程序#yum -y install java-1.8.0-openjdk*

(安装完之后,默认的安装目录是在: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-1.b12.el7_4.x86_64)

2.安装mysql

https://blog.csdn.net/qq_33962835/article/details/80512583

systemctl start mysqld    #启动mysqld

systemctl stop mysqld    #停止mysqld

systemctl restart mysqld    #重启mysqld

systemctl enable mysqld   #设置开机启动

systemctl status mysqld    #查看 MySQL Server 状态

3.安装Tomcat

下载tomcat8压缩包

访问官网:http://tomcat.apache.org/

点击左侧的Tomcat8,进入下载页面

https://tomcat.apache.org/download-80.cgi

选择红框标注的链接,直接点击下载

拷贝tomcat8压缩包

[root@localhost ~]# mkdir /soft

用WinSCP工具将tar包拷贝到此目录

解压tomcat8压缩包

[root@localhost ~]# cd /soft

[root@localhost soft]# tar -zxvf apache-tomcat-8.5.23.tar.gz

移动到/usr/local目录

[root@localhost soft]# mv apache-tomcat-8.5.23 /usr/local/tomcat

防火墙开启8080端口

[root@localhost /]# firewall-cmd --zone=public --add-port=8080/tcp --permanent

[root@localhost /]# firewall-cmd --reload

启动tomcat8

[root@localhost /]# /usr/local/tomcat/bin/startup.sh

[root@localhost bin]# ./startup.sh Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /home/java/jdk1.8.0_121 Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar Tomcat started.

浏览器地址栏输入:http://192.168.1.90:8080

运行java web程序

可以将java的war包上传到“/usr/local/tomcat/webapps/”目录下,直接访问即可。webapps目录就是专门存放war包的,假设你有N个web应用,那么这个目录下就可以放N个war包。

比如我本地开发时访问的地址是:http://localhost:8080/springmvc/hello/index

那么我们放到tomcat里面,访问地址就是:http://192.168.1.90:8080/springmvc/hello/index

4.安装nginx

     1.将nginx放到yum repro库中

        rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

    2.查看nginx信息

       yun info nginx

    3.使用yum安装ngnix

        yum install nginx

  4.启动nginx

        service nginx start

  5.查看nginx版本

        nginx -v

目的:修改服务名,接着从外部访问这个服务

操作:

a.修改nginx配置文件

[root@localhost nginx]# vim /etc/nginx/conf.d/default.conf

修改server_name部分:server_name  yytest.com;

b.重载服务

[root@localhost nginx]# /usr/sbin/nginx -s reload

c.从外部访问nginx服务(192.168.10.11)

如在客户机(192.168.10.10)的浏览器访问:http://yytest.com

d.你发现访问不了,原因1,你没有在hosts文件做映射;原因2,及时你在hosts文件中了映射,由于nginx服务器的80端口堵塞或防火墙没关

e.解决办法:

步骤一:修改客户机(192.168.10.10)的hosts文件,使用SwitchHosts工具添加 192.168.10.11     yytest.com

步骤二:关闭防火墙,具体下文有说明

9.nginx常用操作

启动:

复制代码代码如下: $ /usr/sbin/nginx或任意路径下运行service nginx start(centos7是systemctl start nginx.service )

重启:

$ /usr/sbin/nginx –s reload

停止:

$ /usr/sbin/nginx –s stop

测试配置文件是否正常:

$ /usr/sbin/nginx –t

可能遇到的问题:

具体情况如下  1。本机能ping通虚拟机  2。虚拟机也能ping通本机  3。虚拟机能访问自己的web  4。本机无法访问虚拟己的web  这个问题的原因是服务器的80端口没有打开或防火墙没有关闭解决办法

如果是centos6:

解决方法如下: 

/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT

然后保存: 

/etc/rc.d/init.d/iptables save

重启防火墙 

/etc/init.d/iptables restart

CentOS防火墙的关闭,关闭其服务即可: 

查看CentOS防火墙信息:/etc/init.d/iptables status 

关闭CentOS防火墙服务:/etc/init.d/iptables stop 

永久关闭防火墙: chkconfig –level 35 iptables off

如果是centos7

[root@rhel7 ~]# systemctl status firewalld.service [root@rhel7 ~]# systemctl stop firewalld.service [root@rhel7 ~]# systemctl disable firewalld.service [root@rhel7 ~]# systemctl status firewalld.service

扩展知识:

启动一个服务:systemctl start firewalld.service

关闭一个服务:systemctl stop firewalld.service

重启一个服务:systemctl restart firewalld.service

显示一个服务的状态:systemctl status firewalld.service

在开机时启用一个服务:systemctl enable firewalld.service

在开机时禁用一个服务:systemctl disable firewalld.service

查看服务是否开机启动:systemctl is-enabled firewalld.service;echo $?

查看已启动的服务列表:systemctl list-unit-files|grep enabled

第二种方式:通过手动下载安装包解压安装

1.下载nginx包。

[root@localhost ~]# wget http://nginx.org/download/nginx-1.10.1.tar.gz

2.复制包到你的安装目录

[root@localhost ~]# cp nginx-1.10.1.tar.gz /usr/local/

3.解压

[root@localhost ~]# tar -zxvf nginx-1.10.1.tar.gz [root@localhost ~]# cd nginx-1.10.1

4.启动nginx

[root@localhost ~]# /usr/local/nginx/sbin/nginx

5.查看版本s

[root@localhost ~]# nginx -v

6.url访问nginx localhost或127.0.0.1

卸载Mysql 像我这样子的Linux菜鸟接下来的想法,当然是卸载了MySQL换成MariaDB了。 于是我找到了这篇文章:http://zhangzifan.com/centos-7-remove-mysql.html 1.卸载掉安装的部分 首先执行查看命令,看一下都安转了什么东东: rpm -qa |grep -i mysql 2.开始卸载 执行卸载命令:yum remove mysql-community mysql-community-server mysql-community-libs mysql-community-common 3.检查卸载残余 检查是否卸载干净:rpm -qa |grep -i mysql 4.卸载残余 卸载掉刚才未卸载掉的部分:yum remove mysql-community-release 5.终极检查 再进行一遍检查:rpm -qa |grep -i mysql,安装部分已完全卸载掉。 6.清理文件 查看mysql文件目录:find / -name mysql 7.删除掉该文件:rm -rf /usr/share/mysql

转载请注明原文地址: https://www.6miu.com/read-2800143.html

最新回复(0)