阿里云CentOS安装 JDK+MySQL+Wildfly+Nginx

/ 技术文章默认分类 / 0 条评论 / 681浏览

阿里云CentOS安装 JDK+MySQL+Wildfly+Nginx

更新wget

···shell

yum install -y wget

···

添加无登录密码用户及用户组 www.www,并保证所用网络应用都使用www用户,并控制www文件目录访问权限

···shell

# groupadd www
# useradd -g www www

···

安装JDK

安装下载最新JDK rpm

···shell

# wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.rpm

# chmod -x jdk-8u151-linux-x64.rpm
# yum install jdk-8u102-linux-x64.rpm
# java -version
# ll /usr/java
# rm jdk-8u102-linux-x64.rpm

···

安装完成,验证成功后,删除安装包

添加环境变量(root, 和www都要添加)

···shell

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
  . ~/.bashrc
fi

# User specific environment and startup programs

export JAVA_HOME=/usr/java/latest
export JRE_HOME=/usr/java/latest/jre

PATH=$PATH:$HOME/bin:$JAVA_HOME/bin

export PATH

···

生效更新

···shell

# source .bash_profile

# echo $JRE_HOME
/usr/java/jdk1.8.0_102/jre

# echo $JAVA_HOME
/usr/java/jdk1.8.0_102/

# echo $PATH
/...:/usr/local/bin:/usr/X11R6/bin:/home/mkyong/bin:/usr/java/jdk1.8.0_102//bin

···

切换用户

···shell

su - www

···

2.安装MySQL

查看是否已经安装旧版本mysql,如果发现已有,删除

···shell

# rpm -qa|grep -i mysql
# yum remove mysql*

···

安装yum repo源

···shell

# wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
# rpm -ivh mysql57-community-release-el7-10.noarch.rpm

···

安装之后会获得/etc/yum.repos.d/mysql-community.repo和/etc/yum.repos.d/mysql-community-source.repo两个源,可以去相应的路径下查看一下。 安装mysql

···shell

# yum install mysql-server
# yum install mysql

···

将pid文件改到lib目录下,阿里云的CentOS默认是不给其他程序run目录的读写权限的,

···shell

# vi /etc/my.cny

...
pid-file=/var/run/mysqld/mysqld.pid

设置mysql开机自启,启动mysql,尝试登录

# systemctl enable mysqld
# systemctl start mysqld
# mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
···

这个时候会发现,无法登陆,因为还没有配密码,需要先暂时把权限检查给禁用,在新建密码

···shell

# vi /etc/my.cny

...
# Data table name case insensitive
lower_case_table_names=1

skip-grant-tables
:x

# systemctl restart mysqld
# mysql -u root
mysql>use mysql;
mysql>update mysql.user set authentication_string=password('Wincor') where user='root';
mysql>flush privileges;
mysql>exit;

# vi /etc/my.cny

...
# skip-grant-tables
:x

# mysql -u root -p
Enter password:

···

现在就可以在本地使用root/Wincor登录、管理mysql了(仅限本地访问)

3.安装Wildfly

下载解压Wildfly (使用www用户)

···shell

# mkdir -p /opt/wildfly
# chown -R www:www /opt/wildfly
# chmod -R 775 /opt/wildfly

# su - www
# cd /opt/wildfly
# wget http://download.jboss.org/wildfly/8.2.0.Final/wildfly-8.2.0.Final.zip
# unzip wildfly-8.2.0.Final.zip
# mv wildfly-8.2.0.Final 8.2.0
# rm wildfly-8.2.0.Final.zip

···

设置环境变量

···shell

# vi ~/.bash_profile

#### WildFly 8.2.0 ##################

export JBOSS_HOME=/opt/wildfly/8.2.0
export WILDFLY_HOME=$JBOSS_HOME
export PATH=$PATH:$HOME/bin:$WILDFLY_HOME/bin

#### WildFly 8.2.0 ##################

···

启动

···shell

# standalone.sh -c standalone-full.xml -b=0.0.0.0

···

4.安装Nginx

···shell

# yum install nginx
# vi /etc/nginx/nginx.conf

....
pid /var/lib/nginx/nginx.pid;

...
http {

...
     server {
...
        location / {
       proxy_pass http://127.0.0.1:8080;
  }  
...
     }
...
}

:x
# systemctl start nginx
# systemctl enable nginx

···

默认配置,就会把所有80端口访问转发到8080端口

4.安装Screen Screen是一个可以在多个进程之间多路复用一个物理终端的窗口管理器。Screen中有会话的概念,用户可以在一个screen会话中创建多个screen窗口,在每一个screen窗口中就像操作一个真实的telnet/SSH连接窗口那样。

新建会话

···shell

# yum install screen
# screen
# su - www
# standalone.sh -c standalone-full.xml -b=0.0.0.0
Ctrl + A, D

···

查看会话

···shell

# screen -ls
There is a screen on:  2034.pts-1.izuf60njylntwlm73oivnwz (Detached)
1 Socket in /var/run/screen/S-root.

···

重连会话

···shell

# screen -r 2034

···