通过Nginx来安装一个discuz,软件并不是编译安装的

这次由于时间有限,所以我就没有用编译安装来启动LMP,只有Nginx 是编译安装的
因为是在centos7上面安装的Nginx所以我们这里由于能力有限,暂时不能将其加入开机启动,日后我会进行改进,将其加入开机启动。这里我们给出Nginxd的编译选项及环境

 

yum groupinstall "Development Tools" "Server Platform Deveopment";
 yum install openssl-devel pcre-devel;
 groupadd -r nginx;
 useradd -r -g nginx nginx;

 ./configure \
  --prefix=/usr \
  --sbin-path=/usr/sbin/nginx \
  --conf-path=/etc/nginx/nginx.conf \
  --error-log-path=/var/log/nginx/error.log \
  --http-log-path=/var/log/nginx/access.log \
  --pid-path=/var/run/nginx/nginx.pid  \
  --lock-path=/var/lock/nginx.lock \
  --user=nginx \
  --group=nginx \
  --with-http_ssl_module \
  --with-http_flv_module \
  --with-http_stub_status_module \
  --with-http_gzip_static_module \
  --http-client-body-temp-path=/var/tmp/nginx/client/ \
  --http-proxy-temp-path=/var/tmp/nginx/proxy/ \
  --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
  --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
  --http-scgi-temp-path=/var/tmp/nginx/scgi \
  --with-pcre    | tee /tmp/nginx.out            -->重定向至文件;
    make && make install;

  

二、配置Nginx vi /etc/nginx/nginx.conf

Nginx的代码是由一个核心和一系列的模块组成, 核心主要用于提供Web Server的基本功能,以及Web和Mail反向代理的功能;还用于启用网络协议,创建必要的运行时环境以及确保不同的模块之间平滑地进行交互。不过,大多跟协议相关的功能和某应用特有的功能都是由nginx的模块实现的。这些功能模块大致可以分为事件模块、阶段性处理器、输出过滤器、变量处理器、协议、upstream和负载均衡几个类别,这些共同组成了nginx的http功能。事件模块主要用于提供OS独立的(不同操作系统的事件机制有所不同)事件通知机制如kqueue或epoll等。协议模块则负责实现nginx通过http、tls/ssl、smtp、pop3以及imap与对应的客户端建立会话。

Nginx的核心模块为Main和Events,此外还包括标准HTTP模块、可选HTTP模块和邮件模块,其还可以支持诸多第三方模块。Main用于配置错误日志、进程及权限等相关的参数,Events用于配置IO模型,如epoll、kqueue、select或poll等,它们是必备模块。

Nginx的主配置文件由几个段组成,这个段通常也被称为nginx的上下文,每个段的定义格式如下所示。需要注意的是,其每一个指令都必须使用分号(;)结束,否则为语法错误。
#main  配置段,无需加什么方括号,这里表明是其他几个盘配置段的公用的配置,当然其他的配置段也可以自己在配置里重新定义;这样就叫做上下文#定义用户和用户组;user  nginx nginx ;#优化性能配置!!!与cpu相对,一般是cpu数量-1worker_processes  2;
worker_cpu_affinity  01 10;#用于实现cpu绑定即无需切换上下文,优化系统性能;#error_log  logs/error.log;#error_log  logs/error.log  notice;error_log  logs/error.log  info;


pid /var/run/nginx/nginx.pid;#要想禁用error-log则需使用如下命令;#error_log /dev/null crit;#此处为调试功能,暂不开启;#error_log LOGFILE [debug_core | debug_alloc | debug_mutex | debug_event | debug_http | debug_imap];#优化性能的配置,这里好像只能配置时间;timer_resolution 100ms;#每个进程能打开的最大的句柄数,优化性能的配置worker_rlimit_nofile 200;#每个用户能发向进程的信号数量,这也是性能优化的一部分;貌似会有问题#worker_rlimit_sigpending  200  ;events {
        worker_connections  1024;        #最大的客户端数量由上下文决定;
        #max clients = worker_processes * worker_connections
        #use auto;
        #下面这个配置是负载均衡锁,打开此调度会损耗系统性能;
        #accept_mutex[0n|off] 
        #lock_file为其锁文件
        #一个worker进程为取得一个锁真正建立连接的最长等待时间;如果某worker去取锁时,如果有worker在使用,那么得等待这么久再进行第二次
        # 请求,默认是500ms;
        #accept_mutex_delay #ns ;
        #multi_accept  [on|off];
        #是否允许并发建立连接,一次响应多个用户请求;默认为off;


        #用于调试、定位问题:只调试Nginx时使用,只让nginx工作在单进程模式下
        #daemon [on|off];提供关闭守护进程模式;
        #是否让Nginx运行于后台,默认为on,调试时默认为off,使得信息直接输出至控制台
        #master_process on | off 是否以此模式运行,默认为on,调试时可设为off以便追踪。
        #                                                                               
        }


http {#客户端类指令:如client_body_buffer_size 128k ;
client_header_buffer_size 32k;#large_client_buffer_size  32k;client_max_body_size  8m;#client_header_timeout;#keepalive_timeout;#文件IO类指令:如#aio;#directio;#open_file_cache;#open_file_cache_min_uses;#open_file_cache_valid;#sendfile;#hash类指令:用于定义Nginx为某特定的变量分配多大的内存空间,如#types_hash_bucket_size;#server_names_hash_bucket_size;#variables_hash_bucket_size;#套接字类指令:用于定义Nginx如何处理tcp套接字相关的功能,如tcp_nodelay on;#(用于keepalive功能启用时);tcp_nopush on;#(用于sendfile启用时);

    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;
    #配置压缩模块格式;gzip on;
gzip_min_length 1k;
gzip_buffers   4 16k;
gzip_http_version 1.0;
gzip_comp_level 4;#这里是一个引用配置段,我就不启用了;#include vh/bbs.yourich.com.cn.conf;

 log_format  main  '$remote_addr-$remote_user $time_local "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"'
                       '$upstream_addr $upstream_response_time $request_time ';#   配置公用的server段#   server{#       }#
        server {
        listen       80;
        server_name  www.sjf.com;
        index  index.html index.php;
        access_log /var/log/nginx/access.log  main;
        error_log   /var/log/nginx/error.log;        #server_name_hash_bucket_size;定义一次最多存储多少主机名
        #

        #charset koi8-r;

        #access_log  logs/host.access.log  main;#允许根据用户请求的URI来匹配指定的各location以进行访问配置;匹配到时,将被location块中的配置所处理;#比如:http://www.magedu.com/images/logo.gif# =:精确匹配;# ~:正则表达式模式匹配,匹配时区分字符大小写# ~*:正则表达式模式匹配,匹配时忽略字符大小写# ^~: URI前半部分匹配,不检查正则表达式
        location ^~ /admin{
        auth_basic  "Auth Area";
        auth_basic_user_file   /etc/nginx/.nginx_passwd;

        }
        location ~ .*\.(jpg|jpeg|png|gif\js|css)$ {
                root /usr/html;
                access_log off;
        }
        location   / {
                root /usr/html;                #try_files $uri $uri/ /index.php?$args;
                index index.html index.htm  index.php ;
        }
        location ~* \.php$ {               #        expires -1s;
                #这一条是可以不写的;
                root   /usr/html;        #       try_files $uri =404
                fastcgi_pass  127.0.0.1:9000;
                fastcgi_index     index.php ;
                fastcgi_param    SCRIPT_FILENAME /usr/html$fastcgi_script_name;
                include  fastcgi_params;                #fastcgi_param QUERY_STRING  $query_string;
                #fastcgi_param REQUEST_METHOD $request_method;
                #fastcgi_param CONTENT_TYPE  $content_type;
                #fastcgi_param CONTENT_LENGTH $content_length;
                fastcgi_cache off;
                fastcgi_cache_key  $request_uri;
                fastcgi_cache_valid  200 302 10m;
                fastcgi_cache_valid  301  1h;
                fastcgi_cache_valid  any  1m;
        }
        location    ~* ^/(status|ping)$   {
                include fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param   SCRIPT_FILENAME $fastcgi_script_name;

}
        location /status {
          stub_status                 on;
          access_log                  off;
          allow                       127.0.0.1;
          allow                       192.168.42.171;
          deny                        all;
      }

        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           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$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;
                #fastcgi_param CONTENT_TYPE  $content_type;
                #fastcgi_param CONTENT_LENGTH $content_length;
                fastcgi_cache off;
                fastcgi_cache_key  $request_uri;
                fastcgi_cache_valid  200 302 10m;
                fastcgi_cache_valid  301  1h;
                fastcgi_cache_valid  any  1m;
        }
        location    ~* ^/(status|ping)$   {
                include fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param   SCRIPT_FILENAME $fastcgi_script_name;

}
        location /status {
          stub_status                 on;
          access_log                  off;
          allow                       127.0.0.1;
          allow                       192.168.42.171;
          deny                        all;
      }

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

这里我们用数据哭给用户授权对论坛数据库的访问

mysql -uroot -p123 -e 'create database ultrax;'
mysql -u root -p123 -e 'grant all on 'root'@'192.168.42.171'  identified by  '123'; '

这里我们解压Discuz

blob.png

这里我们用数据哭给用户授权对论坛数据库的访问
这里我们解压Discuz
得到这个目录,然后我们复制所有文件到/usr/html 中
chown -R ngin.nginx /usr/html
然后修改/etc/php-fpm.d/www.conf
将与php连接的用户和组均改为nginx.
这样我们打开网站首页就可以进行访问了!!
接下来我们要实现的就是结合nfs 实现多级LNMP的架构!!!

原创文章,作者:sjfbjs,如若转载,请注明出处:http://www.178linux.com/54277

(1)
上一篇 2016-10-25 09:03
下一篇 2016-10-25 09:46

相关推荐

  • 推荐-DNS架设实验

    DNS架设实验 实验拓扑 实验准备 流程 测试 总结 实验拓扑: 1.对于来自内网的DNS正反向解析,并实现view选择指定解析库解析。2.对于来自外网的DNS正向解析,并实现view选择指定解析库解析。3.实现主从服务器结构。4.实现一个完成对一个子域的授权。5.子域中的所有查询xiao.com.的信息都转向192.168.1.1解析。 1.根据view,…

    2016-04-19
  • 第九周 N21 总有刁民想害朕

    1、写一个脚本,判断当前系统上所有用户的shell是否为可登录shell(即用户的shell不是/sbin/nologin);分别这两类用户的个数;通过字符串比较来实现; #!/bin/bash nologinuser=$(awk -F : '$NF~/\/nologin$/ {print $7}&…

    Linux干货 2016-09-26
  • lvs-dr实践-week17

    1、结合图形描述LVS的工作原理; lvs工作流程: ipvs是工作于input链上,监听目标地址上对应的目标端口,如果这个端口对应的服务定义为集群服务, 就强行修改报文的流程,完成转发, 通过postrouting送出去, 为了让后端主机能够接收, 此时需要让RS也具有目标ip地址, 要么修改目标ip地址支持基于TCP,UDP,SCTP,AH,EST,AH…

    2017-05-23
  • 始于此

         “路漫漫其修远兮,吾将上下而求索”,一段路程的结束,意味着一段路程的开始,同岁月般,永远也不能回到出发的那一刻,你所能做的,就是一路走下去。回顾珍惜,却不能逗留。         我的学习宣言是“功崇惟志,业广惟勤”,时刻告诉自己,“功”出…

    Linux干货 2016-11-28
  • N26-上海-莫言

    持续更新…

    Linux干货 2016-12-26
  • 正则表达式练习题及作业(8.5)

    当天练习题: 基本正则表达式练习题 1.显示/proc/meminfo文件中以大小s开头的行;(要求:使用两种方式)   可有四种方式 [root@CentOS7 ~]# cat /proc/meminfo | grep -E "^(s|S)" SwapCac…

    Linux干货 2016-08-15