欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

荐 nginx安装,make install报错: cannot create regular file启动报错find: “/lost+found”: 权限不够/opt/module/p

程序员文章站 2022-06-23 19:36:45
1.使用jar包pcre-8.37.tar.gz | openssl-1.0.1t.tar.gz | zlib-1.2.8.tar.gz | nginx-1.11.1.tar.gz下载地址: http://nginx.org/download/nginx-1.4.2.tar.gz2.解压[cevent@hadoop213 ~]$ cd /opt/soft/[cevent@hadoop213 soft]$ ll总用量 18916-rw-rw-r--. 1 cevent cevent 892...

1.使用jar包

pcre-8.37.tar.gz | openssl-1.0.1t.tar.gz | zlib-1.2.8.tar.gz | nginx-1.11.1.tar.gz
下载地址: http://nginx.org/download/nginx-1.4.2.tar.gz
荐
                                                        nginx安装,make install报错: cannot create regular file启动报错find: “/lost+found”: 权限不够/opt/module/p
荐
                                                        nginx安装,make install报错: cannot create regular file启动报错find: “/lost+found”: 权限不够/opt/module/p
荐
                                                        nginx安装,make install报错: cannot create regular file启动报错find: “/lost+found”: 权限不够/opt/module/p

2.解压

[cevent@hadoop213 ~]$ cd /opt/soft/
[cevent@hadoop213 soft]$ ll
总用量 18916
-rw-rw-r--. 1 cevent cevent 8924465 7月   5 10:19 apache-tomcat-7.0.70.tar.gz
-rw-rw-r--. 1 cevent cevent  913417 7月   5 10:19 nginx-1.11.1.tar.gz
-rw-rw-r--. 1 cevent cevent  981687 7月   5 10:19 nginx-1.12.2.tar.gz
-rw-rw-r--. 1 cevent cevent 4556447 7月   5 10:19 openssl-1.0.1t.tar.gz
-rw-rw-r--. 1 cevent cevent 2041593 7月   5 10:19 pcre-8.37.tar.gz
-rw-rw-r--. 1 cevent cevent 1364993 7月   1 16:05 redis-3.0.4.tar.gz
-rw-rw-r--. 1 cevent cevent  571091 7月   5 10:19 zlib-1.2.8.tar.gz
[cevent@hadoop213 soft]$ tar -zxvf pcre-8.37.tar.gz -C /opt/module/
[cevent@hadoop213 pcre-8.37]$ ./configure  编译检查
pcre-8.37 configuration summary:
    Install prefix .................. : /usr/local
    C preprocessor .................. : gcc -E
    C compiler ...................... : gcc
    C++ preprocessor ................ : g++ -E
    C++ compiler .................... : g++
    Linker .......................... : /usr/bin/ld -m elf_x86_64
    C preprocessor flags ............ : 
    C compiler flags ................ : -g -O2 -fvisibility=hidden
    C++ compiler flags .............. : -O2 -fvisibility=hidden -fvisibility-inlines-hidden
    Linker flags .................... : 
    Extra libraries ................. : 

    Build 8 bit pcre library ........ : yes
    Build 16 bit pcre library ....... : no
    Build 32 bit pcre library ....... : no
    Build C++ library ............... : yes
    Enable JIT compiling support .... : no
    Enable UTF-8/16/32 support ...... : no
    Unicode properties .............. : no
    Newline char/sequence ........... : lf
    \R matches only ANYCRLF ......... : no
    EBCDIC coding ................... : no
    EBCDIC code for NL .............. : n/a
    Rebuild char tables ............. : no
    Use stack recursion ............. : yes
    POSIX mem threshold ............. : 10
    Internal link size .............. : 2
    Nested parentheses limit ........ : 250
    Match limit ..................... : 10000000
    Match limit recursion ........... : MATCH_LIMIT
    Build shared libs ............... : yes
    Build static libs ............... : yes
    Use JIT in pcregrep ............. : no
    Buffer size for pcregrep ........ : 20480
    Link pcregrep with libz ......... : no
    Link pcregrep with libbz2 ....... : no
    Link pcretest with libedit ...... : no
    Link pcretest with libreadline .. : no
    Valgrind support ................ : no
    Code coverage ................... : no


3.make install报错

[cevent@hadoop213 pcre-8.37]$ make install
make  install-am
make[1]: Entering directory `/opt/module/pcre-8.37'
make[2]: Entering directory `/opt/module/pcre-8.37'
 /bin/mkdir -p '/usr/local/lib'
 /bin/sh ./libtool   --mode=install /usr/bin/install -c   libpcre.la libpcreposix.la libpcrecpp.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libpcre.so.1.2.5 /usr/local/lib/libpcre.so.1.2.5
/usr/bin/install: cannot create regular file `/usr/local/lib/libpcre.so.1.2.5': Permission denied  没有附权
make[2]: *** [install-libLTLIBRARIES] 错误 1
make[2]: Leaving directory `/opt/module/pcre-8.37'
make[1]: *** [install-am] 错误 2
make[1]: Leaving directory `/opt/module/pcre-8.37'
make: *** [install] 错误 2

【解决】

[cevent@hadoop213 pcre-8.37]$ sudo chown -R cevent:cevent /usr/local/  修改权限,需要在usr/local下创建相关目录
[cevent@hadoop213 pcre-8.37]$ make install 安装
make  install-am
make[1]: Entering directory `/opt/module/pcre-8.37'
make[2]: Entering directory `/opt/module/pcre-8.37'
 /bin/mkdir -p '/usr/local/lib'
 /bin/sh ./libtool   --mode=install /usr/bin/install -c   libpcre.la libpcreposix.la libpcrecpp.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libpcre.so.1.2.5 /usr/local/lib/libpcre.so.1.2.5
……
ln -sf pcre_utf32_to_host_byte_order.3   /usr/local/share/man/man3/pcre32_utf32_to_host_byte_order.3
ln -sf pcre_version.3                    /usr/local/share/man/man3/pcre32_version.3
make[3]: Leaving directory `/opt/module/pcre-8.37'
make[2]: Leaving directory `/opt/module/pcre-8.37'
make[1]: Leaving directory `/opt/module/pcre-8.37'
[cevent@hadoop213 pcre-8.37]$ pcre-config --version 查看版本号
8.37

4.安装zlib / openssl

[cevent@hadoop213 pcre-8.37]$ sudo yum -y install zlib zlib-devel libtool openssl openssl-devel

已安装:
  libtool.x86_64 0:2.2.6-15.5.el6     openssl-devel.x86_64 0:1.0.1e-58.el6_10   
  zlib-devel.x86_64 0:1.2.3-29.el6   

作为依赖被安装:
  autoconf.noarch 0:2.63-5.1.el6           automake.noarch 0:1.11.1-4.el6      
  keyutils-libs-devel.x86_64 0:1.4-5.el6   krb5-devel.x86_64 0:1.10.3-65.el6   
  libcom_err-devel.x86_64 0:1.41.12-24.el6 libkadm5.x86_64 0:1.10.3-65.el6     
  libselinux-devel.x86_64 0:2.0.94-7.el6   libsepol-devel.x86_64 0:2.0.41-4.el6

更新完毕:
  openssl.x86_64 0:1.0.1e-58.el6_10                                             

作为依赖被升级:
  e2fsprogs.x86_64 0:1.41.12-24.el6    e2fsprogs-libs.x86_64 0:1.41.12-24.el6   
  krb5-libs.x86_64 0:1.10.3-65.el6     krb5-workstation.x86_64 0:1.10.3-65.el6  
  libcom_err.x86_64 0:1.41.12-24.el6   libss.x86_64 0:1.41.12-24.el6

5.安装nginx

[cevent@hadoop213 nginx-1.12.2]$ tar -zxvf nginx-1.12.2.tar.gz -C /opt/module 解压

[cevent@hadoop213 nginx-1.12.2]$ cd /opt/module/nginx-1.12.2/
[cevent@hadoop213 nginx-1.12.2]$ ./configure  检查配置文件
[cevent@hadoop213 nginx-1.12.2]$ make 
[cevent@hadoop213 nginx-1.12.2]$ make install
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs' \
                || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' \
                || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html' \
                || cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' \
                || mkdir -p '/usr/local/nginx/logs'
make[1]: Leaving directory `/opt/module/nginx-1.12.2'
[cevent@hadoop213 local]$ cd /usr/local/  nginx存放目录
[cevent@hadoop213 local]$ ll
总用量 44
drwxr-xr-x. 2 cevent cevent 4096 7月   5 10:54 bin
drwxr-xr-x. 2 cevent cevent 4096 9月  23 2011 etc
drwxr-xr-x. 2 cevent cevent 4096 9月  23 2011 games
drwxr-xr-x. 2 cevent cevent 4096 7月   5 10:54 include
drwxr-xr-x. 3 cevent cevent 4096 7月   5 10:54 lib
drwxr-xr-x. 2 cevent cevent 4096 9月  23 2011 lib64
drwxr-xr-x. 2 cevent cevent 4096 9月  23 2011 libexec
drwxrwxr-x. 6 cevent cevent 4096 7月   5 14:40 nginx
drwxr-xr-x. 2 cevent cevent 4096 9月  23 2011 sbin
drwxr-xr-x. 6 cevent cevent 4096 7月   5 10:54 share
drwxr-xr-x. 2 cevent cevent 4096 9月  23 2011 src
[cevent@hadoop213 local]$ cd nginx/
[cevent@hadoop213 nginx]$ ll
总用量 16
drwxrwxr-x. 2 cevent cevent 4096 7月   5 14:40 conf
drwxr-xr-x. 2 cevent cevent 4096 7月   5 14:40 html
drwxrwxr-x. 2 cevent cevent 4096 7月   5 14:40 logs
drwxrwxr-x. 2 cevent cevent 4096 7月   5 14:40 sbin
[cevent@hadoop213 nginx]$ cd sbin/  sbin存放命令
[cevent@hadoop213 sbin]$ ll
总用量 3512
-rwxrwxr-x. 1 cevent cevent 3593338 7月   5 14:40 nginx


6.启动报错find: “/lost+found”: 权限不够/opt/module/pcre-8.37/.libs/libpcre.so.1

[cevent@hadoop213 nginx-1.12.2]$ cd /usr/local/nginx
[cevent@hadoop213 nginx]$ ll
总用量 16
drwxrwxr-x. 2 cevent cevent 4096 7月   5 14:40 conf
drwxr-xr-x. 2 cevent cevent 4096 7月   5 14:40 html
drwxrwxr-x. 2 cevent cevent 4096 7月   5 14:40 logs
drwxrwxr-x. 2 cevent cevent 4096 7月   5 14:40 sbin
[cevent@hadoop213 nginx]$ cd sbin/
[cevent@hadoop213 sbin]$ ./nginx
./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
find: “/tmp/keyring-yLYpFp”: 权限不够
find: “/tmp/keyring-rlgLYb”: 权限不够
find: “/tmp/orbit-gdm”: 权限不够
find: “/tmp/pulse-w8PDAPlS3DYA”: 权限不够
find: “/tmp/keyring-0NFv0f”: 权限不够
find: “/tmp/keyring-PozwMV”: 权限不够
find: “/tmp/keyring-qgsfvN”: 权限不够
find: “/tmp/pulse-GGT0lK9dN7WO”: 权限不够
find: “/tmp/vmware-root-4290230028”: 权限不够
find: “/tmp/.esd-0”: 权限不够
find: “/tmp/keyring-WsRHPN”: 权限不够
find: “/tmp/keyring-5zvVuk”: 权限不够
find: “/lost+found”: 权限不够
/opt/module/pcre-8.37/.libs/libpcre.so.1


【解决】

[cevent@hadoop213 conf]$ ldd $(which /usr/local/nginx/sbin/nginx)  查看目录,需要在lib64下创建软链接
        linux-vdso.so.1 =>  (0x00007ffde11c5000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00000036c8600000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00000036c8e00000)
        libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00000036d4600000)
        libpcre.so.1 => not found
        libz.so.1 => /lib64/libz.so.1 (0x00000036c9a00000)
        libc.so.6 => /lib64/libc.so.6 (0x00000036c8a00000)
        /lib64/ld-linux-x86-64.so.2 (0x00000036c8200000)
        libfreebl3.so => /lib64/libfreebl3.so (0x00000036d4200000)
[cevent@hadoop213 nginx]$ find / -name "libpcre.so.1"  查询文件位置
/opt/module/pcre-8.37/.libs/libpcre.so.1
[cevent@hadoop213 local]$ cd /usr/local/nginx/sbin  进入nginx启动目录
[cevent@hadoop213 sbin]$ ll
总用量 3512
-rwxrwxr-x. 1 cevent cevent 3593338 7月   5 14:40 nginx
[cevent@hadoop213 sbin]$ cd /usr/lib64/  进入lib文件夹
[cevent@hadoop213 sbin]$ sudo ln -s /opt/module/pcre-8.37/.libs/libpcre.so.1  添加软链接

启动继续报错
[cevent@hadoop213 lib64]$ cd /usr/local/nginx/
[cevent@hadoop213 nginx]$ cd sbin/
[cevent@hadoop213 sbin]$ ll
总用量 3512
lrwxrwxrwx. 1 cevent cevent      40 7月   5 15:12 libpcre.so.1 -> /opt/module/pcre-8.37/.libs/libpcre.so.1
-rwxrwxr-x. 1 cevent cevent 3593338 7月   5 14:40 nginx
[cevent@hadoop213 sbin]$ ./nginx 
nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)  默认80、1024端口只能root用户启动


7.更改conf配置

[cevent@hadoop213 conf]$ cd /usr/local/nginx/conf/
[cevent@hadoop213 conf]$ ll
总用量 60
-rw-r--r--. 1 cevent cevent 1077 7月   5 14:40 fastcgi.conf
-rw-r--r--. 1 cevent cevent 1077 7月   5 14:40 fastcgi.conf.default
-rw-r--r--. 1 cevent cevent 1007 7月   5 14:40 fastcgi_params
-rw-r--r--. 1 cevent cevent 1007 7月   5 14:40 fastcgi_params.default
-rw-r--r--. 1 cevent cevent 2837 7月   5 14:40 koi-utf
-rw-r--r--. 1 cevent cevent 2223 7月   5 14:40 koi-win
-rw-r--r--. 1 cevent cevent 3957 7月   5 14:40 mime.types
-rw-r--r--. 1 cevent cevent 3957 7月   5 14:40 mime.types.default
-rw-r--r--. 1 cevent cevent 2656 7月   5 14:40 nginx.conf
-rw-r--r--. 1 cevent cevent 2656 7月   5 14:40 nginx.conf.default
-rw-r--r--. 1 cevent cevent  636 7月   5 14:40 scgi_params
-rw-r--r--. 1 cevent cevent  636 7月   5 14:40 scgi_params.default
-rw-r--r--. 1 cevent cevent  664 7月   5 14:40 uwsgi_params
-rw-r--r--. 1 cevent cevent  664 7月   5 14:40 uwsgi_params.default
-rw-r--r--. 1 cevent cevent 3610 7月   5 14:40 win-utf
[cevent@hadoop213 conf]$ vim nginx.conf

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        #listen       80;
        listen       8080;  修改为8080访问端口
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #



8.修改selinux-conf

修改selinux-conf
[cevent@hadoop213 conf]$ cd /etc/selinux/
[cevent@hadoop213 selinux]$ ll
总用量 20
-rw-r--r--. 1 root root  458 3月  13 01:54 config
-rw-r--r--. 1 root root  113 5月  11 2016 restorecond.conf
-rw-r--r--. 1 root root   76 5月  11 2016 restorecond_user.conf
-rw-r--r--. 1 root root 2271 7月  24 2015 semanage.conf
drwxr-xr-x. 6 root root 4096 3月  13 11:25 targeted
[cevent@hadoop213 selinux]$ sudo vim config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
# SELINUX=enforcing  注释,改为disabled
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

[cevent@hadoop213 sbin]$ cd /usr/local/nginx/
[cevent@hadoop213 nginx]$ cd sbin/
[cevent@hadoop213 sbin]$ ./nginx  启动nginx
[cevent@hadoop213 sbin]$ ps -ef | grep nginx  查询进程
cevent   12899     1  0 15:36 ?        00:00:00 nginx: master process ./nginx
cevent   12900 12899  0 15:36 ?        00:00:00 nginx: worker process
cevent   12903  3053  0 15:36 pts/0    00:00:00 grep nginx


9.访问链接:http://hadoop213.cevent.com:8080/

荐
                                                        nginx安装,make install报错: cannot create regular file启动报错find: “/lost+found”: 权限不够/opt/module/p

10.开放防火墙端口

[cevent@hadoop213 sbin]$ firewall-cmd --list-all   需查询相关firewall文档doc
-bash: firewall-cmd: command not found
[cevent@hadoop213 sbin]$ firewall-cmd --add-service=http -permanent
[cevent@hadoop213 sbin]$ sudo firewall-cmd --add-port=8080/tcp -permanent


11.使用nginx操作命令前提条件,进入nginx目录:/usr/local/nginx/sbin

[cevent@hadoop213 sbin]$ ./nginx -v查看当前版本号
nginx version: nginx/1.12.2
[cevent@hadoop213 sbin]$ ps -ef | grep nginx查看nginx启动状态
cevent   12899     1  0 15:36 ?        00:00:00 nginx: master process ./nginx
cevent   12900 12899  0 15:36 ?        00:00:00 nginx: worker process
cevent   13055  3053  0 15:58 pts/0    00:00:00 grep nginx
[cevent@hadoop213 sbin]$ ./nginx -s stop 停止nginx
[cevent@hadoop213 sbin]$ ps -ef | grep nginx
cevent   13065  3053  0 15:59 pts/0    00:00:00 grep nginx
[cevent@hadoop213 sbin]$ ./nginx -s reload  重新加载/重启


12.nginx配置文件解析

[cevent@hadoop213 conf]$ cd /usr/local/nginx/conf/
[cevent@hadoop213 conf]$ ll
总用量 60
-rw-r--r--. 1 cevent cevent 1077 7月   5 14:40 fastcgi.conf
-rw-r--r--. 1 cevent cevent 1077 7月   5 14:40 fastcgi.conf.default
-rw-r--r--. 1 cevent cevent 1007 7月   5 14:40 fastcgi_params
-rw-r--r--. 1 cevent cevent 1007 7月   5 14:40 fastcgi_params.default
-rw-r--r--. 1 cevent cevent 2837 7月   5 14:40 koi-utf
-rw-r--r--. 1 cevent cevent 2223 7月   5 14:40 koi-win
-rw-r--r--. 1 cevent cevent 3957 7月   5 14:40 mime.types
-rw-r--r--. 1 cevent cevent 3957 7月   5 14:40 mime.types.default
-rw-r--r--. 1 cevent cevent 2656 7月   5 14:40 nginx.conf
-rw-r--r--. 1 cevent cevent 2656 7月   5 14:40 nginx.conf.default
-rw-r--r--. 1 cevent cevent  636 7月   5 14:40 scgi_params
-rw-r--r--. 1 cevent cevent  636 7月   5 14:40 scgi_params.default
-rw-r--r--. 1 cevent cevent  664 7月   5 14:40 uwsgi_params
-rw-r--r--. 1 cevent cevent  664 7月   5 14:40 uwsgi_params.default
-rw-r--r--. 1 cevent cevent 3610 7月   5 14:40 win-utf

[cevent@hadoop213 conf]$ vim nginx.conf

【1.全局块:影响nginx服务器整体运行的配置命令】
#user  nobody;
worker_processes  1;   nginx并发处理值,值越大,并发处理越高

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

【2.events块:nginx服务器与用户网络的连接】

events {
    worker_connections  1024;  每个work process支持的最大连接数1024
}

【3.http块:配置包括代理、缓存、反向代理、负载均衡、高可用、第三方模块
包含:http全局块、server块
】

http { 
## http块:包含文件引入、MIME-type定义、日志自定义、超时连接、单连接请求等
    include       mime.types;  包含的mime类型
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
## server块:和虚拟主机有密切关系,包括 - 全局server块、location块
        #listen       80;
        listen       8080;  修改为8080访问端口(这里修改为8079,反向代理启动需要8080端口)
        server_name  localhost; //服务器名

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {  ##定义请求跳转
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #


本文地址:https://blog.csdn.net/weixin_37056888/article/details/107326131