导航:首页 > 操作系统 > linuxnginx下载

linuxnginx下载

发布时间:2023-02-07 03:12:37

A. 如何在linux上安装nginx

1 nginx安装环境

nginx是C语言开发,建议在linux上运行,本教程使用Centos6.5作为安装环境。
gcc
安装nginx需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,需要安装gcc:yum install gcc-c++
PCRE
PCRE(PerlCompatible Regular Expressions)是一个Perl库,包括 perl 兼容的正则表达式库。nginx的http模块使用pcre来解析正则表达式,所以需要在linux上安装pcre库。
yuminstall -y pcre pcre-devel
注:pcre-devel是使用pcre开发的一个二次开发库。nginx也需要此库。
zlib
zlib库提供了很多种压缩解压缩的方式,nginx使用zlib对http包的内容进行gzip,所以需要在linux上安装zlib库。
yuminstall -y zlib zlib-devel

openssl
OpenSSL是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。
nginx不仅支持http协议,还支持https(即在ssl协议上传输http),所以需要在linux安装openssl库。
yuminstall -y openssl openssl-devel

2 编译安装
将nginx-1.8.0.tar.gz拷贝至linux服务器。

解压:
tar -zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0

1、 configure
./configure --help查询详细参数(参考本教程附录部分:nginx编译参数)
注意:临时文件目录指定为/var/temp/nginx,需要在/var下创建temp及nginx目录
参数设置如下:
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_mole \
--http-client-body-temp-path=/var/temp/nginx/client\
--http-proxy-temp-path=/var/temp/nginx/proxy\
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi\
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi\
--http-scgi-temp-path=/var/temp/nginx/scgi
2、 编译安装
make
make install
安装成功查看安装目录 :
3 启动nginx
cd /usr/local/nginx/sbin/
./nginx
查询nginx进程:
15098是nginx主进程的进程id,15099是nginx工作进程的进程id
注意:执行./nginx启动nginx,这里可以-c指定加载的nginx配置文件,如下:
./nginx-c /usr/local/nginx/conf/nginx.conf
如果不指定-c,nginx在启动时默认加载conf/nginx.conf文件,此文件的地址也可以在编译安装nginx时指定./configure的参数(--conf-path= 指向配置文件(nginx.conf))
4 停止nginx
方式1,快速停止:
cd /usr/local/nginx/sbin
./nginx -s stop
此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。
方式2,完整停止(建议使用):
cd /usr/local/nginx/sbin
./nginx -s quit
此方式停止步骤是待nginx进程处理任务完毕进行停止。
6 测试
nginx安装成功,启动nginx,即可访问虚拟机上的nginx

B. linux 下nginx模块的安装

安装

第一步 下载并解压Nginx压缩包

从Nginx官网下载Nginx,或者在Linux上执行wget http://nginx.org/download/nginx-1.10.1.tar.gz命令直接下载
解压nginx-1.10.1.tar.gz文件:

tar zxvf nginx-1.10.1.tar.gz
1
1
第二步 配置

cd nginx-1.10.1
./configure --prefix=/usr/local/nginx
1
2
1
2
注意:
① 如果之前没有安装C compiler(C 编译器),这一步将报如下错误信息:

xueliang@dev:~/download/nginx-1.10.1$ ./configure –prefix=/usr/local/nginx
checking for OS
+ Linux 4.2.0-27-generic x86_64
checking for C compiler … not found

./configure: error: C compiler cc is not found

xueliang@dev:~/download/nginx-1.10.1$
可以参考这篇文章安装C compiler,然后继续下面的操作

② 如果之前没有安装PCRE,这一步将报如下错误信息:

checking for PCRE library … not found
checking for PCRE library in /usr/local/ … not found
checking for PCRE library in /usr/include/pcre/ … not found
checking for PCRE library in /usr/pkg/ … not found
checking for PCRE library in /opt/local/ … not found

./configure: error: the HTTP rewrite mole requires the PCRE library.
You can either disable the mole by using –without-http_rewrite_mole
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using –with-pcre= option.

xueliang@dev:~/download/nginx-1.10.1$

③ 如果之前没有安装zlib,这一步将报如下错误信息:

checking for md5 in system md library … not found
checking for md5 in system md5 library … not found
checking for md5 in system OpenSSL crypto library … not found
checking for sha1 in system md library … not found
checking for sha1 in system OpenSSL crypto library … not found
checking for zlib library … not found

./configure: error: the HTTP gzip mole requires the zlib library.
You can either disable the mole by using –without-http_gzip_mole
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using –with-zlib= option.

xueliang@dev:~/download/nginx-1.10.1$

也可以跳过此步,执行默认安装,--prefix的默认值为/usr/local/nginx,Nginx官网对此有说明:Building nginx from Sources

C. linux系统怎么安装nginx

这里以CentOS6.6系统(32位)中安装nginx的源码包,进行讲解。
1. nginx源码包的下载
nginx官方下载地址:http://nginx.org/
选择你要安装的nginx版本,这里,我选择的是 nginx-1.10.2 。
具体的下载链接为:http://nginx.org/download/nginx-1.10.2.tar.gz
可以在其他电脑下载好,通过ftp软件传给要安装的linux电脑。也可以直接在linux电脑上使用wget命令下载。这里我们使用后一种方式。
在linux的根目录,创建一个多级空目录 /my_package/source,用来存放下载的源码包。
mkdir -p /my_package/sourcecd /my_package/source12

执行下载命令:
wget http://nginx.org/download/nginx-1.10.2.tar.gz1

下载完成后,在 /my_package/source 目录中,就有了 nginx-1.10.2.tar.gz 源码包压缩文件。
2. nginx的安装与配置
2.1 准备工作
安装nginx之前,需要先安装pcre库。如果你的linux系统中没有pcre,需要先进行安装。
这里,我们使用yum工具,在线快速安装pcre:
yum -y install pcre
yum -y install pcre-devel12

可以通过下面的命令,找到已安装的pcre和pcre-devel的位置:
rpm -ql pcre
rpm -ql pcre-devel或
find / -name "*pcre*"1234

2.2 nginx的安装
配置nginx安装的参数,比如:安装路径,指定依赖库的具体位置等。
这里我们使用默认安装配置:
tar -zxvf nginx-1.10.2.tar.gzcd nginx-1.10.2./configure123

如果这一步执行正确,在提示信息中会告知nginx将要安装的位置、可执行文件的位置等,如下:
nginx path prefix: "/usr/local/nginx"nginx binary file: "/usr/local/nginx/sbin/nginx"nginx moles path: "/usr/local/nginx/moles"nginx configuration prefix: "/usr/local/nginx/conf"nginx configuration file: "/usr/local/nginx/conf/nginx.conf"nginx pid file: "/usr/local/nginx/logs/nginx.pid"nginx error log file: "/usr/local/nginx/logs/error.log"nginx http access log file: "/usr/local/nginx/logs/access.log"nginx http client request body temporary files: "client_body_temp"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"12345678910111213

如果这一步出错了,根据错误提示信息解决问题后,使用 make clean 命令,清除产生的临时文件,再来重新执行 ./configure
如果想查看具体可以配置哪些安装参数,可以使用下面的命令查看:
./configure --help1

编译和安装
makemake install12

到此,nginx的源码包就安装完毕了。
2.3 nginx的配置
如果想修改nginx的配置文件,可使用下面的命令:
vi /usr/local/nginx/conf/nginx.conf1

3. nginx的常用命令
检查测试nginx的配置信息是否正确
/usr/local/nginx/sbin/nginx -t1

启动nginx
/usr/local/nginx/sbin/nginx1

启动nginx服务器后,可以使用下面的命令检测nginx是否启动成功,并查看nginx的端口、主进程号、进程名称等信息。
netstat -tlunp1

也可以使用下面的命令检测nginx是否启动成功,并查看nginx的主进程和子进程的详细信息。
ps aux | grep nginx1

ps aux 命令(a代表前台进程,x代表后台进程,u代表进程的发起者)列出的进程信息中,主要包含以下信息:USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND 。这里,简单说明一下:
USER:表示进程的发起者,也就是说,进程是哪个用户产生的。
PID:表示进程的id,也称作,进程号。%CPU:表示进程占用的CPU资源的百分比。%MEM:表示进程占用的物理内存的百分比。
VSZ:表示进程占用的虚拟内存的大小,单位KB。
RSS:表示进程占用的实际物理内存的大小,单位KB。
TTY:表示进程是在哪个终端中运行的。其中tty1到tty7代表本地控制台终端,tty1到tty6是本地的字符界面终端,tty7是图形终端。pts/0-255代表虚拟终端(即远程登录终端)。
STAT:表示进程的状态。常见的状态有:R 运行;S 睡眠;T 停止;s 包含子进程;+ 位于后台。
START:表示进程是在什么时间启动的。
TIME:表示进程占用CPU的运算时间,值越大,越耗费资源。
COMMAND:表示产生该进程的命令(通过它可以识别正在运行的进程名)。1234567891011

成功启动nginx后,就可以在本地电脑或其他电脑中访问你的nginx服务器中的网站了。
本地电脑(即nginx所在的电脑)的访问方式:curl 127.0.0.1
其他电脑(局域网内)的访问方式:打开浏览器,输入nginx服务器的局域网IP即可。12

为了更方便的使用 /usr/local/nginx/sbin 中的命令,
我们将其加入linux系统的环境变量,即修改文件 /etc/profile,在最后加入下面的代码:
export PATH="/usr/local/nginx/sbin:$PATH"1

保存退出后,执行命令:source /etc/profile 可使该配置文件立即生效。
关闭nginx
nginx -s stop 快速关闭nginx
nginx -s quit 平滑关闭nginx
kill -s QUIT 11247 通过linux的kill命令杀死nginx进程,11247为nginx的主进程号123

重新加载nginx的配置文件
nginx -s reload 修改了nginx的配置文件后,可以使用该命令让新的配置立即生效,而不用重启整个nginx服务器

希望我的方法能够帮助到你

D. linux服务器上下载某个文件怎么配置nginx

使用护卫神主机大师,一键安装配置nginx,再开设网站,上传文件到网站就可以提供下载了

E. red hat enterprise linux6 怎样安装nginx

一、安装前的准备nginx安装环境

yum -y install gcc gcc-c++ autoconf automake make
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
二、安装nginx
下载nginx源码包,下载地址为:http://nginx.org/download/,在这个地址下选一个你想安装版本。

创建一个目录用来放置你下载的源码
mkdir my_nginx
cd my_nginx
wget http://nginx.org/download/nginx-1.9.0.tar.gz
tar -zxvf nginx-1.9.0.tar.gz
cd nginx-1.9.0
现在就可以进行安装了,传统的安装步骤。
./configure
make
make install
这样就可以安装好了。
注意:nginx的默认安装路径是 /usr/local/nginx 其运行文件在其/usr/local/nginx/sbin目录下面(稍后介绍添加环境变量,任何路径就可以执行nginx)。
启动nginx:
进入/usr/local/nginx/sbin 下执行就可以了
./nginx
这个时候你就启动nginx了
在浏览器中输入127.0.0.1会弹出下面的页面表示你nginx安装成功了。

F. linux上怎么安装nginx

查看是否已经安装了REPC
rpm -qa | grep “REPC”
好的 这里看到已经安装了。
同理 查看openssl gzip wget

如果没有安装则使用yum命令安装下,需要在root权限下操作
分别是
yum install pcre*
yum install openssl*
yum install zlib
yum install zlib-devel
yum install wget
这里看到 这四个东西 都安装好了

下面开始安装nginx
先获取包wget http://nginx.org/download/nginx-1.8.0.tar.gz

后面的版本号可以更改的,可以先用浏览器登陆http://nginx.org/download/ 然后看下你要的是什么版本,目前高到底有测试版 稳定版 旧版 三种

PS:你当前位置在哪,下载的文件就在哪

下载好了以后,自己找个位置复制过去,然后解压。我这里是放在了/usr/local
cp nginx-1.8.0.tar.gz /usr/local
cd /usr/local
tar -zxvf nginx-1.8.0.tar.gz

解压完毕,进去,安装。
cd nginx-1.8.0
./configure --prefix=/usr/local/nginx-1.8.0 \--with-http_ssl_mole --with-http_spdy_mole \--with-http_stub_status_mole --with-pcre

执行这个命令
make && make install

之后进入安装目录
然后 启动 ./sbin/nginx

ps -ef|grep "nginx"
查看服务是否启动 有两个服务

7
至此 安装完毕了。
修改conf/nginx.conf 来完成配置 之后 重启nginx 服务
./sbin/nginx -s reload

阅读全文

与linuxnginx下载相关的资料

热点内容
缉魂130分钟台湾完整版 浏览:688
wifi电视一般需要什么app 浏览:526
怎样保护自己的id密码加密 浏览:244
韩剧女主手上带个铃铛 浏览:374
南充云服务器 浏览:984
哪个网站下载源码不要钱 浏览:739
筹码源码指标公式股旁网 浏览:403
农商银行的app是什么名字 浏览:248
德国服务器适合做什么 浏览:139
java权限系统源码 浏览:164
androidmk编译aidl 浏览:881
单片机取8位 浏览:995
如何在云服务器上安装2s 浏览:8
怎么把王者安卓号转移到苹果 浏览:780
思科密码加密后怎么登录 浏览:592
安卓手机生态垃圾怎么办 浏览:114
fy187 浏览:597
python中文文字识别 浏览:882
日本蕾丝边电影 浏览:796
斯坦福编译原理讲义 浏览:147