Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 无法在Ubuntu 18.04上将AEM作为服务启动_Shell_Ubuntu_Aem - Fatal编程技术网

Shell 无法在Ubuntu 18.04上将AEM作为服务启动

Shell 无法在Ubuntu 18.04上将AEM作为服务启动,shell,ubuntu,aem,Shell,Ubuntu,Aem,我正在尝试在AWS EC2实例上的Ubuntu18.04上将AEM Adobe Experience Manager Author设置为服务 脚本文件aem at/usr/bin/aem对root用户的文件权限 #!/bin/bash # # description: This service manages the Adobe Experience Manager java process. # processname: aem6 . /lib/lsb/init-functions SCRIP

我正在尝试在AWS EC2实例上的Ubuntu18.04上将AEM Adobe Experience Manager Author设置为服务

脚本文件aem at/usr/bin/aem对root用户的文件权限

#!/bin/bash
#
# description: This service manages the Adobe Experience Manager java process.
# processname: aem6
. /lib/lsb/init-functions
SCRIPT_NAME=`basename $0`
AEM_ROOT=/opt/aem/author
AEM_USER=root

########
BIN=${AEM_ROOT}/crx-quickstart/bin
START=${BIN}/start
STOP=${BIN}/stop
STATUS=${BIN}/status

case "$1" in
  start)
    if [ -f $START ]; then
       echo "Starting AEM Service.."
       /bin/su -l $AEM_USER -c $START
       RETVAL=$?
       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/${SCRIPT_NAME}
    fi
   ;;
   stop)
    if [ -f $STOP ]; then
       echo "Stopping AEM Service.."
       /bin/su -l $AEM_USER -c $STOP
       RETVAL=$?
       [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/${SCRIPT_NAME}
    fi
    ;;
    status)
      if [ -f $STATUS ]; then
         echo -s "Checking status of $SCRIPT_NAME: "
         /bin/su -l $AEM_USER -c $STATUS
         RETVAL=$?
         [ $RETVAL -eq 0 ] && echo "$SCRIPT_NAME is running"
      fi
   ;;
   restart)
      /bin/su -l ${AEM_USER} -c ${STOP}
      /bin/su -l ${AEM_USER} -c ${START}
   ;;
   reload)
   ;;
   *)
     echo "Usage: $0 {start|stop|status|reload}"
     RETVAL=1
     ;;
esac
exit $RETVAL
[Unit]
Description=Adobe Experience Manager

[Service]
Type=simple
ExecStart=/usr/bin/aem start
ExecStop=/usr/bin/aem stop
ExecReload=/usr/bin/aem restart
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
位于/etc/systemd/system/aem的服务文件。根目录下的服务文件权限

#!/bin/bash
#
# description: This service manages the Adobe Experience Manager java process.
# processname: aem6
. /lib/lsb/init-functions
SCRIPT_NAME=`basename $0`
AEM_ROOT=/opt/aem/author
AEM_USER=root

########
BIN=${AEM_ROOT}/crx-quickstart/bin
START=${BIN}/start
STOP=${BIN}/stop
STATUS=${BIN}/status

case "$1" in
  start)
    if [ -f $START ]; then
       echo "Starting AEM Service.."
       /bin/su -l $AEM_USER -c $START
       RETVAL=$?
       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/${SCRIPT_NAME}
    fi
   ;;
   stop)
    if [ -f $STOP ]; then
       echo "Stopping AEM Service.."
       /bin/su -l $AEM_USER -c $STOP
       RETVAL=$?
       [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/${SCRIPT_NAME}
    fi
    ;;
    status)
      if [ -f $STATUS ]; then
         echo -s "Checking status of $SCRIPT_NAME: "
         /bin/su -l $AEM_USER -c $STATUS
         RETVAL=$?
         [ $RETVAL -eq 0 ] && echo "$SCRIPT_NAME is running"
      fi
   ;;
   restart)
      /bin/su -l ${AEM_USER} -c ${STOP}
      /bin/su -l ${AEM_USER} -c ${START}
   ;;
   reload)
   ;;
   *)
     echo "Usage: $0 {start|stop|status|reload}"
     RETVAL=1
     ;;
esac
exit $RETVAL
[Unit]
Description=Adobe Experience Manager

[Service]
Type=simple
ExecStart=/usr/bin/aem start
ExecStop=/usr/bin/aem stop
ExecReload=/usr/bin/aem restart
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
检查服务状态时:

ubuntu@ip-109:~$ sudo systemctl status aem 
aem.service - Adobe Experience Manager
Loaded: loaded (/etc/systemd/system/aem.service; enabled; vendor preset: enabled)
Active: active (exited) since Wed 2019-10-23 20:25:21 UTC; 3min 24s ago
Process: 20106 ExecStart=/usr/bin/aem start (code=exited, status=0/SUCCESS)
Main PID: 20106 (code=exited, status=0/SUCCESS)

Oct 23 20:25:21 ip-172-31-14-109 systemd[1]: Started Adobe Experience Manager.
Oct 23 20:25:21 ip-172-31-14-109 aem[20106]: Starting AEM Service..
Oct 23 20:25:21 ip-172-31-14-109 su[20122]: Successful su for root by root
Oct 23 20:25:21 ip-172-31-14-109 su[20122]: + ??? root:root
Oct 23 20:25:21 ip-172-31-14-109 su[20122]: pam_unix(su:session): session opened for user root by (uid=0)
Oct 23 20:25:21 ip-172-31-14-109 aem[20106]: mesg: ttyname failed: Inappropriate ioctl for device
Oct 23 20:25:21 ip-172-31-14-109 su[20122]: pam_unix(su:session): session closed for user root
但无法看到使用ps-ef | grep java的java进程或使用sudo lsof-i-p-n | grep LISTEN的4502端口


我缺少什么?

能够解决问题。问题在于java并非对所有用户都可用。使用默认ubuntu用户安装Oracle Java,同时aem脚本以root用户身份运行

安装自定义Java..的步骤。。不是Ubuntu默认设置:

下载tar.gz文件231-linux-x64.tar.gz 使用SCP将文件复制到服务器 创建目录mkdir/opt/java 安装并复制sudo tar-zxf jdk-8u231-linux-x64.tar.gz-C/opt/java/ 更新您的环境以允许所有用户使用Java。运行此命令 sudo更新备选方案-安装/usr/bin/java/opt/java/jdk1.8.0_231/bin/java 1 将路径添加到.bashrc。打开以编辑sudo nano~/.bashrc 将以下行添加到文件末尾: 导出JAVA_HOME=/opt/JAVA/jdk1.8.0_231 导出路径=${PATH}:${JAVA_HOME}/bin 在这之后。。再次启动aem服务。它应该能工作