Lnmp架构部署动态网站环境.2019-7-3-1.2

Nginx安装

一、安装准备

  Pcre(Perl Compatible Regular Expressions,兼容正则表达式)安装pcre库是为了使Nginx支持HTTP Rewrite模块。

安装方法:

1、yum安装

[root@Lnmp tools]# yum install pcre pcre-devel -y

2、编译安装

wget http://sourceforge.net/projects/pcre/files/pcre/8.30/pcre-8.30.tar.gz

tar zxf pcre-8.30.tar.gz

cd pcre-8.30/

./configure

make && make install

cd ../

  安装Openssl

yum install openssl openssl-devel -y

二、安装Nginx

[root@Lnmp tools]# tar xf nginx-1.6.2.tar.gz  #解压nginx包

[root@Lnmp tools]# useradd nginx -s /sbin/nologin -M   #创建用户

[root@Lnmp tools]# cd nginx-1.6.2

[root@Lnmp nginx-1.6.2]# ./configure --user=nginx --group=nginx --prefix=/application/nginx1.6.2 --with-http_stub_status_module --with-http_ssl_module  #编译安装

./configure: error: C compiler cc is not found  #如果出现此报错

[root@Lnmp nginx-1.6.2]# yum -y install gcc gcc-c++ autoconf automake make  #执行此命令

[root@Lnmp nginx-1.6.2]# make

[root@Lnmp nginx-1.6.2]# make install  #如果不清楚是否安装成功在每次命令之后执行echo $? 0就是没有问题

[root@Lnmp nginx-1.6.2]# cd ../

[root@Lnmp tools]# ln -s /application/nginx1.6.2/ /application/nginx  #做软连接

[root@Lnmp tools]# /application/nginx/sbin/nginx -t  #检查语法

[root@Lnmp tools]# /application/nginx/sbin/nginx  #启动nginx

此时在浏览器输入主机IP地址出现welcome to nginx表示安装成功

原文地址:https://www.cnblogs.com/DevonL/p/11125130.html