因为是测试环境,故
systemctl stop firewalld
yum remove firewalld
setenforce 0
首先是搭建tomcat
tomcat服务器运行时是需要JDK支持的,所以必须配置好相关的
依赖环境
我的yum源是阿里云的,所以JDK的包直接yum安装就可以了
yum –y install java-1.8.0-openjdk
yum -y install java-1.8.0-openjdk-headless
java -version 检查安装版本是否一致
依赖环境安装好之后就开始安装tomcat
因事先有准备好tar,所以直接解压即可
tar -xf apache-tomcat-8.0.30.tar.gz
mv移动解压出来的目录并改名到 /usr/local/tomcat
查改目录下子目录或文件齐全
ls /usr/local/tomcat
bin/ //主程序目录
lib/ //库文件目录
logs/ //日志目录
temp/ //临时目录
work/ //自动编译目录jsp代码转换servlet
conf/ //配置文件目录
webapps/ //页面目录
/usr/local/tomcat/bin/startup.sh 启动tomcat即可
因业务需要,需要添加多一个9090端口
vim /usr/local/tomcat/conf/server.xml
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="9090" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
接着就是./shutdown.sh
./startup.sh
netstat -anput | grep java
接下来是nginx
老规矩,安装依赖环境
yum -y install gcc pcre-devel openssl-devel zlib-devel
因为公司要求需要到ssl,所以还需要下载相对应的ssl的版本
wget ftp://ftp.openssl.org/source/old/1.0.1/openssl-1.0.1-beta2.tar.gz
接着就是解压,放到你想放到的目录上,本人是比较喜欢放到/usr/local,故:
tar zxvf openssl-1.0.1-beta2.tar.gz
mv openssl-1.0.1-beta2 /usr/local/openssl
然后给nginx创建一个不能登陆的用户
useradd -s /sbin/nologin nginx
解压nginx包
tar zxvf nginx-1.12.2.tar.gz
进入到生成的目录里
./configure --prefix=/usr/local/nginx1.10.3
--with-openssl=/usr/include/openssl
--with-openssl=/usr/local/openssl # 刚才已经是openssl放到了/usr/local/openssl了,这里指定一下
--with-http_ssl_module
--with-http_v2_module
--with-pcre
--with-http_stub_status_module
模块也可以按照自身需求进行更改,接下来是编译了
make&&make install
创建nginx的软连接
ln -s /usr/local/nginx/sbin/nginx /sbin/
如果想要nginx支持PHP文件,则需要修改配置nginx.conf让其支持PHP文件(两处地方):
location / {
root html;
index index.php index.html index.htm;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi.conf;
}
nginx 启动
netstat -anput | grep 80
接下来MySQL,同上,准备好了tar包
yum -y install perl-JSON 安装依赖环境
tar zxvf mysql-5.7.17.tar
rpm -Uvh mysql-community-*.rpm
ls /var/lib/mysql 查看数据库目录
systemctl start mysql
systemctl enable mysql
netstat -anput | grep 3306
ls /var/run/mysqld/mysqld.pid
ls /var/log/mysqld.log
ls /var/lib/mysql
与数据库服务相关的信息
主配置文件 日志文件 socket文件 PID文件 数据库目录的位置 进程所有 者和组 数据目录所有者和组
grep password /var/log/mysqld.log
查看数据库初始化密码
mysql -uroot -p'xxxxxxxxxx'
首次使用原密码登入需要修改密码后才能操作
mysql>alter user root@"localhost" identified by "qwer!@1234";
重置新密码
额外:
show variables like "%password%";
set global validate_password_policy=0; //降低策略
set global validate_password_length=6; //修改密码长度
```
永久设置
```vim /etc/my.cnf
[mysqld]
validate_password_policy=0
validate_password_length=6
Systemctl restart mysqld
补充一个tomcat的配置文件server.xml多实例的
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
<Service name="Catalina1">
<Connector port="9090" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina1" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps1"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
然后在修改好的路径上创建相对应的文件即可,然后把原本的webapps里面的所有目录文件cp到webapps1里面即可