zoukankan      html  css  js  c++  java
  • 安装Nginx

    安装Nginx
    1、安装编译环境
    yum -y install gcc gcc-c++ make lrzsz

    上传 rz

    2、安装pcre、zlib

    tar -zxvf pcre-8.38.tar.gz
    cd pcre-8.38
    ./configure && make && make install
    cd ..

    tar -zxvf zlib-1.2.8.tar.gz
    cd zlib-1.2.8
    ./configure && make && make install
    cd ..

    3、安装Nginx

    tar -zxvf nginx-1.8.1.tar.gz
    cd nginx-1.8.1
    ./configure && make && make install
    cd ..

    4、启动

    检查80端口是否被占用
    lsof -i:80 (如果被占用,停掉占用的进程)

    /usr/local/nginx/sbin/nginx #启动nginx服务

    ln -s /usr/local/nginx/sbin/nginx /usr/sbin #创建Nginx 启动链接
    nginx #启动nginx服务
    pkill nginx #停止nginx服务

    报错:nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
    解决: ln -s /usr/local/lib/libpcre.so.1 /lib64


    ##############虚拟主机#################
    1、基于端口
    vim /usr/local/nginx/conf/nginx.conf
    ————————————————————————————————————————————————————
    server {
    listen 90;
    root /www/web1;
    }
    ————————————————————————————————————————————————————————

    2、基于ip
    vim /usr/local/nginx/conf/nginx.conf
    ————————————————————————————————————————————————————
    server {
    listen 192.168.**.**;
    root /www/web1;
    }
    ————————————————————————————————————————————————————————

    3、基于域名
    vim /usr/local/nginx/conf/nginx.conf
    ————————————————————————————————————————————————————
    server {
    listen 80;
    server_name www.123.com;
    root /www/web1;
    }
    ————————————————————————————————————————————————————————


    ##############配置nginx支持PHP
    1、安装PHP php-fpm
    yum -y install php*
    rpm -ivh php-fpm-5.3.3-1.i_want_root.el6.x86_64.rpm

    2、修改nginx配置文件
    vim /usr/local/nginx/conf/nginx.conf
    ————————————————————————————————————————————————————————————

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


    location ~ .php$ {
    root html;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }

    ——————————————————————————————————————————————————————
    重新加载nginx配置文件

    nginx -s reload

    启动php-fpm

    service php-fpm start

    编辑php测试页

    vim /usr/local/nginx/html/index.php
    ____________________________

    <?php phpinfo(); ?>
    _________________________________

    测试


    世界本来就很邋遢,还有什么可以害怕。加油。

  • 相关阅读:
    HTTP基础及telnet简单命令
    【详解】并查集高级技巧:加权并查集、扩展域并查集
    二叉树中两节点的最近公共父节点(360的c++一面问题)
    (用POJ 1160puls来讲解)四边形不等式——区间dp的常见优化方法
    详细讲解Codeforces Round #625 (Div. 2)E
    详细讲解Codeforces Round #625 (Div. 2) D. Navigation System
    详细讲解Codeforces Round #624 (Div. 3) F. Moving Points
    详细讲解Codeforces Round #624 (Div. 3) E. Construct the Binary Tree(构造二叉树)
    POJ
    新手建站前需要做哪些准备?
  • 原文地址:https://www.cnblogs.com/FyJianc/p/11504688.html
Copyright © 2011-2022 走看看