Installing Apache JMeter on Ubuntu: A Step-by-Step Guide
Apache JMeter is a powerful Java-based tool for performance and functional testing. This guide outlines the most reliable way to install JMeter on Ubuntu (22.04/24.04 LTS), including prerequisites, manual installation, and verification steps.
1. Prerequisite: Install Java (JDK 8 or Higher)
JMeter requires Java 8 (or newer) to run. Ubuntu’s default package manager (apt) offers OpenJDK, a free and open-source implementation of Java.
Steps:
- Update System Packages:
Runsudo apt update && sudo apt upgrade -yto ensure your system has the latest package versions. - Install OpenJDK 11 (recommended for compatibility):
Executesudo apt install openjdk-11-jdk -y. - Verify Installation:
Check the Java version withjava -version. You should see output like:
If Java is not found, ensureopenjdk version "11.0.20" 2023-07-18 OpenJDK Runtime Environment (build 11.0.20+8-post-Ubuntu-1ubuntu122.04) OpenJDK 64-Bit Server VM (build 11.0.20+8-post-Ubuntu-1ubuntu122.04, mixed mode)/etc/profileincludesexport PATH=$JAVA_HOME/bin:$PATHand runsource /etc/profile.
2. Download Apache JMeter
Get the latest stable version from the official Apache JMeter website (HTTPS recommended for security).
Steps:
- Download via
wget(replace5.6.3with the latest version from JMeter’s download page):wget https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.6.3.tgz - Verify the Download (optional but recommended):
Check the file’s SHA-256 checksum against the value on the JMeter website to ensure integrity.
3. Extract and Move JMeter to a System Directory
Extract the downloaded tarball and move it to /opt (a standard location for third-party applications).
Steps:
- Extract the Tarball:
tar -xzf apache-jmeter-5.6.3.tgz - Move to
/opt:
Usesudoto move the extracted folder to/opt:This ensures JMeter is accessible system-wide.sudo mv apache-jmeter-5.6.3 /opt/jmeter
4. Configure Environment Variables
Add JMeter’s bin directory to your PATH so you can run jmeter from any terminal.
Steps:
- Edit
~/.bashrc(for your user) or/etc/profile(for all users):nano ~/.bashrc - Add the Following Lines (replace
/opt/jmeterwith your JMeter path if different):export JMETER_HOME=/opt/jmeter export PATH=$JMETER_HOME/bin:$PATH - Apply Changes:
Runsource ~/.bashrc(orsource /etc/profilefor system-wide changes) to load the new variables.
5. Verify JMeter Installation
Check if JMeter is correctly installed and accessible.
Steps:
- Run JMeter in GUI Mode (optional):
This opens the JMeter graphical interface. Close it after verifying (you’ll use non-GUI mode for performance tests).jmeter - Check Version in Non-GUI Mode:
You should see output like:jmeter -v
If you encounter errors (e.g.,Copyright (c) 1998-2023 The Apache Software Foundation Version 5.6.3jmeter: command not found), double-check yourPATHconfiguration and runsource ~/.bashrcagain.
Optional: Install JMeter Plugins
For advanced features (e.g., WebSocket testing, JSON parsing), install plugins via the JMeter Plugins Manager:
- Open JMeter GUI, go to
Options>Plugins Manager. - Select Plugins: Choose required plugins (e.g., “WebSocket Samplers”) and click
Apply Changes and Restart JMeter. - Copy Plugins to
lib/ext(if installing manually):
For example, to add WebSocket support, downloadJMeterWebSocketSamplers.jarand place it in/opt/jmeter/lib/ext.
Troubleshooting Common Issues
- Java Not Found: Ensure
java -versionworks andJAVA_HOMEis set in/etc/profile. - Permission Denied: Run
sudo chmod -R 755 /opt/jmeterto grant read/execute permissions. - Plugin Errors: Verify plugin compatibility with your JMeter version (check the plugin’s documentation).
By following these steps, you’ll have a fully functional JMeter installation on Ubuntu, ready for performance and functional testing.
以上就是关于“ubuntu jmeter如何安装”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm