Home >Operation and Maintenance >Nginx >How to install and configure nginx for LNMP compilation and installation
1. Foreword
This installation uses source code installation. The main resource package is downloaded from the official website, and the secondary dependencies are installed using yum. This article only involves the installation of nginx, not The configuration of nginx and how nginx accesses php are not covered in this article.
2. Installation steps
nginx
2.1. Download nginx
wget http://nginx.org/download/nginx-1.12.0.tar.gz##2.2 , Download the pcre installation package
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gzThis package does not need to be installed, it is just a medium2.3. Unzip nginx and pcre
tar zxvf nginx-1.12.0.tar.gz
tar zxvf pcre-8.39.tar.gz2.4. Install dependency packages
yum install -y gcc gcc-c++ zlib-devel2.5. Generate makefile
cd nginx-1.12.0./configure --prefix=/usr/local/nginx (installation directory) --with-pcre=../pcre-8.39/(pcre relative directory) The results are as follows: 2.6. Compile and install
make && make installThe results are as follows : The nginx installation is completed here
3. Start nginx
/usr/local/ nginx/sbin/nginxCheck the running status through ps aux|grep nginx At this point nginx will start normally.4. Open port 80 for external access
If you only run it without opening the port, the browser will not be able to access it.firewall-cmd --zone=public --add-port=80/tcp --permanentSuccessfully opened port 80You need to restart the firewall to open the play port
systemctl restart firewalld.serviceGo here , you can re-open the browser and access Access the browser, and the above interface appears, which means that nginx has been installed.
The above is the detailed content of How to install and configure nginx for LNMP compilation and installation. For more information, please follow other related articles on the PHP Chinese website!