Introduction: This article briefly introduces the installation and startup process of Nginx under the Linux platform.
Note: Since the performance and widespread use of Nginx on the Windows platform are not as good as Nginx on the Linux platform, this tutorial is mainly targeted at the Linux platform.
First visit the official website of Nginx http://nginx.org/ and download the source code of Nginx (link http://nginx.org/download/nginx-1.8.0.tar.gz).
Next start the installation process. In order to facilitate version management and distinguish different versions, use root to log in to the system, create the directory Nginx_180 in the system root directory '/', and use the code as follows:
<code>[root<span>@localhost</span> ~]<span># mkdir /Nginx_180</span></code>
After that, download the nginx-1.8.0.tar. gz is copied to the /Nginx_180 directory, use the following code:
<code>[root<span>@localhost</span><span>Downloads</span>]<span># cp nginx-1.8.0.tar.gz /Nginx_180</span></code>
Next, decompress the package, locate the directory to /Nginx_180, use the following code:
<code>[root<span>@localhost</span><span>Nginx_180</span>]<span># tar xf nginx-1.8.0.tar.gz</span></code>
In this way, an nginx-1.8 is generated in the Nginx_180 directory .0 folder, the files inside are the source code of nginx1.8.0 version. The directory structure is as follows:
The configure file is an automatic script program of the Nginx software. Running configure can check the running environment and generate the required Makefile. Next, execute the following code:
<code>[root<span>@localhost</span> nginx-<span>1.8</span>.<span>0</span>]<span># ./configure --prefix=/Nginx</span></code>
It needs to be explained here that the option after executing configure -prefix is Specify the Nginx software installation path, readers can set it themselves.
After executing the configure file, you will get the Nginx Makefile, and then use the make command to compile:
<code>[root<span>@localhost</span> nginx-<span>1.8</span>.<span>0</span>]<span># make</span></code>
If no error message appears, it means that the compilation is successful and you can proceed to the next installation operation.
Note: When the author compiled here for the first time, he encountered a prompt that the pcre library was missing. Just execute yum -y install pcre pcre-devel.
Execute the make install command and install it into the system, code:
<code>[root<span>@localhost</span> nginx-<span>1.8</span>.<span>0</span>]<span># make install</span></code>
In order to verify whether Nginx is successfully installed, locate the current working directory to /Nginx, and you can see the following files
Note: The four directories in the above picture are As a result of compiling Nginx, a folder marked with temp will appear after the first run.
Run Nginx, the code is as follows:
<code>[root<span>@localhost</span><span>Nginx</span>]<span># ./sbin/nginx</span></code>
Now use the default configuration to start Nginx, open the browser, visit localhost, if you see the following web page, it means the installation is started successfully.
At this point, Nginx is installed.
The above introduces the Nginx installation method, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.