首页 技术 正文
技术 2022年11月8日
0 收藏 905 点赞 2,096 浏览 1213 个字

记录一下linux下安装nginx的所需要的配置。

首先从 nginx官网 下载所需要的版本,复制链接,执行

wget http://nginx.org/download/nginx-1.8.0.tar.gz

 在你的linux目录下会有nginx-1.8.0.tar.gz压缩包,解压到当前目录。

tar -zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0/
./configure

  这个时候一般会出现错误,我们需要安装nginx所依赖的包

sudo apt-get install gcc   g++    make   automake   python perl

  一般这个时候只是./configure的时候还会出现错误

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

这个时候我们需要安装PCRE所需要的包。

sudo apt-get update
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install openssl libssl-dev

  现在执行./configure就成功了。

  最后,我们进行编译和安装。

sudo makesudo make install

  ok,安装结束。

  安装完成以后,你可以输入命令启动服务器。

sudo /usr/local/nginx/sbin/nginx

  这样,你就可以在网页输入localhost访问到web服务器。

  你可以更改 /usr/local/nginx/html/index.html中的内容。如果想要关闭nginx.直接输入命令

pkill nginx

  为了方便管理,我们可以写成shell脚本loadNginx.sh(自己取的文件名)来开关nginx。

#!/bin/bash
if [ "$1" == "start" ];then
sudo /usr/local/nginx/sbin/nginx
echo "start..."
elif [ "$1" == "stop" ];then
sudo pkill nginx
echo "stop..."
fi

  通过 bash loadNginx.sh start来开启nginx,bash loadNginx.sh stop 关闭。

  也可以修改nginx的端口。

vim /usr/local/nginx/conf/nginx.conf

  找到80端口,修改成8080(这是我自己选取的)。

  

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,085
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,560
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,409
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,182
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,819
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,902