学习nginx (一)简单启动nginx(windows 和 linux)

版权声明:转载的话 请标明出处 https://blog.csdn.net/qq_28198181/article/details/87101407

学习的网址:https://www.majiaxueyuan.com/uc/play/40

nginx 下载地址:http://nginx.org/en/download.html

目录

1.下载源代码

2.windows下运行

3.linux下运行

1.下载源代码

地址在上面。可以下载linux 版本 和windows 版本的(我这也上传了:https://download.csdn.net/download/qq_28198181/10954250

下载后放到自己喜欢的盘里,解压,会有两个版本的压缩包

2.windows下运行

在wiondws上运行,解压nginx的zip的压缩包这个是windows上使用的

最好放在没有中文标识的路径下,我这直接放到D盘的根目录

然后点进去,选择

我这里使用的是右键使用管理员权限,然后会提示使用网络

启动后 咱可以在任务管理器中查看

我们访问127.0.0.1

我们可以浏览下 conf目录下的nginx.conf

打开后找到:

这里 listen 80 就是监听的80端口, server_name 就是本地的 

location root html 是访问的 目录下 html目录下 的index.html文件

以上就是windows直接启动nginx后的效果

3.linux下运行

前置条件:

安装gcc环境

Yum -y install gcc-c++

安装PCRE

PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库。命令:

yum install -y pcre pcre-devel

安装zlib

yum install -y zlib zlib-devel

安装openssl

yum install -y openssl openssl-devel

我自己电脑的虚拟机没有联网所以只能离线下载:

离线安装gcc看这里:https://blog.csdn.net/qq_28198181/article/details/82978830 

 

安装nginx

上传nginx-1.6.3.tar.gz包到服务器上

我这传到的是/user/local/src里面

解压

tar -zxvf nginx-1.6.3.tar.gz

进入目录

cd nginx-1.6.3

编译(在这里遇到一个问题,就是configure的时候报错error: the HTTP rewrite module requires the PCRE library或者 zlib的。这命令进行了修改 如下:)

./configure 


#遇到这种类似的:error: the HTTP rewrite module requires the PCRE library
#警告会提示你:You can either disable the module by using --without-http_gzip_module
#option, or install the zlib library into the system, or build the zlib library

./configure --without-http_rewrite_module --without-http_gzip_module

make &&  make install

make &&  make install

安装完后我的是在 /usr/local/nginx/下

进入目录下的sbin

./nginx

启动成功

我用虚拟机进去查看

猜你喜欢

转载自blog.csdn.net/qq_28198181/article/details/87101407