centos安装nginx

centos安装nginx

本篇内容是来自linux环境下安装nginx步骤 ,修改文章错乱的地方,以及解决按照过程中的一个问题。

环境配置
  • 系统环境配置

    自己做实验,会懒省事把防火墙和seliunx关闭,请自己根据情况使用

  • 依赖环境配置

    #安装编译环境
    [root@localhost ~]# yum -y install gcc gcc-c++ automake autoconf libtool make
    
    #安装PCRE库
    #https://sourceforge.net/projects/pcre/ 下载所需版本的PCRE源码包
    #ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/已经作废
    #路径自己随意就好
    [root@localhost ~]# cd /usr/local/
    [root@localhost local]# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
    [root@localhost local]# tar -zxvf pcre-8.39.tar.gz
    [root@localhost local]# cd pcre-8.39
    [root@localhost pcre-8.39]# ./configure
    [root@localhost pcre-8.39]# make
    [root@localhost pcre-8.39]# make install
    
    #安装zlib库
    #http://zlib.net/zlib-1.2.11.tar.gz 下载其他版本的源码包
    [root@localhost pcre-8.39]# cd /usr/local/
    [root@localhost local]# wget http://zlib.net/zlib-1.2.11.tar.gz
    [root@localhost local]# tar -zxvf zlib-1.2.11.tar.gz
    [root@localhost local]# cd zlib-1.2.11
    [root@localhost zlib-1.2.11]# ./configure
    [root@localhost zlib-1.2.11]# make
    [root@localhost zlib-1.2.11]# make install
    
    #安装openssl
    [root@localhost zlib-1.2.11]# cd /usr/local/
    [root@localhost local]# wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz
    [root@localhost local]# tar -zxvf openssl-1.0.1t.tar.gz
    
    
安装nginx
[root@localhost local]# wget http://nginx.org/download/nginx-1.15.8.tar.gz
[root@localhost local]# tar -zxvf nginx-1.15.8.tar.gz
[root@localhost local]# cd nginx-1.15.8
[root@localhost nginx-1.15.8]# ./configure
[root@localhost nginx-1.15.8]# make
[root@localhost nginx-1.15.8]# make install

#下列步骤为解决启动时报该问题的步骤:/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
可以在nginx安装目录sbin下执行./nginx -t,查看是会出错还是成功

#查看libpcre.so文件位置
[root@localhost nginx-1.15.8]# find / -type f -name *libpcre.so.*
#建立软链接,应该是版本造成的
[root@localhost nginx-1.15.8]# ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1
启动nginx
#修改端口,listen监听的就是端口
[root@localhost nginx-1.15.8]# vi /usr/local/nginx/conf/nginx.conf
    server {
        listen       8089;
        server_name  localhost;

        #charset koi8-r;

#启动代码格式:nginx安装目录地址 -c nginx配置文件地址
[root@localhost nginx-1.15.8]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

#查看nginx
[root@localhost nginx-1.15.8]# ps  -ef | grep nginx
root     12152     1  0 18:29 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody   12153 12152  0 18:29 ?        00:00:00 nginx: worker process                                          
root     12210  2039  0 18:42 pts/0    00:00:00 grep nginx
部署项目
#部署项目
#将项目放置在html文件夹下,我的路径是是/usr/local/nginx/html/
#修改nginx.conf这个配置文件,不会的网上查一下,在这里就不误人子弟了
[root@localhost html]# ls
index.html  service-worker.js  static

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值