您的位置:首页 > 运维架构 > Nginx

linux rat6.6 nginx-1.0.15源码包安装

2016-08-31 09:21 281 查看
1安装环境: rat6.6 在最简环境下搭建 故需要安装很多依赖包     

(1)安装目录:/opt/nginx-1.0.15

源码包放置目录:/opt/software

#mkdir 
/opt/nginx-1.0.15      //创建目录

#chmod 755 nginx-1.0.15     //目录分配权限

#mkdir   /opt/software

#chmod 755  /opt/software

2准备工作

(1)   nginx-1.0.15.tar.gz 解压包放在/opt/software 

放置源码包可以使用rz命令 

可提前 安装yum install lrzsz 

(2)安装依赖包

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

3编译安装

#cd /opt/software/

#ll

#tar -zxvf nginx-1.0.15.tar.gz

#cd nginx-1.0.15

#./configure  --user=www   --group=www  --prefix=/opt/nginx-1.0.15 --with-http_stub_status_module --with-http_ssl_module

#make

#make install

4安装完毕后进入之前创建文件夹

#cd  /opt/nginx-1.0.15/conf

#vi nginx.conf   

以下是nginx.conf 修改后的内容



[root@localhost nginx-1.0.15]# cat conf/nginx.conf

user www  www;

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       81;

        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {

            root   /opt/nginx-1.0.15/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

        #

        location ~ \.php$ {

           # root           /root/scripts;

            root           /opt/nginx-1.0.15/html;

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  /document_root$fastcgi_script_name;              

            include        fastcgi_params;

        }

        # deny access to .htaccess files, if Apache's document root

        # concurs with nginx's one

        #

        #location ~ /\.ht {

        #    deny  all;

        #}

    }

    # another virtual host using mix of IP-, name-, and port-based configuration

    #

    #server {

    #    listen       8000;

    #    listen       somename:8080;

    #    server_name  somename  alias  another.alias;

    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}

    # HTTPS server

    #

    #server {

    #    listen       443;

    #    server_name  localhost;

    #    ssl                  on;

    #    ssl_certificate      cert.pem;

    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;

    #    ssl_prefer_server_ciphers   on;

    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}

}


 其中PHP是安装后 设置的  可以先不动

5测试运行

#service iptables  stop    //关闭防火墙

#

./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

问题原因:没有安装PCRE库,或安装了PCRE库而没有配置PCRE共享库。

解决方案:配置PCRE共享库。

1. 查找pcre库的位置。

[root@server06 ~]# cd /lib 

[root@server06 lib]# find / -type f -name *libpcre.so.* 

/lib64/libpcre.so.0.0.1 

/usr/local/lib/libpcre.so.1.2.4 

/opt/nginx/pcre-8.36/.libs/libpcre.so.1.2.4

2. 将PCRE库进行软连接。

RedHat 64位机器读取的pcre文件为/lib64/libpcre.so.0.0.1文件。

[root@server06 ~]# ln -s /usr/local/lib/libpcre.so.1 /lib64/ 

[root@server06 ~]# cd /usr/local/nginx/sbin/ 

[root@server06 sbin]# ./nginx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux 源码