CentOS7安装部署Nginx(1.8.1)


参考文档: https://blog.csdn.net/qq_39387856/article/details/88951699

系统环境

[root@nginx ~]# cat /etc/redhat-release
CentOS Linux release 7.0.1406 (Core)

1 安装make及编译环境

[root@nginx ~]# yum -y install gcc gcc-c++ automake autoconf libtool make

2 安装OpenSSL

[root@nginx ~]# cd /usr/local/src/
[root@nginx src]# wget https://www.openssl.org/source/openssl-1.1.1b.tar.gz	# 下载包
[root@nginx src]# tar -zxvf openssl-1.1.1b.tar.gz	# 解压包
[root@nginx openssl-1.1.1b]# ./Configure && make && make install	#编译

3 安装PCRE库

[root@nginx src]# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
[root@nginx src]# cd pcre-8.40/
[root@nginx pcre-8.40]# ./configure && make && make install

4 安装zlib库

[root@nginx src]# wget http://zlib.net/zlib-1.2.11.tar.gz
[root@nginx src]# cd zlib-1.2.11/
[root@nginx zlib-1.2.11]# ./configure && make && make install


5 安装Nginx

官网下载,上传并解压安装包

[root@nginx src]# cd nginx-1.8.1/
[root@nginx nginx-1.8.1]# ./configure && make && make install

6 修改监听端口

默认80端口,可能会与apache冲突

[root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
server {
        listen      8899;
        server_name  localhost;

7 启动Nginx

7.1 查看Nginx安装路径

[root@nginx nginx-1.8.1]# whereis nginx
nginx: /usr/local/nginx

7.2 启动服务

[root@nginx ~]# cd /usr/local/nginx/sbin/
[root@nginx sbin]# ls
nginx  nginx.old
[root@nginx sbin]# ./nginx

7.3 查看端口是否启用

[root@nginx sbin]# ps -ef | grep nginx
avahi       915      1  0 11:53 ?        00:00:00 avahi-daemon: running [nginx.local]
root      15032      1  0 13:10 ?        00:00:00 nginx: master process ./nginx
nobody    15033  15032  0 13:10 ?        00:00:00 nginx: worker process
root      15043   2878  0 13:10 pts/0    00:00:00 grep --color=auto nginx


[root@nginx sbin]# netstat -alntup | grep nginx
tcp        0      0 0.0.0.0:8899            0.0.0.0:*               LISTEN      15032/nginx: master

8 防火墙放行端口

[root@nginx ~]# firewall-cmd --zone=public --add-port=8899/tcp --permanent
success
[root@nginx ~]# firewall-cmd --reload
success

9 测试

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值