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 许可协议。转载请注明出处!
相关文章
你可能不知道的Linux死机重启方法
前言 不管在工作或者学习中,都可能遇到电脑死机的情况,如果直接强制关机或者切断电源可能会带来硬件的损坏,严重的可能导致数据丢失。 在学习中使用Linux经常遇到死机的情况,而且无法通过Alt+Ctrl+F[1-7]登陆,也无法通过ssh登陆。 更安全、底层的方法 按下Alt+Ctrl+SysReq(PrintScr键)一秒钟,保持Alt+Ctrl按下状态,松开PrintScr键; 保持按下Alt+
2022-06-17 · Linux · 约 1 分钟
部署个SSH蜜罐玩玩,既能增强安全性,又能当电子蛐蛐
部署SSH蜜罐?改个端口,装fakessh白嫖密码字典,sshesame当电子蛐蛐记录操作。typora插件更新麻烦,安全测试才是真本事。
2024-11-04 · Linux · 约 1 分钟
SSH 跳板机原理与配置:实现无缝跳板连接,一步直达目标主机
在日常运维或开发工作中,我们常常需要访问部署在内网的服务器。然而出于安全策略或网络拓扑的限制,内网服务器并不会直接向外部暴露端口,导致我们无法“直连”它们。此时,**跳板机**(Jump Host/Bastion Host)就成了必不可少的中转
2025-01-17 · Linux · 约 1 分钟
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 分钟
讨论
共 0 条加载评论中…