centos7下搭建JAVA项目运行环境。 JAVA+MYSQL+TOMCAT+NGINX

环境: centos 7 64位

一、配置mysql 5.7
1、下载mysql源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

2、安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm

3、安装mysql
yum install mysql-community-server

4、启动MySQL服务
systemctl start mysqld

5、开机启动
systemctl enable mysqld
systemctl daemon-reload

6、进入命令行

查看初始密码
grep 'temporary password' /var/log/mysqld.log

登录数据库
mysql -uroot -p

修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

添加远程登录用户 3306端口要开放
grant all privileges on *.* to 'root'@'%' identified by 'MyNewPass4!' with grant option;

退出
EXIT

7、修改配置文件

打开my.conf文件
vim /etc/my.cnf

添加一下数据都最后面

#设置中文编码
character_set_server=utf8
init_connect='SET NAMES utf8'
#不区分大小写
lower_case_table_names=1
#select count(*),id from goods 报语法错误解决
sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER"

保存好,重启数据库
service mysqld restart


二、安装JAVA环境

1、安装JDK1.8
yum install java-1.8.0-openjdk-devel.x86_64

2、telnet安装
yum install telnet.x86_64

3、iptables安装
yum install iptables-devel.x86_64

创建目录
mkdir /data/protal
mkdir /data/server

三、安装tomcat

cd /data/server

1、下载tomcat
wget http://mirror.cc.columbia.edu/pub/software/apache/tomcat/tomcat-8/v8.0.48/bin/apache-tomcat-8.0.48.tar.gz

2、解压tomcat
tar -zxvf apache-tomcat-8.0.48.tar.gz

3、重命名
mv apache-tomcat-8.0.48 tomcat

4、打开service.xml
vim tomcat/conf/server.xml

5、在<host> 里面加入
<Context path="" docBase="/data/protal" debug="0" reloadable="true" />

6、解决centos7 tomcat-8启动慢
yum install rng-tools
systemctl start rngd


四、安装nginx

1、 gcc 安装
yum install gcc-c++

2、 PCRE pcre-devel 安装
yum install -y pcre pcre-devel

3、 zlib 安装
yum install -y zlib zlib-devel

4、OpenSSL 安装
yum install -y openssl openssl-devel

5、下载安装包
wget -c https://nginx.org/download/nginx-1.10.1.tar.gz

6、解压
tar -zxvf nginx-1.10.1.tar.gz
cd nginx-1.10.1

7、配置时添加ssl模版

./configure --with-http_ssl_module

8、编译安装

make
make install

9、替换nginx.conf
cd /usr/local/nginx/conf/
替换nginx.conf 成自己之前写好的

10、开启nginx服务

cd /usr/local/nginx/sbin/
./nginx

五、设置别名 一键重启

1、编辑~/.bashrc
vim ~/.bashrc
2、在其加入
alias protal-restart='/data/service/tomcat/bin/shutdown.sh;/data/service/tomcat/bin/startup.sh'
3、source ~/.bashrc

六、云盘的挂载
http://blog.csdn.net/laughing_cui/article/details/52034298

 

加上所替换的NGINX.CONF配置文件:

链接:https://pan.baidu.com/s/1o9NNIIY 密码:cr85

posted @ 2018-01-14 23:06  那个男孩很坏  阅读(566)  评论(0编辑  收藏  举报