ubuntu

如何在Ubuntu上部署WebLogic的Web应用

小樊
33
2025-10-12 07:50:27
栏目: 智能运维

Prerequisites
Before deploying WebLogic on Ubuntu, ensure your system meets the following requirements:

Step 1: Install and Configure Java
WebLogic depends on Java for execution. If not already installed, use the following commands to install OpenJDK 11:

sudo apt update
sudo apt install openjdk-11-jdk

Verify the installation:

java -version

Ensure the output displays the correct Java version (e.g., “openjdk version 11.0.xx”).

Step 2: Create a Dedicated WebLogic User
For security, run WebLogic as a non-root user. Create a weblogic group and user:

sudo groupadd weblogic
sudo useradd -g weblogic weblogic
sudo passwd weblogic  # Set a strong password

This user will own all WebLogic-related files and directories.

Step 3: Download and Extract WebLogic
Move the downloaded WebLogic package to a target directory (e.g., /opt) and extract it:

sudo mkdir -p /opt/weblogic
sudo mv ~/Downloads/fmw_14.1.1.0.0_wls_lite_generic.jar /opt/weblogic/
cd /opt/weblogic
sudo -u weblogic java -jar fmw_14.1.1.0.0_wls_lite_generic.jar -mode=console

The -mode=console flag enables text-based installation (no GUI required). Follow the on-screen prompts to complete the installation (accept the license agreement, specify the installation directory, etc.).

Step 4: Configure Environment Variables
Set environment variables for WebLogic in the weblogic user’s shell profile (~/.bash_profile):

sudo -u weblogic nano ~/.bash_profile

Add the following lines (adjust paths based on your installation directory):

export WEBLOGIC_HOME=/opt/weblogic/wlserver
export PATH=$WEBLOGIC_HOME/bin:$PATH
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64  # Path to your JDK

Save the file and apply changes:

source ~/.bash_profile

Verify the variables:

echo $WEBLOGIC_HOME  # Should display the WebLogic home directory
echo $JAVA_HOME      # Should display the JDK path

Step 5: Create a WebLogic Domain
A domain is a logically related group of WebLogic resources (servers, applications, etc.). Use the config.sh script to create a domain:

cd /opt/weblogic/wlserver/server/bin
sudo -u weblogic ./config.sh

Follow the wizard:

  1. Select Create a new domain.
  2. Choose Production Mode (recommended for production) or Development Mode (for testing).
  3. Specify a domain name (e.g., mydomain) and location (e.g., /opt/weblogic/user_projects/domains/mydomain).
  4. Set the administrator username/password (e.g., weblogicadmin/StrongPassword123).
  5. Complete the wizard; the domain directory will be created.

Step 6: Start the WebLogic Server
Navigate to the domain’s bin directory and start the server:

cd /opt/weblogic/user_projects/domains/mydomain/bin
sudo -u weblogic ./startWebLogic.sh

Check the server logs (/opt/weblogic/user_projects/domains/mydomain/servers/AdminServer/logs/AdminServer.log) for startup messages. If successful, you’ll see “Server started in RUNNING mode.”

Step 7: Access the WebLogic Console
Open a browser and navigate to:

http://<your_server_ip>:7001/console

Log in with the administrator credentials you set during domain creation. The console provides a graphical interface to manage the server, domains, and applications.

Step 8: Deploy a Web Application
To deploy a WAR file (e.g., myapp.war):

  1. Log in to the WebLogic Console.
  2. Navigate to Deployments > Install.
  3. Click Choose File and select the WAR file from your local machine.
  4. Click Next, then Finish. The application will be deployed to the default server (AdminServer).
  5. Access the application via:
    http://<your_server_ip>:7001/myapp  # Replace "myapp" with the context root from the WAR file
    

Alternatively, use the WebLogic Scripting Tool (WLST) for command-line deployment:

cd /opt/weblogic/wlserver/common/bin
./wlst.sh

Enter the following WLST commands (replace paths and names as needed):

connect('weblogicadmin', 'StrongPassword123', 't3://localhost:7001')
deploy(appPath='/path/to/myapp.war', name='myapp', targets='AdminServer')
disconnect()
exit()

Troubleshooting Tips

0
看了该问题的人还看了