wildfly在CentOS、debian操作系统下设置为自启动服务

CentOS

# WILDFLY_VERSION=16.0.0.Final
# wget https://download.jboss.org/wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.tar.gz -P /tmp
# tar xf /tmp/wildfly-$WILDFLY_VERSION.tar.gz -C /opt/
# ln -s /opt/wildfly-$WILDFLY_VERSION /opt/wildfly

# tar xf /tmp/wildfly-19.1.0.Final.tar.gz -C /opt/
# ln -s /opt/wildfly-19.1.0.Final /opt/wildfly

# groupadd -r wildfly
# useradd -r -g wildfly -d /opt/wildfly -s /sbin/nologin wildfly
# mkdir /var/run/wildfly/

# chown -RH wildfly:wildfly /opt/wildfly
# chown wildfly. /var/run/wildfly/

# mkdir -p /etc/wildfly
# cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.conf /etc/wildfly/
# cp /opt/wildfly/docs/contrib/scripts/systemd/launch.sh /opt/wildfly/bin/
# chmod +x /opt/wildfly/bin/*.sh
# cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.service /etc/systemd/system/

# systemctl start wildfly
# systemctl enable wildfly
# systemctl status wildfly

 上面一般用于centos下的配置。

wildfly在debian下配置自启动服务:

前面添加组、创建软链接保持一致

cp /opt/wildfly/docs/contrib/scripts/init.d/wildfly-init-debian.sh /etc/init.d/wildfly
cp /opt/wildfly/docs/contrib/scripts/init.d/wildfly.conf /etc/default/wildfly
vi /etc/default/wildfly

需要添加或放开的配置

JAVA_HOME="/opt/jdk1.8.0_92"
JBOSS_HOME="/opt/wildfly"
JBOSS_USER=wildfly
JBOSS_MODE=standalone
JBOSS_CONFIG=standalone.xml
STARTUP_WAIT=60
SHUTDOWN_WAIT=60
JBOSS_CONSOLE_LOG="/var/log/wildfly/console.log"

将wildfly 作为系统服务,开机自启

update-rc.d wildfly defaults

#启动服务
service wildfly start

如果之前使用systemd安装过,需要执行:

systemctl disable wildfly
rm -rf /etc/systemd/system/wildfly.service
systemctl daemon-reload

#再更新
update-rc.d wildfly defaults

允许所有ip访问

vi /opt/wildfly/standalone/configuration/standalone.xml

将文件中的


    


    

改为:


    


    

设置端口80–>8080

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080

开放端口:

apt install ufw
ufw allow 8080/tcp

在debian 11安装后没自动启服务,发再还要使用

systemctl enable wildfly

才起作用

你可能感兴趣的:(java与开源框架,debian,centos,linux)