Install and start nginx in Linux
- 2020-09-16 07:56:19
- OfStack
Nginx is a high-performance web server and also a very good reverse proxy server, which can achieve load balancing, dynamic and static separation and other strategies. linux is widely used.
Since nginx depends on pcre and zlib, you need to install pcre and zlib before installing nginx (For convenience, I put the packages for pcre, zlib, and nginx in the same directory).
1. Install pcre
Download from the website of pcre tar gz package, website address is: https: / / sourceforge net projects/pcre/files/pcre /, I downloaded here is: pcre - 8.39. tar. gz
tar -zxvf pcre-8.39.tar.gz
cd pcre-8.39
./configure
make
make install
2. Install zlib
Download the tar.gz package from zlib's official website at http:// zlib.net /. Here I downloaded ES45en-1.2.8. tar.gz
tar -xvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make
make install
3. Install nginx
Download from the website of nginx tar gz package, website address is: http: / / nginx org/en/download html, I downloaded here is: nginx - 1.11.5. tar. gz
tar -zxvf nginx-1.11.5.tar.gz
cd nginx-1.11.5
./configure --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --pid-path=/usr/local/nginx/sbin/nginx.pid --with-http_ssl_module --with-pcre=../pcre-8.39 --with-zlib=../zlib-1.2.8
make
make install
At this point, nginx is installed
4. Configure and start nginx
After the installation of the above steps and directory Settings, nginx launcher is/usr/local/nginx/sbin/nginx, configuration file is/usr local/nginx/conf/nginx conf, port can be modified in the configuration file, the reverse proxy path, etc
The command to start nginx is:
/usr/local/nginx/sbin/nginx -t // test nginx.conf Is the configuration correct
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf // According to the nginx.conf In the configuration, start nginx service