设为首页收藏本站language 语言切换
查看: 1164|回复: 0
收起左侧

Nginx的网站服务(手工编译安装过程细解)

[复制链接]
发表于 2022-7-25 10:52:42 | 显示全部楼层 |阅读模式
Nginx网站服务Nginx的概念? ??Nginx (engine x)是一个高性能的HTTP和反向代理web服务器 ,同时也提供了IMAP/POP3/SMTP服务。Nginx是由伊戈尔赛索耶夫为俄罗斯访问量第二的Ramblerru站点(俄文: Pamonep) 开发的,第-一个公开版本0. 1.0发布于2004年10月4日。
? ??其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。2011年6月1日,nginx 1.0.4发布。
? ??Nginx是一款轻量级的Web服务器反向代理服务器及电子邮件(IMAP/POP3) 代理服务器,在BSD-like协议下发行。其特点是占有内存少,并发能力强,事实上nginx的并发能力在同类型的网页服务器中表现较好,中国大陆使用nginx网站用户有:百度、京东、新浪、网易、腾讯、淘宝等。
Nginx手工编译安装安装环境:Centos7、nginx-1.12.0.tar.gz

Nginx手工编译安装流程步骤细解如下:
#Nginx设置nginx-1.12.0.tar.gz 1.解压缩软件包tar zxf nginx-1.12.0 tar.gz -C /opt/2.安装所需编译安装环境包yum install gcc gcc-c++ pcre pcre-devel zlib-devel -y3.创建家目录但不创建家目录useradd -M -s /sbin/nologin nginx4.配置相关参数cd /opt/nginx-1.12.0./configure \--prefix=/usr/local/nginx \--user=nginx \--group=nginx \--with-http_stub_status_module (统计模块)5.编译安装make &&make install6.测试 #cd /usr/local/nginx #ls#conf html logs sbin ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/#nginx -t nginx netstat -natp | grep 80systemctl stop firewalld.service setenforce 0#yum install -y elinks (测试网页工具)#elinks http://localhost 7.#基本管理killall -3 (-s QUIT) nginx netstat -antp | grep 80killall -1 (-s HUP) nginx8.制作管理脚本Nginx手工编译安装实例[root@localhost ~]# yum install gcc gcc-c++ pcre pcre-devel zlib-devel -y[root@localhost ~]# cd LNMP-C7/[root@localhost LNMP-C7]# lsDiscuz_X3.4_SC_UTF8.zip ???php-7.1.10.tar.bz2mysql-boost-5.7.20.tar.gz ?php-7.1.20.tar.bz2ncurses-5.6.tar.gz ????????php-7.1.20.tar.gznginx-1.12.2.tar.gz ???????zend-loader-php5.6-linux-x86_64_update1.tar.gzphp-5.6.11.tar.bz2[root@localhost LNMP-C7]# tar zxf nginx-1.12.2.tar.gz -C /opt/[root@localhost nginx-1.12.2]# useradd -M -s /sbin/nologin nginx[root@localhost LNMP-C7]# cd /opt/[root@localhost opt]# cd nginx-1.12.2/[root@localhost nginx-1.12.2]# ./configure \> --prefix=/usr/local/nginx \> --user=nginx \> --group=nginx \> --with-http_stub_status_module.....//省略部分内容 ?nginx http proxy temporary files: "proxy_temp" ?nginx http fastcgi temporary files: "fastcgi_temp" ?nginx http uwsgi temporary files: "uwsgi_temp" ?nginx http scgi temporary files: "scgi_temp"[root@localhost nginx-1.12.2]# make && make install...//省略部分内容test -d '/usr/local/nginx/logs' \ ???????|| mkdir -p '/usr/local/nginx/logs'make[1]: Leaving directory `/opt/nginx-1.12.2'[root@localhost nginx-1.12.2]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/[root@localhost nginx-1.12.2]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/[root@localhost nginx-1.12.2]# nginx -tnginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful[root@localhost nginx-1.12.2]# nginx[root@localhost nginx-1.12.2]# netstat -natp | grep nginxtcp ???????0 ?????0 0.0.0.0:80 ?????????????0.0.0.0:* ??????????????LISTEN ?????66585/nginx: master [root@localhost nginx-1.12.2]# systemctl stop firewalld.service [root@localhost nginx-1.12.2]# setenforce 0[root@localhost nginx-1.12.2]# yum install -y elinks[root@localhost nginx-1.12.2]# elinks http://localhost//这里执行命令后显示对话框,ok回车,输入q选择yes回车则退出到原本界面以上就是对Nginx的手工编译安装的过程,下面我们介绍一下对Nginx的基本管理命令
Nginx的基本管理[root@localhost nginx-1.12.2]# killall -3 nginx ???//关闭Nginx服务[root@localhost nginx-1.12.2]# netstat -natp | grep nginx[root@localhost nginx-1.12.2]# nginx ??????????????//启动Nginx服务[root@localhost nginx-1.12.2]# killall -1 nginx ???//重启Nginx服务[root@localhost nginx-1.12.2]# netstat -natp | grep nginxtcp ???????0 ?????0 0.0.0.0:80 ?????????????0.0.0.0:* ??????????????LISTEN ?????76326/nginx: master //也可以使用以下命令进行关闭和重启killall -s QUIT nginx killall -s HUP nginx[root@localhost nginx-1.12.2]# killall -s QUIT nginx[root@localhost nginx-1.12.2]# netstat -natp | grep nginx[root@localhost nginx-1.12.2]# nginx [root@localhost nginx-1.12.2]# killall -s HUP nginx[root@localhost nginx-1.12.2]# netstat -natp | grep nginxtcp ???????0 ?????0 0.0.0.0:80 ?????????????0.0.0.0:* ??????????????LISTEN ?????79214/nginx: master 以上基本管理比较不方便,我们可以自己制作一个管理脚本,脚本如下
vim /etc/init.d/nginx#!/bin/bash# chkconfig: - 99 20# description: Nginx Service Control ScriptPROG="/usr/local/nginx/sbin/nginx"PIDF="/usr/local/nginx/logs/nginx.pid"case "$1" in ????start) ???????$PROG ???????;; ???stop) ???????kill -s QUIT $(cat $PIDF) ???????;; ???restart) ???????$0 stop ????????$0 start ???????;; ???reload) ???????kill -s HUP $(cat $PIDF) ???????;; ???*) ???????echo "Usage: $0 {start|stop|restart|reload}" ???????exit 1esacexit 0[root@localhost init.d]# chmod +x nginx [root@localhost init.d]# chkconfig -add nginx [root@localhost init.d]# service nginx restart 小结本文主要讲解有关Nginx的相关基础点,我们所要知道的就是其自身的特点以及其与Apache的区别。
特点:稳定性、轻量级、高并发、低资源
优势:擅长处理静态网站(图片文字视频等文件)访问资源;
Apache擅长动态(例如:账号注册时所需要的交互)
下一篇文章我们将介绍如何在手工编译安装好Nginx服务的基础上进行Nginx虚拟主机的搭建,谢谢阅读!

了解更多相关内容欢迎关注http://www.kd010.com/
您需要登录后才可以回帖 登录 | 论坛注册

本版积分规则

QQ|Archiver|手机版|小黑屋|sitemap|鸿鹄论坛 ( 京ICP备14027439号 )  

GMT+8, 2025-2-2 22:38 , Processed in 0.067680 second(s), 12 queries , Redis On.  

  Powered by Discuz!

  © 2001-2025 HH010.COM

快速回复 返回顶部 返回列表