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

你可能感兴趣的:(软件安装,nginx,centos,liunx)