Web Application Environment Installation
I. Basic concepts
Package Management on Operating Systems
Debian/Ubuntu Package Management
Advanced Packaging Tool – APT
apt-get
is a command line tool for interacting with the Advanced Package Tool (APT) library (a package management system for Linux distributions). It allows you to search for, install, manage, update, and remove software.
Configuration of the APT system repositories is stored in the /etc/apt/sources.list
file and the /etc/apt/sources.list.d
directory. You can add additional repositories in a separate file in the /etc/apt/sources.list.d
directory, for example, redis.list
, docker.list
.
dpkg
dpkg
is a package manager for Debian-based systems. It can install, remove, and build packages, but unlike other package management systems, it cannot automatically download and install packages – or their dependencies. APT and Aptitude are newer, and layer additional features on top of dpkg.
# install |
CentOS/RHEL Package Management
Yellow Dog Updater, Modified (YUM)
YUM
is the primary package management tool for installing, updating, removing, and managing software packages in Red Hat Enterprise Linux. YUM
performs dependency resolution when installing, updating, and removing software packages. YUM
can manage packages from installed repositories in the system or from .rpm
packages. The main configuration file for YUM
is at /etc/yum.conf
, and all the repos are at /etc/yum.repos.d
.
# add repos config to /etc/yum.repos.d |
# search package |
RPM (RPM Package Manager)
RPM
is a popular package management tool in Red Hat Enterprise Linux-based distros. Using RPM
, you can install, uninstall, and query individual software packages. Still, it cannot manage dependency resolution like YUM
. RPM
does provide you useful output, including a list of required packages. An RPM
package consists of an archive of files and metadata. Metadata includes helper scripts, file attributes, and information about packages.
# install |
Windows Package Management
Chocolatey
winget
Microsoft Store
MacOS Package Management
brew
Mac App Store
Service Manager
Systemd
II. Software Installation
JDK/JRE
Headless version
Headless is the same version than the latter without the support of keyboard, mouse and display systems. Hence it has less dependencies and it makes it more suitable for server application.
Debian/Ubuntu/Deepin
Install openjdk from Official APT Repositories
Supported Operating Systems
- Ubuntu/Debian
- Deepin
Installing
# insall |
Installing Options
- openjdk-8/11/17-jdk
- openjdk-8/11/17-jdk-headless
- openjdk-8/11/17-jre
- openjdk-8/11/17-jre-headless
Maven
CentOS/RHEL
Install from the EPEL YUM repository
# Add the EPEL repository, and update YUM to confirm your change |
Add Aliyun Mirror. Add the following lines to the tag <mirrors>
in the /etc/maven/settings.xml
<mirror> |
Python
Debian/Ubuntu
Install from the official APT repository
# Update the environment |
CentOS/RHEL
Install from the Official YUM repository
# Update the environment. Make sure that we are working with the most up to date environment possible in terms of our packages |
Node.js
CentOS/RHEL
Install from the EPEL YUM repository
# Add the EPEL repository, and update YUM to confirm your change |
Redis
Linux
Install from Snapcraft
The Snapcraft store provides Redis packages that can be installed on platforms that support snap. Snap is supported and available on most major Linux distributions.
sudo snap install redis |
If your Linux does not currently have snap installed, install it using the instructions described in Installing snapd.
Debian/Ubuntu/Deepin
Install from the official APT repositories
sudo apt-get update |
Update config
sudo vim /etc/redis/redis.conf |
Uncomment the following line
# supervised auto |
to
supervised auto |
Enable and restart Redis service
sudo systemctl enable redis.service |
Verify
systemctl status redis |
Install from the Redis APT repository
Most major Linux distributions provide packages for Redis.
# prerequisites |
# add the repository to the apt index, update it. and then install redis. |
CentOS/RHEL
Install from the EPEL YUM repository
Add the EPEL repository, and update YUM to confirm your change:
sudo yum install epel-release
sudo yum updateInstall Redis:
sudo yum install redis
Start Redis:
sudo systemctl start redis
Optional: To automatically start Redis on boot:
sudo systemctl enable redis
Verify the Installation
Verify that Redis is running with redis-cli
:
redis-cli ping |
If Redis is running, it will return:
PONG |
Windows
Redis is not officially supported on Windows.
Install from Source
Supported Operating Systems
- All Linux distros (distributions)
- MacOS
You can compile and install Redis from source on variety of platforms and operating systems including Linux and macOS. Redis has no dependencies other than a C compiler and libc
.
# Download source files |
If the compile succeeds, you’ll find several Redis binaries in the src
directory, including:
- redis-server: the Redis Server itself
- redis-cli is the command line interface utility to talk with Redis.
Starting and stopping Redis
cd redis-stable |
update password in redis.conf
# requirepass foobared |
to
requirepass YOUR_STRONG_PASSWORD |
Manage Redis service using systemd
Create the /etc/systemd/system/redis.service
file, and add the following line to the file
[Unit] |
copy the files
cd /path/to/redis/source/dir |
Edit config
sudo vim /etc/redis/redis.conf |
Uncomment the following line
# supervised auto |
to
supervised auto |
Enable and start Redis service
systemctl enable redis |
To verify Redis is up and running, run the following command:
redis-cli PING |
MySQL
Linux
Install from binary distributions
Aim: Creating a MySQL service starts automatically when the computer starts up.
Download generic Unix/Linux binary package
Linux - Generic (glibc 2.12) (x86, 64-bit), Compressed TAR Archive. For example: mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
Installing
# Install dependency `libaio` library |
Note: This procedure assumes that you have root
(administrator) access to your system. Alternatively, you can prefix each command using the sudo (Linux) or pfexec (Solaris) command.
Managing MySQL Server with systemd
Create a user for remote access
- Enable MySQL server port in the firewall
If the firewall management on Linux uses ufw, you can run the following command to enable MySQL server port.
ufw allow 3306/tcp |
- Update bind-address in /etc/my.cnf
Change 127.0.0.1 to Local IP like 192.168.1.100
bind-address=192.168.1.100 |
- Create a MySQL user for remote login
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user; |
- Verify
Connect the remote MySQL server from your local computer
# testing the port is open |
Errors
Error: mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
When you run mysql -u root -p
.
Solutions
# centos |
Error: ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
To set up your password for the first time:
mysql> SET PASSWORD = PASSWORD('new password'); |
Windows
Docker
docker run --name={mysql_container_name} -d -p {exposed_port}:3306 \ |
Elasticsearch
Kibana
CentOS/RHEL
Install from the elastic YUM repository
Download and install the public signing key:
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch |
Create a file called kibana.repo
in the /etc/yum.repos.d/
directory for RedHat based distributions, or in the /etc/zypp/repos.d/
directory for OpenSuSE based distributions, containing:
[kibana-8.x] |
You can now install Kibana with one of the following commands:
# older Red Hat based distributions |
Install by downloading RPM file
Downloading the Kibana RPM file
wget https://artifacts.elastic.co/downloads/kibana/kibana-8.8.2-x86_64.rpm |
Start Elasticsearch and generate an enrollment token for Kibana
When you start Elasticsearch for the first time, the following security configuration occurs automatically:
- Authentication and authorization are enabled, and a password is generated for the
elastic
built-in superuser. - Certificates and keys for TLS are generated for the transport and HTTP layer, and TLS is enabled and configured with these keys and certificates.
The password and certificate and keys are output to your terminal.
Run Kibana with systemd
To configure Kibana to start automatically when the system starts, run the following commands:
sudo /bin/systemctl daemon-reload |
Kibana can be started and stopped as follows:
sudo systemctl start kibana.service |
Log information can be accessed via journalctl -u kibana.service
.
Configure Kibana via the config file
Kibana loads its configuration from the /etc/kibana/kibana.yml
file by default. The format of this config file is explained in Configuring Kibana.
Nginx
Apache Tomcat
Docker
Debian/Ubuntu/Deepin
Install from the Docker APT repository
Set up the repository
- Update the
apt
package index and install packages to allowapt
to use a repository over HTTPS
sudo apt-get update |
- Add Docker’s official GPG key:
sudo install -m 0755 -d /etc/apt/keyrings |
- Use the following command to set up the repository
# 中科大源 docker - debian/deepin |
Install Docker Engine
- Update the
apt
package index:
sudo apt-get update |
- Install Docker Engine, containerd, and Docker Compose.
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin |
- Verify that the Docker Engine installation is successful by running the
hello-world
image
sudo docker run hello-world |
View Docker version and status
docker version |
References
Linux package management with YUM and RPM
systemd.unit — Unit configuration
MySQL