Installing Nginx on CentOS 6, Compiling and Installing Nginx on Linux
Preface Recently I deployed a django project to a new server, and this server was given a CentOS 6 system. The official repos are very old, and the yum manager was broken by ops, so I couldn't load the EPEL repo. If I wanted to use nginx I could only compile and install it myself~ Download nginx source First, download the installation files from Nginx's official website. Link: http://nginx.org/ The version I used is: nginx-1.12.1.tar.gz Install the environment required for compilation Install gcc Install n
目录13 个章节
Preface
Recently I deployed a django project to a new server, and this server was given a CentOS 6 system. The official repos are very old, and the yum manager was broken by ops, so I couldn't load the EPEL repo. If I wanted to use nginx I could only compile and install it myself~
Download nginx source
First, download the installation files from Nginx's official website. Link: http://nginx.org/ The version I used is: nginx-1.12.1.tar.gz
Install the environment required for compilation
Install gcc
Installing nginx requires first compiling the source code downloaded from the official website. Compilation depends on a gcc environment. If there is no gcc environment, you need to install it:
yum install gcc-c++
Install PCRE pcre-devel
PCRE (Perl Compatible Regular Expressions) is a Perl library that includes a Perl-compatible regular expression library. Nginx's http module uses pcre to parse regular expressions, so you need to install the pcre library on Linux. pcre-devel is a secondary development library for developing with pcre. Nginx also needs this library. Command:
yum install -y pcre pcre-devel
Install zlib
The zlib library provides many compression and decompression methods. Nginx uses zlib to gzip the contents of http packets, so you need to install the zlib library on CentOS.
yum install -y zlib zlib-devel
Install OpenSSL
OpenSSL is a powerful Secure Sockets Layer cryptographic library, covering major cryptographic algorithms, commonly used key and certificate encapsulation management functions, and the SSL protocol, and providing a rich set of applications for testing or other purposes. Nginx not only supports the http protocol, but also supports https (that is, transmitting http over the ssl protocol), so you need to install the OpenSSL library on CentOS.
yum install -y openssl openssl-devel
Only after installing the above four items can you proceed to install Nginx.
Install nginx
Extract
tar zxvf nginx-1.12.1.tar.gz
Compile
cd nginx-1.12.1
./configure
make
make install
After executing the above commands, Nginx installation is complete, but the extracted directory is not the installation directory. Use the following command to find the installation directory. After installation on this machine, the installation directory is: /usr/local/nginx
whereis nginx
Start and stop nginx
Starting and stopping nginx must be executed in the sbin directory of the installation directory. You can also execute it from outside, but you need to write the full path.
# 启动
/usr/local/nginx/sbin/nginx
# 停止
# 下面命令当于先查出nginx进程id再使用kill命令强制杀掉进程。
/usr/local/nginx/sbin/nginx -s stop
# 下面命令待nginx进程处理任务完毕进行停止
/usr/local/nginx/sbin/nginx -s quit
Reload the configuration file
Reload the configuration file. After nginx's configuration file nginx.conf is modified, to make the configuration take effect you need to restart nginx. Using -s reload, you don't need to stop nginx first and then start nginx for the configuration information to take effect in nginx.
/usr/local/nginx/sbin/nginx -s reload
Recommended nginx restart order: Restarting nginx is equivalent to stopping first then starting, i.e. execute the stop command first then the start command.
/usr/local/nginx/sbin/nginx -s quit
/usr/local/nginx/sbin/nginx
PS: It is recommended to add
/usr/local/nginx/sbin/to the environment variables, so you don't have to enter the full path when using nginx.
Set up startup on boot
Edit: /etc/rc.local
Add a line: /usr/local/nginx/sbin/nginx
Set execute permission:
chmod 755 rc.local
_EOF_
Installing Nginx on CentOS 6, Compiling and Installing Nginx on Linux
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
部署个SSH蜜罐玩玩,既能增强安全性,又能当电子蛐蛐
部署SSH蜜罐?改个端口,装fakessh白嫖密码字典,sshesame当电子蛐蛐记录操作。typora插件更新麻烦,安全测试才是真本事。
2024-11-04 · Linux · 约 1 分钟
什么年代了怎么还在用bash啊?现代化shell开箱体验: fish, nu, elvish
Fish开箱即用,智能补全和颜色真不错?Nushell像SQL处理数据,万物皆对象,但学曲线陡?Elvish像编程语言,逻辑严密,社区小众?何必折腾,直接换Shell?
2026-03-17 · Linux · 约 1 分钟
Manjaro-安装docker笔记
Manjaro的官方源里面就有docker,直接安装就行。 sudo pacman -S docker 启用docker服务 sudo systemctl start docker 设置开机自启动 sudo systemctl enable docker 这样安装的docker默认是只有root用户才能用,我们需要把当前用户添加到docker用户组,才可以。 # 如果还没有 docker grou
2021-12-18 · Linux · 约 1 分钟
Linux编译安装Python3-6,理论上各个发行版通用
前言 最近笔者把一个django项目部署到一个新的服务器上,而这个服务器给的是CentOS6版本的系统,官方源很旧,还被运维把源搞坏了,没办法通过源安装Python3.6以及pip,所以只好用最原始的方法,编译安装! 注意 如果本机安装了python2,尽量不要管他,使用python3运行python脚本就好,因为可能有程序依赖目前的python2环境,不要动现有的python2环境! 官网下载的
2022-06-17 · Linux · 约 1 分钟
讨论
共 0 条加载评论中…