linuxnginx的安装
⑴ linux下怎么安装nginx
在linux下安装nginx的时候,一般在./configure的阶段会要求通过prefix设置安装路径。因此,在./configure的时候指定不同的prefix就可以安装多个nginx啦。值得注意的是,安装完之后,两个nginx的监听端口要设置成不同的监听端口。否则,会有一个nginx无法启动。
1
2
./configure --prefix=/home/work/nginx1 .....//第一个nginx的安装配置
make && make install
1
2
./configure --prefix=/home/work/nginx2 .....//第二个nginx的安装配置
make && make install
1
2
cd /home/work/nginx1/conf/nginx.conf && 修改第一个nginx的监听端口.
./home/work/nginx1/sbin/nginx
1
2
cd /home/work/nginx2/conf/nginx.conf && 修改第二个nginx的监听端口.
./home/work/nginx2/sbin/nginx
⑵ 如何在linux下安装nginx
安装nginx前,我们首先要确保系统安装了g++、gcc、openssl-devel、pcre-devel和zlib-devel软件,可通过如图所示命令进行检测,如果以安装我们可以通过图二所示卸载
我们一般安装linux软件都会在/usr/local目录下,然后进行解压编译安装,具体的命令大家请看图片所示
等待配置和编译完成,完成后我们就需要配置防火墙,不拦截80端口,设置完成后需要重启防火墙
接下来介绍下启动/停止/重启的具体方法,进入目录后我们可以用执行sbin/nginx来启动,也可以通过conf/nginx.conf来启动,停止我们可以查询进程使用kill -9 进程号/pkill -9 nginx来结束nginx服务,重启可以通过 sbin/nginx -s reload来重启,具体命令大家请看如图所示
下面来说说基本的操作命令,
nginx -h #帮助
nginx -v #显示版本
nginx -V #显示版本和配置信息
nginx -t #测试配置
nginx -q #测试配置时,只输出错误信息
nginx -s stop #停止服务器
nginx -s reload #重新加载配置
然后请看图片所示conf文件的配置,来配置nginx的方法
6
好了,这个就完成了,大家看看我的效果吧
⑶ linux 怎么安装nginx
nginx windows安装配置方法
安装方法
一、打开nginx windows版 v1.13.3免费版下载好后,把nginx windows版软件解压到c盘根目录。
二、双击nginx.exe图标,可见黑窗口一闪而过,启动完毕。
⑷ 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服务器
希望我的方法能够帮助到你
⑸ linux 怎么安装nginx
linux系统为Centos 64位
第一步:从http://nginx.org/download/上下载相应的版本(或者wget http://nginx.org/download/nginx-1.5.9.tar.gz直接在Linux上用命令下载)
第二步:解压 tar -zxvf nginx-1.5.9.tar.gz
第三步:设置一下配置信息 ./configure --prefix=/usr/local/nginx ,或者不执行此步,直接默认配置
第四步:
make 编译 (make的过程是把各种语言写的源码文件,变成可执行文件和各种库文件)
make install 安装 (make install是把这些编译出来的可执行文件和库文件复制到合适的地方)
⑹ 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
⑺ linux上怎么安装nginx
1.先从nginx官网下载最新的版本
2.解压nginx-1.7.8.tar.gz,然后执行下面操作即可
./configure --prefix=/usr/local/nginx
make
make install
⑻ linux系统怎么安装nginx
ginx官方下载地址: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/source
cd /my_package/source
⑼ linux下怎么安装nginx
从nginx官网上下载源码包
安装pcre
cd /usr/local/src
tar zxvf pcre-8.10.tar.gz
cd pcre-8.10/
./configure
make && make install
编译安装nginx
tar zcvf nginx-1.9.9.tar.gz
cd nginx-1.9.9
./configure --user=www --group=www --add-mole=../ngx_cache_purge-1.0 --prefix=/usr/local/nginx --with-http_stub_status_mole --with-http_ssl_mole
make && make instal
关于更多Linux的学习,请查阅书籍《linux就该这么学》。
⑽ 如何在linux上安装nginx
#forcentos
yuminstall-yepel-release&&yumcleanall&&yummakecache
yuminstall-ynginx
如果编译安装的话需要很多依赖包。YUM安装是最简单的。