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 许可协议。转载请注明出处!
相关文章
Config-Software-mirrors-source-for-OpenSuSE-42-3
I just wrote a shell file to finish it. # Disable the system source sudo zypper mr -da # Add aliyun mirrors sudo zypper addrepo -f http://mirrors.aliyun.com/opensuse/update/leap/42.3/non-oss/ openSUS
2022-06-17 · Linux · 约 1 分钟
什么年代了怎么还在用bash啊?现代化shell开箱体验: fish, nu, elvish
Fish开箱即用,智能补全和颜色真不错?Nushell像SQL处理数据,万物皆对象,但学曲线陡?Elvish像编程语言,逻辑严密,社区小众?何必折腾,直接换Shell?
2026-03-17 · Linux · 约 1 分钟
你可能不知道的Linux死机重启方法
前言 不管在工作或者学习中,都可能遇到电脑死机的情况,如果直接强制关机或者切断电源可能会带来硬件的损坏,严重的可能导致数据丢失。 在学习中使用Linux经常遇到死机的情况,而且无法通过Alt+Ctrl+F[1-7]登陆,也无法通过ssh登陆。 更安全、底层的方法 按下Alt+Ctrl+SysReq(PrintScr键)一秒钟,保持Alt+Ctrl按下状态,松开PrintScr键; 保持按下Alt+
2022-06-17 · Linux · 约 1 分钟
为团队配置Linux环境,简单高效的项目共享方案
配置Linux多用户共享环境?无非是组权限和SGID设置。SSH公钥认证,共享conda环境,复制进度用rsync。这些操作,简单高效,但何必如此折腾?
2024-08-11 · Linux · 约 1 分钟
讨论
共 0 条加载评论中…