nginx安装部署及路径

Tomcat 安装:在cathout.sh 里配置好jdk路径 然后chmod 777 startup.sh shutdown.sh cathout.sh 最后 ./startup.sh

简介:Nginx是一个web服务器也可以用来做负载均衡及反向代理使用,目前使用最多的就是负载均衡

一、浏览器访问路径:http://192.168.12.11/、http://192.168.12.10/ 12.11安装路径:/usr/local/nginx 12.10安装路径:/usr/local/nginx 二、常用命令:

启动:/usr/local/nginx/sbin/nginx

停止/重新加载:/usr/local/nginx/sbin/nginx -s stop(quit、reload) 验证配置文件是否合法:/usr/local/nginx/sbin/nginx -t 命令帮助:/usr/local/nginx/sbin/nginx -h 三、安装步骤:

(1) 下载Nginx及相关组件 [root@localhost src]

# wget http://nginx.org/download/nginx-1.10.2.tar.gz 省略安装内容...

[root@localhost src]

# wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz 省略安装内容...

[root@localhost src]# wget http://zlib.net/zlib-1.2.11.tar.gz 省略安装内容...

[root@localhost src] # wget

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz

省略安装内容...

(2)安装c++编译环境,如已安装可略过

[root@localhost src]# yum install gcc-c++ 省略安装内容...期间会有确认提示输入y回车 Is this ok [y/N]:y 省略安装内容...

(3)安装Nginx及相关组件:依赖包安装顺序依次为:openssl、zlib、pcre, 然后安装Nginx包 openssl安装:

[root@localhost src]# tar zxvf openssl-fips-2.0.10.tar.gz 省略安装内容...

[root@localhost src]# cd openssl-fips-2.0.10

[root@localhost openssl-fips-2.0.10]# ./config && make && make install 省略安装内容...

zlib安装:

[root@localhost src]# tar zxvf zlib-1.2.11.tar.gz 省略安装内容...

[root@localhost src]# cd zlib-1.2.11

[root@localhost zlib-1.2.11]# ./configure && make && make install 省略安装内容... pcre安装:

[root@localhost src]# tar zxvf pcre-8.40.tar.gz 省略安装内容...

[root@localhost src]# cd pcre-8.40

[root@localhost pcre-8.40]# ./configure && make && make install 省略安装内容... nginx安装:

[root@localhost src]# tar zxvf nginx-1.10.2.tar.gz 省略安装内容...

[root@localhost src]# cd nginx-1.10.2

[root@localhost nginx-1.10.2]# ./configure && make && make install 省略安装内容...

安装完成后,可启动nginx;

通过访问localhost看到这个就安装完毕了

Ps:

问题:若进入nginx目录并启动

报错了,error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory,按照下面方式解决:

1.用whereis libpcre.so.1命令找到libpcre.so.1在哪里

2.用ln -s /usr/local/lib/libpcre.so.1 /lib64命令做个软连接就可以了 3.用sbin/nginx启动Nginx

4.用ps -aux | grep nginx查看状态

[root@localhost nginx]# whereis libpcre.so.1

[root@localhost nginx]# ln -s /usr/local/lib/libpcre.so.1 /lib64 [root@localhost nginx]# sbin/nginx

[root@localhost nginx]# ps -aux | grep nginx

后续配置:

1、简单配置Nginx

打开nginx配置文件位于nginx目录下的conf文件夹下

简单介绍一下vim的语法

默认vim打开后是不能录入的,需要按键才能操作,具体如下: 开启编辑:按“i”或者“Insert”键 退出编辑:“Esc”键 退出vim:“:q” 保存vim:“:w”

保存退出vim:“:wq” 不保存退出vim:“:q!”

\代表注释,最重要的是server{}块这部分就代表每一个web站点,详细的配置介绍可以查阅我的另一片配置文章,此处我们先暂时设置三个站点

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4