Huawei Cloud Yaoyun Server L Instance Evaluation | Best Practices for Enterprise Projects Package Management Tool Installation Software (6)

Huawei Cloud Yaoyun Server L instance evaluation | Enterprise project best practice series:

Huawei Cloud Yaoyun Server L Instance Evaluation|Introduction to Cloud Server Best Practices for Enterprise Projects (1)
Huawei Cloud Yaoyun Server L Instance Evaluation|Best Practices for Enterprise Projects Huawei Cloud Introduction (2)
Huawei Cloud Yaoyun Server L Instance Evaluation | Enterprise Project Best Practices Huawei Cloud Yaoyun Server L Instance Introduction (3)
Huawei Cloud Yaoyun Server L Instance Evaluation | Best Practices for Enterprise Projects: Yunyao Cloud Server L Instance Purchase (4)
Huawei Cloud Yaoyun Server L Instance Evaluation | Evaluation of Best Practices for Enterprise Projects Use Case (5)
Huawei Cloud Yaoyun Server L Instance Evaluation|Enterprise Project Best Practice Package Management Tool Installation Software (6)
Huawei Cloud Yaoyun Server L instance evaluation | Enterprise project best practices for docker deployment and application (7)
Huawei Cloud Yaoyun Server L instance evaluation | Enterprise project best practices for private library construction verdaccio (8) a>
Huawei Cloud Yaoyun Server L Instance Evaluation|Enterprise Project Best Practices for Starting the Pet Reservation Project (9)
Huawei Cloud Yaoyun Server L Instance Evaluation|Enterprise Project Best Practice Best Practices of Scheduled Tasks and Queue Queue Practice (10)
Huawei Cloud Yaoyun Server L Instance Evaluation | Best Practices of Enterprise Projects Stress Test (11)
Huawei Cloud Yaoyun Server L instance evaluation | Suggestions and summary of best practices for enterprise projects (12)


7. Huawei Cloud Server L instance evaluation package management tool installation software:

According to the enterprise-level project architecture diagram, this chapter mainly installs the basic environment LNMP of the company's enterprise projects, and installs the related package managers Composer, Node, Npm, and Yarn. It evaluates whether there are any problems with the package management tool installation software. If there are no problems, Will try to use Shell to install the environment.

Insert image description here


1. Preparation:

First, check whether the LNMP environment is installed by default on the server. You can see that the environment is very clean and there are not too many default software installed, which is conducive to customizing some environment needs.
Insert image description here

Because the company's software architecture adopts the SOA architecture, there will be multiple intranet server instances. Generally, newly purchased servers need to update the host name to identify the server, which facilitates good identification in subsequent maintenance.


2. Install PHP 7.3, PHP 7.3-FPM, PHP 7.3 related extensions:

PHP is a general-purpose open source scripting language especially suitable for web development. It can be embedded in HTML, run on the server side, and interact with the database to generate dynamic web pages. The company uses PHP's Laravel framework. The Laravel framework can quickly develop enterprise applications such as CRM, ERP, OA, and industry software with low code, reducing operational management and control costs for enterprises. The platform has powerful code generation tools, unique process engines, and rich Rapid development functions such as form controls.

Insert image description here

# 1. 添加对其他软件源的管理
# -y 标志表示自动同意安装,没有它,将在终端窗口中收到每次安装的提示
sudo apt -y install software-properties-common

# 2. 安装存储库 ppa:ondrej/php,它将提供所有 PHP 版本
sudo add-apt-repository ppa:ondrej/php

# 3. 更新apt-get源,以便包管理器可以看到新列出的包
sudo apt-get update

# 4. 安装php、fpm和php相关扩展
sudo apt-get install -y php7.3 php7.3-fpm php7.3-xml php7.3-mbstring php7.3-gd php7.3-mcrypt php7.3-curl php7.3-mysql

# 5. 查看PHP安装的版本及安装的PHP扩展:
php -version
php -m

Insert image description here

Insert image description here

Check the installed version of PHP and installed PHP extensions:

Insert image description here


3. Install Nginx:

Nginx is a web server that can also be used for load balancing and reverse proxy, and is also used in a large number of load balancing scenarios.

Insert image description here

sudo apt-get install -y nginx

Insert image description here


4. Install node, npm and yarn from source code:

Node is

# 下载源码包
wget https://cdn.npmmirror.com/binaries/node/latest-v16.x/node-v16.15.1-linux-x64.tar.xz
# 解压
tar -xf node-v16.15.1-linux-x64.tar.xz
# 移动到local目录
mv node-v16.15.1-linux-x64 /usr/local/node
# 软链接到bin中命令
ln -s /usr/local/node/bin/node /usr/bin/node
ln -s /usr/local/node/bin/npm /usr/bin/npm
# 安装yarn并软链接到bin中命令
npm install yarn -g
ln -s /usr/local/node/bin/yarn /usr/bin/yarn
# 查看npm、node、yarn版本
npm -v
node -v
yarn -v

Insert image description here

In the past, if you used Vagrant to install an Ubuntu virtual machine locally, you first needed to replace the apt source, such as Alibaba source, Tencent source, Tsinghua source, etc. After checking the /etc/apt/sources.list file, Huawei was used directly by default. The source is very fast in terms of speed. As you can see above, the average download speed reaches 1.56MB/s.

Insert image description here


5. Install PHP’s package management tool Composer from source code:

Composer is a dependency management tool for PHP 5.3 and above. It allows you to declare the code libraries that your project depends on and install them for you in the project. Composer is not a package manager.

Insert image description here

# 下载PHP包管理工具composer二进制程序文件
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
# 移动到启动程序bin目录
sudo mv composer.phar /usr/local/bin/composer
# 查看composer版本
composer --version

Insert image description here


6. Reinstall the system:

Using the package management tool as above to install LNMP related software can be completed smoothly, because there are many commonly used shell script installation environments. Next, you need to initialize the environment, and then test the shell to install php, nginx, node and other programs.

The function of reinstalling the system is also commonly used. Once, the company's server was unfortunately attacked. According to the normal repair time, it may take a lot of time and manpower to complete, such as clearing dependencies, version upgrades, and repairing bad files. . If you reinstall the system and use shell scripts for daily maintenance, you can quickly copy an environment to prevent affecting the functions of the production environment. Of course, the company uses K8S cluster deployment in the Java system, and the Dockerfile is used to replicate the environment more conveniently and quickly.

Insert image description here


7. Shell script installation:

Shell is a command line interpreter that provides users with an interface system-level program that sends requests to the Linux kernel in order to run programs. Users can use the shell to start, suspend, stop, and even write some programs.

Insert image description here

#! /bin/bash

echo '=== start install ========'

# 1. 添加对其他软件源的管理
# -y 标志表示自动同意安装,没有它,将在终端窗口中收到每次安装的提示
sudo apt -y install software-properties-common

# 2. 安装存储库 ppa:ondrej/php,它将提供所有 PHP 版本
sudo add-apt-repository ppa:ondrej/php

# 3. 更新apt-get源,以便包管理器可以看到新列出的包
sudo apt-get update

# 4. 安装php、fpm和php相关扩展
sudo apt-get install -y php7.3 php7.3-fpm php7.3-xml php7.3-mbstring php7.3-gd php7.3-mcrypt php7.3-curl php7.3-mysql

# 5. 安装nginx
sudo apt-get install -y nginx

# 6. 源码安装node、npm、yarn
wget https://cdn.npmmirror.com/binaries/node/latest-v16.x/node-v16.15.1-linux-x64.tar.xz
tar -xf node-v16.15.1-linux-x64.tar.xz
mv node-v16.15.1-linux-x64 /usr/local/node
ln -s /usr/local/node/bin/node /usr/bin/node
ln -s /usr/local/node/bin/npm /usr/bin/npm
npm install yarn -g
ln -s /usr/local/node/bin/yarn /usr/bin/yarn

# 7. 安装composer
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer

echo '=== end install ========'

# 8. 查看版本
php -version
nginx -v

# 查看npm、node、yarn版本
npm -v
node -v
yarn -v
composer --version

Insert image description here

8. Summary:

By installing the LNMP environment on the Huawei Cloud Server L instance that conforms to the company's enterprise projects, no LNMP environment that does not meet the needs was found. During the installation process,The default Huawei The download speed of Yunyuan is very fast and it is worth recommending. Such as source code installation, apt-get package management installation, and shell script installation are all well supported.

Insert image description here

The following is a list of installed software:

Insert image description here
The following is the overall test progress:

Insert image description here

Guess you like

Origin blog.csdn.net/wanmeijuhao/article/details/133785612