Linux下安装nginx,会比window下面稍微复杂一点。
下载安装包文件
访问nginx news,点击下载链接download
选择版本进行下载
linux的选择如下版本
上传服务器
登录到服务器上面,将刚才下载的文件上传上去,用FTP工具或者直接rz命令
解压文件
tar -xzvf nginx-1.18.0.tar.gz
编译
解压出来之后,
先编译一下文件
./configure
执行过程中,有可能会出现依赖性问题
nginx安装报错:./configure: error: the HTTP gzip module requires the zlib 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
statically from the source with nginx by using –with-zlib=<path> option.
可以参考如下链接解决
make一下
make
再make install
make install
执行完成之后,查找安装目录
whereis nginx
启动nginx
上述步骤安装完成之后,启动nginx
./nginx
访问nginx
http://8.141.155.80:80
通过ip:port进行访问,端口默认80,可以在nginx的conf里面查看
注意
服务器要开放端口,如果像阿里云这种,要在安全组进行端口开放设置