Home Backend Development PHP Tutorial Sample code for replacing Nginx server with Tengine in LNMP environment

Sample code for replacing Nginx server with Tengine in LNMP environment

Oct 12, 2017 am 09:31 AM
lnmp nginx server

The LNMP environment I have used before has always been the native Nginx server. In recent days, I have seen many large websites using Tengine developed by the Taobao team based on Nginx and decided to install it in my own virtual machine for fun.

I won’t say much about the introduction of Tengine. Anyway, it is said that the performance is much improved compared to the native Nginx (reference: http://tengine.taobao.org/)

The following is about Installation process:

Before this, I would like to recommend the simple and easy-to-use upload and download commands rz and sz of the Linux system

We can install it through yum install lrzsz

Upload and download Command test

1) Upload (rz)

Run the rz command on the client SSH command line. The command is as follows:

[root@oldboy ~]# rz

After execution, a file selection window for uploading will pop up, and you can select relevant files to upload (direct uploading of directories is not supported).

Tip: You can use rz -y to implement overlay upload. The default directory of the upload window can be set in the SSH client.

2) Download (sz)

To achieve downloading, you can directly use szfilename, where filename is the name of the file you want to download. If it is a directory, it needs to be packaged into a single file before downloading.

[root@oldboy ~]# sz oldboy.txt #<==oldboy.txt must exist, it can be a relative path or an absolute path.

The following is the installation of Tengine

To install Tengine we need to prepare two installation packages

google-perftools-1.8.2.tar.gz

tengine-2.1.2.tar.gz

After the download is completed, back up the original Nginx service first

# cd /usr/local/

# mv nginx nginxbak

Backup is complete, start installing Tengine

1.

1. Unzip the google-perftools-1.8.2.tar.gz installation package

# tar xf google-perftools-1.8.2.tar.gz

2. Install the source code

# cd google-perftools-1.8.2

#./configure --enable-frame-pointers

# make && make install

3. Complete the google-perftools-1.8.2 installation

2. Tengine installation

1. Also unzip the tengine-2.1.2.tar.gz installation package first

# tar xf tengine-2.1.2.tar.gz

2. Install the source code

  # ./configure
   --prefix=/usr/local/nginx 
  --with-http_stub_status_module 
  --with-http_ssl_module 
  --with-http_spdy_module 
  --with-http_gzip_static_module 
  --with-ipv6 --with-http_sub_module 
  --with-google_perftools_module 
  --with-http_image_filter_module 
  --with-http_realip_module 
  --with-http_concat_module
        # make && make install
Copy after login

3. Complete the installation

3. Check the nginx version

# nginx -V

If you encounter this error: nginx: error while loading shared libraries: libprofiler.so.0: cannot open shared object file: No such file or directory

That means the system does not know which directory xxx.so is placed in.

At this time, you need to add the directory where xxx.so is located in /etc/ld.so.conf.

Generally speaking, there are many so in the directory /usr/local/lib, so adding the line /usr/local/lib to /etc/ld.so.conf can solve this problem .

After saving /etc/ld.so.conf, you also need to execute /sbin/ldconfig –v to update it

Then try again #nginx -V

This means the installation has been successful

4. Restart Nginx

# service nginx restart

If you encounter the following situation:

You can use: # pkill -9 nginx to kill the process

Then use: # service nginx restart

After the restart is completed, visit:

##5. Configure nginx.conf

# vim /usr/local/nginx/conf/nginx.conf

Add at the bottom :include vhost/*.conf; Then restart, you can configure multi-site access

Hide Tengine version information displayed in the foreground

   http {     
           #关闭 版本号信息设置           
           server_tag off;           
           server_info off;           
           server_tokens off;
      }
Copy after login

Set to prohibit access through IP, only through domain name

 server {
          #设置禁止通过 ip 访问,只能通过域名
         listen 80 default;         
         server_name _;         
         return 500;
     }
Copy after login

At this point, the Tengine installation and configuration is almost completed.

(If there are any errors or deficiencies in the above content, I hope you will forgive me. Welcome to exchange and learn from each other; thank you!)

The above is the detailed content of Sample code for replacing Nginx server with Tengine in LNMP environment. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to configure cloud server domain name in nginx How to configure cloud server domain name in nginx Apr 14, 2025 pm 12:18 PM

How to configure an Nginx domain name on a cloud server: Create an A record pointing to the public IP address of the cloud server. Add virtual host blocks in the Nginx configuration file, specifying the listening port, domain name, and website root directory. Restart Nginx to apply the changes. Access the domain name test configuration. Other notes: Install the SSL certificate to enable HTTPS, ensure that the firewall allows port 80 traffic, and wait for DNS resolution to take effect.

How to check the name of the docker container How to check the name of the docker container Apr 15, 2025 pm 12:21 PM

You can query the Docker container name by following the steps: List all containers (docker ps). Filter the container list (using the grep command). Gets the container name (located in the "NAMES" column).

How to check whether nginx is started How to check whether nginx is started Apr 14, 2025 pm 01:03 PM

How to confirm whether Nginx is started: 1. Use the command line: systemctl status nginx (Linux/Unix), netstat -ano | findstr 80 (Windows); 2. Check whether port 80 is open; 3. Check the Nginx startup message in the system log; 4. Use third-party tools, such as Nagios, Zabbix, and Icinga.

How to configure nginx in Windows How to configure nginx in Windows Apr 14, 2025 pm 12:57 PM

How to configure Nginx in Windows? Install Nginx and create a virtual host configuration. Modify the main configuration file and include the virtual host configuration. Start or reload Nginx. Test the configuration and view the website. Selectively enable SSL and configure SSL certificates. Selectively set the firewall to allow port 80 and 443 traffic.

How to check nginx version How to check nginx version Apr 14, 2025 am 11:57 AM

The methods that can query the Nginx version are: use the nginx -v command; view the version directive in the nginx.conf file; open the Nginx error page and view the page title.

How to start containers by docker How to start containers by docker Apr 15, 2025 pm 12:27 PM

Docker container startup steps: Pull the container image: Run "docker pull [mirror name]". Create a container: Use "docker create [options] [mirror name] [commands and parameters]". Start the container: Execute "docker start [Container name or ID]". Check container status: Verify that the container is running with "docker ps".

How to start nginx server How to start nginx server Apr 14, 2025 pm 12:27 PM

Starting an Nginx server requires different steps according to different operating systems: Linux/Unix system: Install the Nginx package (for example, using apt-get or yum). Use systemctl to start an Nginx service (for example, sudo systemctl start nginx). Windows system: Download and install Windows binary files. Start Nginx using the nginx.exe executable (for example, nginx.exe -c conf\nginx.conf). No matter which operating system you use, you can access the server IP

How to create containers for docker How to create containers for docker Apr 15, 2025 pm 12:18 PM

Create a container in Docker: 1. Pull the image: docker pull [mirror name] 2. Create a container: docker run [Options] [mirror name] [Command] 3. Start the container: docker start [Container name]

See all articles