1 Mysql安装(最费劲的就是这个)
-
到这个页面下载文件: http://dev.mysql.com/downloads/repo/yum/
即 http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
sudo yum localinstall 刚才下载的文件
sudo yum install mysql-community-server
-
启动停止及查看状态:
service mysqld start service mysqld stop service mysqld status
-
自启动:
chkconfig mysqld on
-
设置用户密码:
1. Stop mysql: systemctl stop mysqld 2. Set the mySQL environment option systemctl set-environment MYSQLD_OPTS="--skip-grant-tables" 3. Start mysql usig the options you just set systemctl start mysqld 4. Login as root mysql -u root 5. Update the root user password with these mysql commands mysql> UPDATE mysql.user SET authentication_string=PASSWORD('showgp') WHERE User='root' AND Host='localhost'; mysql> FLUSH PRIVILEGES; mysql> quit 6. Stop mysql systemctl stop mysqld 7. Unset the mySQL envitroment option so it starts normally next time systemctl unset-environment MYSQLD_OPTS 8. Start mysql normally: systemctl start mysqld Try to login using your new password: 7. mysql -u root -p
安装了mysql之后提示要重设密码时的解决:
mysql> SET PASSWORD = PASSWORD('showgp');
密码不满足要求时, 设置:
SET GLOBAL validate_password_policy=LOW; SET GLOBAL validate_password_length=6;
完成...
2 Tomcat
-
下载java:
wget --no-cookies --no-check-certificate --header "Cookie:gpw_e24=http%3A%2F%2Fwww.oracle.com%2F;oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u112-b15/jdk-8u112-linux-x64.tar.gz"
-
解压并配置javahome:在bashrc中写:(假设下载好了放在/opt/jdk8目录)
export JAVA_HOME="/opt/jdk8" export PATH="$PATH:$JAVA_HOME/bin"
然后
source ./.bashrc
-
安装Tomcat并设置:
wget http://apache.osuosl.org/tomcat/tomcat-9/v9.0.0.M15/bin/apache-tomcat-9.0.0.M15.tar.gz 然后解压放入/opt/tomcat9
export CATALINA_HOME="/opt/tomcat9"
在rc.local中设置tomcat自启动.
ok
3 协同
另外一台已经安装好了apache...开始配置:
在apache httpd端:
http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html
http://tomcat.apache.org/connectors-doc/reference/apache.html
-
下载mod_jk connector:
http://apache.mirrors.tds.net/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.42-src.tar.gz
编译并安装好.
配置文件中写:
LoadModule jk_module modules/mod_jk.so //加载模块 #/opt/apache24/conf JkWorkersFile /opt/apache24/conf/workers.properties //worker的配置 JkMount /wp2/* worker1 //worker的目录
官方文档写的在配置文件中加入的内容:
# Load mod_jk module LoadModule jk_module modules/mod_jk.so # Add the module (activate this lne for Apache 1.3) # AddModule mod_jk.c # Where to find workers.properties JkWorkersFile /etc/httpd/conf/workers.properties # Where to put jk shared memory JkShmFile /var/log/httpd/mod_jk.shm # Where to put jk logs JkLogFile /var/log/httpd/mod_jk.log # Set the jk log level [debug/error/info] JkLogLevel info # Send requests for context /examples to worker named worker1 JkMount /examples/* worker1
这个则是对应的workers.properties文件内容:
worker.list=worker1 # Set properties for worker1 (ajp13) worker.worker1.type=ajp13 # 如果是远程机器, 则是IP worker.worker1.host=localhost # ajp13默认是8009端口 worker.worker1.port=8009
http://tomcat.apache.org/connectors-doc/reference/workers.html
至此简单的一个apache前端 + 一个tomcat应用服务器就搭建完成了.
使用apache服务器的地址再请求JkMount中的应用上下文名称就可以访问到后端tomcat服务器中该应用了.
后记
- 一个worker可以对应多个JkMount中的应用(当然了...)