nginx for linux安装及安装错误解决

nginx:下载地址:http://www.nginx.org/

1.GCC编译器

安装指令 :yum  install -y  gcc

如果你所使用的是ubuntu,则安装指令为:apt-get install -y  gcc        因为ubuntu可不用yum,下同哦..............

如果涉及到C++来编写Nginx HTTP模块,则还需要安装G++编译器

安装指令:yum install -y gcc-c++

2. PCRE库

首先我们需要下载PCRE,这个步骤简单,我们可以自行完成。例如这里我们下载的安装包为pcre-8.34.tar.gz,我们需要用到移动到指定的文件夹下面,然后解压安装。

移动指令:mv “指定文件目录”  “目标文件目录”。假设我们需要将源码移动到/home目录下 mv  /home  "源码所在目录/pcre-8.34.tar.gz"

解压指令:tar zxvf pcre-8.34.tar.gz   然后执行如下指令。

cd /home/pcre-8.34

./configure  此过程中会生成一大堆文件,不用去管它。

make

make install

3.OpenSSL开发库

yum  install -y openssl openssl-devel

如果是ubuntu系统,安装指令:# sudo apt-get install openssl # sudo apt-get install libssl-dev

OK,准备工作已经做完,我们来安装Nginx。首先得下载源码,然后将其移动到目标文件夹,当然也可以就地解压。这里我们以nginx-1.6.0.tar.gz,移动到/home目录下来进行实例说明。cd到/home目录,解压。

# tar zxvf nginx-1.6.0.tar.gz

# cd nginx-1.6.0

      ./configure --prefix=/usr/local/nginx --with-http_stub_status_module

make

make install

如果在make的时候出现make: *** 没有规则可以创建“default”需要的目标“build”这种提示,请回到OpenSSL开发库的安装上去,一般是这一步出了问题。而且你肯定没有注意./configure时候的错误提示:

./configure: error: the HTTP cache module requires md5 functionsfrom OpenSSL library.  You can either disable the module by using--without-http-cache option, or install the OpenSSL library into the system,or build the OpenSSL library statically from the source with nginx by using--with-http_ssl_module --with-openssl= options.

如果一切都没有问题,我们来检查下安装是否成功。

cd  /usr/local/nginx/sbin

./nginx -t

结果显示:

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

则表示安装正确,现在我们来启动Nginx:

cd  /usr/local/nginx/sbin

./nginx 启动 nginx

这个时候打开浏览器,输入自己电脑的ip。对于不知道自己电脑ip的童靴,可以使用ifconfig指令进行查看。

这里我在浏览器中输入:http://127.0.0.1 出现如下信息:

看到上面nginx 欢迎界面说明启动成功

停止nginx: pkill -9 nginx

参考:http://www.th7.cn/system/lin/201406/61021.shtml

出现问题:Nginx: error while loading shared libraries: libpcre.so.1

Shell代码

[[email protected] conf]# /usr/local/nginx/sbin/nginx

/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

确认已经安装PCRE:

Shell代码

[[email protected] lib]$ cd /lib

[[email protected] lib]$ ls *pcre*

libpcre.so.0  libpcre.so.0.0.1

[[email protected] nginx]$ find / -type f -name *libpcre.so.*

添加软链接:

Shell代码

[[email protected] lib]$ ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1

前面在一般的linux上可以解决此问题.

注: 在有的操作系统上面,安装pcre后,安装的位置为/usr/local/lib/*pcre*

在redhat 64位机器之上有这样的情况.

在redhat 64位机器上, nginx可能读取的pcre文件为/lib64/libpcre.so.1文件.

所以在改用下面的软连接:

Shell代码

[[email protected] ~]$ ln -s /usr/local/lib/libpcre.so.1 /lib64/

新手初学呀!多方借鉴!

时间: 2024-07-30 19:47:53

nginx for linux安装及安装错误解决的相关文章

linux编译安装时常见错误解决办法

linux编译安装时常见错误解决办法 This article is post on https://coderwall.com/p/ggmpfa 原文链接:http://www.bkjia.com/PHPjc/1008013.html configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution复制代码 代码如下:yum -y install libxslt-devel c

PHP编译安装时常见错误解决办法,php编译常见错误

PHP编译安装时常见错误解决办法,php编译常见错误 1.configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution 解决方法: yum -y install libxslt-devel 2.configure: error: Could not find net-snmp-config binary. Please check your net-snmp installa

make安装redis遇到错误解决方法

zmalloc.o: In function `zmalloc_used_memory': /home/cqh/tar/redis-2.6.14/src/zmalloc.c:223: undefined reference to `__sync_add_and_fetch_4' collect2: ld 返回 1 make[1]: *** [redis-server] 错误 1 make[1]: Leaving directory `/home/cqh/tar/redis-2.6.14/src'

AppStore安装APP发生错误解决方法

打开网络偏好设置 高级  -> DNS ->  +  ->  114.114.114.114 AppStore安装APP发生错误解决方法

Kali linux virtualbox rc=1908 错误解决办法

Kali linux virtualbox rc=1908 错误解决办法: 当我尝试启动virtualbox时候提示: Kernel driver not installed (rc=-1908)The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Please reinstall the kernel module

ubuntu14.04安装oracle12c及错误解决方法

1.更换apt源 cp /etc/apt/sources.list /etc/apt/sources.list.bak vim /etc/apt/sources.list cat  /etc/apt/sources.list deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ trusty-security main res

Nginx在Linux下的安装部署

一.Nginx简介 Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 服务器.Nginx作为负载均衡服务器:Nginx 既可以在内部直接支持 Rails 和 PHP 程序对外进行服务,也可以支持作为 HTTP代理服务器对外进行服务.nginx网站国内的用户有:百度.新浪.网易.腾讯等等. 二.Nginx的安装 下载Nginx(http://nginx.org/en/download.html),最新的好像是ng

Oracle 11g安装过程中错误解决

报错:warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 1e5e0159解决:rpm --import /etc/pki/rpm-gpg/RPM* 报错:ORA-12705: Cannot access NLS data files or invalid environment specified解决:Linux下 如果环境变量 NLS_LANG 值是NA 会引起 ORA-12705 错误,解决方法是修改set

CentOS6.5上给curl安装ssl时错误解决

1 在CentOS上使用PHP的curl访问HTTPS页面时,出现错误“Protocol https not supported or disabled in libcurl”. 表示curl未启用https,需要重新编译php所使用的curl库. cd curl-7.31.0./configure --prefix=/home/www/thirdlib/curl --with-ssl=/ueidc/openssl 出现错误提示: checking for SSL_connect in -lss

安装Centos 7 错误解决

dracut-initqueue[624]:Warning: Could not boot. dracut-initqueue[624]:Warning: /dev/root does not exist. Starting Dracut EmergencyShell… Warning: /dev/root does not exist 原因是:UltroISO在Window下写入U盘的安装文件路径,没有被linux安装程序识别 解决方法如下: dracut:/# cd /dev dracut: