----------------------------------------------
ubuntu22.04安装依赖(nginx 的 ssl pcre等)
1.首先使用dpkg命令查看自己需要的软件是否安装。
例如查看zlib是否安装:
dpkg -l | grep zlib
2.解决依赖包openssl安装,命令:
sudo apt-get install openssl libssl-dev
3.解决依赖包pcre安装,命令:
sudo apt-get install libpcre3 libpcre3-dev
4.解决依赖包zlib安装,命令:
sudo apt-get install zlib1g-dev
-----------------------------------------------
一、jre1.8 wget http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/server-jre-8u144-linux-x64.tar.gz
#tar -zxvf server-jre-8u144-linux-x64.tar.gz
#mkdir /usr/java
#mv jdk1.8.0_144 /usr/java/
#chown root:root -R /usr/java/jdk1.8.0_144/
#vi /etc/profile
----------------------
export JAVA_HOME=/usr/java/jdk1.8.0_144
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib
export PATH=$JAVA_HOME/bin:/usr/local/nginx/sbin:/usr/local/mysql/bin:$PATH
----------------------
#source /etc/profile
测试# java -version
java version "1.8.0_131"
#以及java和javac命令都行
chmod 777 *.sh
cd /usr/java/jdk1.8.0_144/jre/lib/security/【修改后,tomcat启动速度快了】
vi java.security
编辑这个文件
将 securerandom.source=file:/dev/urandom
修改为 securerandom.source=file:/dev/./urandom
二、tomcat9 wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.0.M26/bin/apache-tomcat-9.0.0.M26.tar.gz
#tar -zxvf apache-tomcat-9.0.0.M26.tar.gz
#mv apache-tomcat-9.0.0.M26 /usr/local/tomcat
#vi /etc/profile 【可不要】
--------------------------
# begin - tomcat9
CATALINA_HOME=/usr/local/tomcat
CATALINA_BASE=/usr/local/tomcat
PATH=$PATH:$CATALINA_BASE/bin
export PATH CATALINA_BASE
# end - tomcat9
--------------------------
#source /etc/profile
#vi /usr/local/tomcat/conf/server.xml 【修改server.xml】
#vi /usr/local/tomcat/bin/catalina.sh
-----------------------------
在 # OS specific support. 前面【修改】加入如下代码:
JAVA_HOME=/usr/java/jdk1.8.0_144
JRE_HOME=$JAVA_HOME/jre
------------------------------------------
#自启动
tomcat需要增加一个pid文件
在tomcat/bin 目录下面,增加setenv.sh配置,catalina.sh启动的时候会调用,同时配置java内存参数
# vim setenv.sh
写入一下命令:
-----------------------------------
#tomcat启动pid
export CATALINA_HOME=/usr/local/tomcat
export CATALINA_BASE=/usr/local/tomcat
#add tomcat pid
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
#add java opts
JAVA_OPTS="-server -XX:PermSize=256M -XX:MaxPermSize=1024m -Xms512M -Xmx1024M -XX:MaxNewSize=256m"
---------------------------------------------------
chmod 777 *.sh
3、增加tomcat.service
在/usr/lib/systemd/system目录下增加tomcat.service,目录必须是绝对目录
#vim /usr/lib/systemd/system/tomcat.service
写入一下命令:
-----------------------------
[Unit]
Description=Tomcat
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/tomcat/tomcat.pid
ExecStart=/usr/local/tomcat/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
------------------------------------------
#chmod 754 /usr/lib/systemd/system/tomcat.service
#systemctl enable tomcat.service
#systemctl start tomcat.service
#firewall-cmd --zone=public --add-port=8080/tcp【添加防火墙 没有 --permanent 重启失效】
#firewall-cmd --reload
三、nginx wget http://nginx.org/download/nginx-1.13.4.tar.gz
#tar -zxvf nginx-1.13.4.tar.gz
#cd nginx-1.13.4
创建nginx用户www
#groupadd www
#useradd -g www www
#./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_realip_module --with-pcre=../pcre-8.32
#make && make install
vim /usr/lib/systemd/system/nginx.service
--------------------------------------
[Unit]
Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
[Install]
WantedBy=multi-user.target
---------------------------------------------
#chmod 754 /usr/lib/systemd/system/nginx.service
systemctl enable nginx.service
systemctl start nginx.service
firewall-cmd --zone=public --add-port=80/tcp --permanent#【添加防火墙 没有 --permanent 重启失效】
firewall-cmd --reload
华旅网络 |