TOMCAT NGINX 环境的搭建脚本
##Nginx安装
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
yum -y install pcre-devel zlib-devel gcc gcc-c++ make
useradd -M -s /sbin/nologin nginx
cd /opt
for i in `ls *`
do
if [[ $i == *.tar.gz ]]
then
tar xf $i
fi
done
cd /opt
tar xf nginx-1.12.0.tar.gz -C /opt/
cd nginx-1.18.0/
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module
make -j4 && make install
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
/lib/systemd/system/nginx.service
touch /lib/systemd/system/nginx.service
echo "[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target" >> /lib/systemd/system/nginx.service
chmod 754 /lib/systemd/system/nginx.service
systemctl start nginx.service
systemctl enable nginx.service
##tomcat安装部署
cd /opt
rpm -qpl jdk-8u201-linux-x64.rpm
rpm -ivh jdk-8u201-linux-x64.rpm
java -version
echo 'export JAVA_HOME=/usr/java/jdk1.8.0_201-amd64
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH' >/etc/profile.d/java.sh
source /etc/profile.d/java.sh
java -version
touch Hello.java
echo 'public class Hello {
public static void main(String[] args){
System.out.println("Hello world!");
}
} ' > Hello.java
javac Hello.java
java Hello
cd /opt
tar xf apache-tomcat-9.0.16.tar.gz
mv apache-tomcat-9.0.16 /usr/local/tomcat
/usr/local/tomcat/bin/catalina.sh start
/usr/local/tomcat/bin/catalina.sh run
netstat -natp | grep 8080
touch /usr/lib/systemd/system/tomcat.service
echo '[Unit]
Description=tomcat server
Wants=network-online.target
After=network.target
[Service]
Type=forking
Environment="JAVA_HOME=/usr/java/jdk1.8.0_201-amd64"
Environment="PATH=$JAVA_HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"
Environment="CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar"
ExecStart=/usr/local/tomcat/bin/startup.sh
ExecStop=/usr/local/tomcat/bin/shutdown.sh
Restart=on-failure
[Install]
WantedBy=multi-user.target' > /usr/lib/systemd/system/tomcat.service
##优化TOMCAT
##启动速度
sed -i '/securerandom.source=file:\/dev\/random/c\securerandom.source=file:/dev/urandom' /usr/java/jdk1.8.0_201-amd64/jre/lib/security/java.security
/usr/local/tomcat/bin/shutdown.sh
/usr/local/tomcat/bin/startup.sh