nginx搭建(centos7)

1、安装前准备:

      系统: CentOS 7.5 x64

      下载包:wget 

yum -y install wget

安装:

2、安装一下这些依赖条件:

yum install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel

3、 nginx下载:

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

4、解压tar包

扫描二维码关注公众号,回复: 1277646 查看本文章
tar -zvxf nginx-1.10.3.tar.gz

5、进入到解压后的文件夹中

6、安装配置

./configure --with-http_ssl_module --with-http_gzip_static_module

    这边加了两个选项,--with-http_ssl_module表示使用ssl模块,--with-http_gzip_static_module表示使用gzip模块,其它更详细的配置就要参考nginx的文档      了:http://nginx.org/en/docs/configure.html

7、make && make install

make
make install

  成功后,

  程序位置:/usr/local/nginx/sbin/nginx 

  配置文件位置:/usr/local/nginx/conf/nginx.conf

8、启动nginx

切换到/usr/local/nginx/sbin/目录下,

./nginx -t 判断配置是否正确,若正确,则可启动nginx

注意:如果运行的时候不带-c参数,那就采用默认的配置文件,即/etc/nginx/nginx.conf

查看运行进程状态:

说明已经启动成功

直接在浏览器上输入ip地址即可看到如下信息:

至此,nginx安装成功

附:其他常用nginx命令

停止nginx:
#./nginx -s stop

重启nginx(配置文件变动后需要重启才能生效):
#./nginx -s reload

检查配置文件是否正确:
#./nginx -t

查看nginx的pid:
cat /usr/local/nginx/logs/nginx.pid

查看nginx版本
$ ./nginx -v

回头看编译配置
# ./nginx -V

猜你喜欢

转载自www.cnblogs.com/UniqueColor/p/9118583.html