Linux installs Nginx and deploys front-end projects [Internal/External Network - Nanny Level Tutorial]

Table of contents

1 Download the required installation package

2 installation steps

2.1 Upload the downloaded complete folder to your path in the form of a compressed package and unzip it.

2.2 Go to the gcc folder and execute the command:

2.3 Go to the gcc-c++ folder and execute the command:

2.4 Check whether gcc and gcc-c++ are installed successfully

2.5 Execute gcc -v, g++ -v, if there is success or version information, it means the installation is successful;

2.6 Install PCRE:

2.7 Install libtool

 2.8 install nginx

3 How to operate

3.1 Enter the linux server and switch to the root user

3.2 Go directly to the default installation location of nginx

3.3 Explanation of ngin file content

3.4 How to deploy the front-end project to Nginx

3.5 Upload dist.tar compressed package

3.6 Decompress the dist.tar file

3.7 Use cd to switch to the conf file after successful decompression

3.8 Modify the configuration file in nginx.conf according to the actual situation

3.9 Start Nginx

3.10 Check whether the startup is successful

3.11 Accessing deployed front-end projects


        Because the company needs the intranet to deploy the front-end and back-end, it is very troublesome to download without the Internet, so today I will share with you how to deploy the front-end Vue project on the intranet.

Note : It is best to switch to the root user in advance, so that the permissions are relatively large.

1 Download the required installation package


download link

2 installation steps

2.1 Upload the downloaded complete folder to your path in the form of a compressed package and unzip it.

2.2 Go to the gcc folder and execute the command:

rpm -Uvh *.rpm --nodeps --force

2.3 Go to the gcc-c++ folder and execute the command:

rpm -Uvh *.rpm --nodeps --force

2.4 Check whether gcc and gcc-c++ are installed successfully

2.5 Execution gcc -v ,  g++ -v if there is success or version information, it means the installation is successful;

2.6 Install PCRE:

//1.解压对应文件
tar -zxvf pcre-8.35.tar.gz
//2.进入对应文件夹
cd pcre-8.35
//3.执行命令:依次执行
./configure
make
make install

2.7 Install libtool

//1.解压对应文件
tar -zxvf libtool-2.4.2.tar.gz
//2.进入对应文件夹
cd libtool-2.4.2
//3.执行命令:依次执行
./configure
make
make install

 2.8 install nginx

//1.解压对应文件
tar -zxvf nginx-1.13.9.tar.gz
//2.进入对应文件夹
cd nginx-1.13.9
//3.执行命令:依次执行
./configure
make
make install

3 How to operate

3.1 Enter the linux server and switch to the root user

su root Enter the password if you have a password, and operate directly without a password. (It is not the administrator who cannot operate the nginx configuration file and delete related files)

3.2 Go directly to the default installation location of nginx

cd /usr/local/nginx

3.3 Explanation of ngin file content

Entering nginx contains the files shown in the figure below. Our front-end deployment is mainly to operate conf (configuration file), html (put the front-end packaged dist file), sbin (start nginx)

3.4 How to deploy the front-end project to Nginx

        How to place the front-end dist file under the nginx html file, first of all, note that nginx can decompress the compressed package with the tar suffix by default, so you need to pack it into a tar compressed package externally, if you want to pack it into a compressed package with other suffixes, you can also , but you need to install the decompressed plug-in, but isn’t it impossible to download from the intranet? It is recommended to use 7ZIP to directly pack into a tar archive.

Then

cd html

Enter the html directory, which contains two html files by default.

3.5 Upload dist.tar compressed package

Use the rz command, directly enter rz to upload the dist.tar file. (The rz -y command will directly overwrite the uploaded file with the same name)

3.6 Decompress the dist.tar file

Use tar -xvf dist.tar directly to decompress

3.7 Use cd to switch to the conf file after successful decompression

3.8 Modify the configuration file in nginx.conf according to the actual situation

3.9 Start Nginx

Switch to the sbin directory and execute

./nginx

3.10 Check whether the startup is successful

implement

netstat -tpln or ps -ef|grep nginx

Check if it started successfully

3.11 Accessing deployed front-end projects

Directly enter the ip of linux: the port number nginx monitors to access

For example

127.0.0.1:3000

Finish.

3.12 Nginx related commands

The prerequisite for using nginx operation commands: you must enter the /sbin folder under the automatically generated directory of nginx .

1 Install the automatically generated directory:

/usr/local/nginx/

2 Check the version number of nginx

./nginx -v

3. close nginx

./nginx -s stop

4. Reload nginx

Execute the command under the directory: /usr/local/nginx/sbin , without restarting the server, it will be compiled automatically.

./nginx -s reload

Guess you like

Origin blog.csdn.net/m0_64210833/article/details/131066849