nginx php 配置

简介: /************************************************************************************** * nginx php 配置 * 说明: * 配置一下nginx和php的开发环境,这个主要是为了将来运行的TI的Matrix GUI。
/**************************************************************************************
 *                               nginx php 配置
 * 说明:
 *     配置一下nginx和php的开发环境,这个主要是为了将来运行的TI的Matrix GUI。
 *                 
 *                                                  2016-8-7 深圳 南山平山村 曾剑锋
 *************************************************************************************/


一、参考文档:
    ubuntu 14.04安装nginx+php+mysql
        http://www.cnblogs.com/helinfeng/p/4219051.html

二、目录结构:
    root@aplex:/home/aplex/website/phpsite# pwd
    /home/aplex/website/phpsite
    root@aplex:/home/aplex/website/phpsite# tree
    .
    └── index.php
    
    0 directories, 1 file
    root@aplex:/home/aplex/website/phpsite# 

三、nginx配置:
    root@aplex:/etc/nginx# pwd
    /etc/nginx
    root@aplex:/etc/nginx# ls
    conf.d          mime.types           nginx.conf       sites-enabled
    fastcgi_params  naxsi_core.rules     proxy_params     uwsgi_params
    koi-utf         naxsi.rules          scgi_params      win-utf
    koi-win         naxsi-ui.conf.1.4.1  sites-available
    root@aplex:/etc/nginx# cat sites-available/default
    # You may add here your
    # server {
    #   ...
    # }
    # statements for each of your virtual hosts to this file
    
    ##
    # You should look at the following URL's in order to grasp a solid understanding
    # of Nginx configuration files in order to fully unleash the power of Nginx.
    # http://wiki.nginx.org/Pitfalls
    # http://wiki.nginx.org/QuickStart
    # http://wiki.nginx.org/Configuration
    #
    # Generally, you will want to move this file somewhere, and start with a clean
    # file but keep this around for reference. Or just disable in sites-enabled.
    #
    # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
    ##
    
    server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;
    
        root /home/aplex/website/mysite;
        index index.html index.htm;
    
        # Make site accessible from http://localhost/
        server_name localhost;
    
        location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            # try_files $uri $uri/ =404;
            include  uwsgi_params;
                    uwsgi_pass  127.0.0.1:9091;              #必须和uwsgi中的设置一致
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
        }
    
        # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
        #location /RequestDenied {
        #   proxy_pass http://127.0.0.1:8080;    
        #}
    
        #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 /usr/share/nginx/html;
        #}
    
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #   fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #   # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        #
        #   # With php5-cgi alone:
        #   fastcgi_pass 127.0.0.1:9000;
        #   # With php5-fpm:
        #   fastcgi_pass unix:/var/run/php5-fpm.sock;
        #   fastcgi_index index.php;
        #   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;
    #   root html;
    #   index index.html index.htm;
    #
    #   location / {
    #       try_files $uri $uri/ =404;
    #   }
    #}
    
    
    # HTTPS server
    #
    #server {
    #   listen 443;
    #   server_name localhost;
    #
    #   root html;
    #   index index.html index.htm;
    #
    #   ssl on;
    #   ssl_certificate cert.pem;
    #   ssl_certificate_key cert.key;
    #
    #   ssl_session_timeout 5m;
    #
    #   ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
    #   ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
    #   ssl_prefer_server_ciphers on;
    #
    #   location / {
    #       try_files $uri $uri/ =404;
    #   }
    #}
    
    server {
        listen 8000 default_server;
        listen [::]:8000 default_server ipv6only=on;
    
        root /home/aplex/website/phpsite;
        index index.html index.htm index.php;
    
        # Make site accessible from http://localhost/
        server_name localhost;
    
        # location / {
        #   # First attempt to serve request as file, then
        #   # as directory, then fall back to displaying a 404.
        #   # try_files $uri $uri/ =404;
        #   # include  uwsgi_params;
            #       # uwsgi_pass  127.0.0.1:9091;              
        #   # Uncomment to enable naxsi on this location
        #   # include /etc/nginx/naxsi.rules
        # }
    
        # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
        #location /RequestDenied {
        #   proxy_pass http://127.0.0.1:8080;    
        #}
    
        #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 /usr/share/nginx/html;
        #}
    
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #   # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        #
        #   # With php5-cgi alone:
        #   fastcgi_pass 127.0.0.1:9000;
        #   # With php5-fpm:
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
        }
    
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #   deny all;
        #}
    }
    root@aplex:/etc/nginx# 

 

目录
相关文章
|
2月前
|
应用服务中间件 BI nginx
Nginx的location配置详解
【10月更文挑战第16天】Nginx的location配置详解
|
2月前
|
缓存 负载均衡 安全
Nginx常用基本配置总结:从入门到实战的全方位指南
Nginx常用基本配置总结:从入门到实战的全方位指南
285 0
|
2月前
|
应用服务中间件 Linux nginx
Jetson 环境安装(四):jetson nano配置ffmpeg和nginx(亲测)之编译错误汇总
这篇文章是关于在Jetson Nano上配置FFmpeg和Nginx时遇到的编译错误及其解决方案的汇总。
96 4
|
16天前
|
存储 负载均衡 中间件
Nginx反向代理配置详解,图文全面总结,建议收藏
Nginx 是大型架构必备中间件,也是大厂喜欢考察的内容,必知必会。本篇全面详解 Nginx 反向代理及配置,建议收藏。
Nginx反向代理配置详解,图文全面总结,建议收藏
|
29天前
|
应用服务中间件 API nginx
nginx配置反向代理404问题
【10月更文挑战第18天】本文介绍了使用Nginx进行反向代理的配置方法,解决了404错误、跨域问题和302重定向问题。关键配置包括代理路径、请求头设置、跨域头添加以及端口转发设置。通过调整`proxy_set_header`和添加必要的HTTP头,实现了稳定的服务代理和跨域访问。
147 1
nginx配置反向代理404问题
|
13天前
|
应用服务中间件 网络安全 nginx
轻松上手Nginx Proxy Manager:安装、配置与实战
Nginx Proxy Manager (NPM) 是一款基于 Nginx 的反向代理管理工具,提供直观的 Web 界面,方便用户配置和管理反向代理、SSL 证书等。本文档介绍了 NPM 的安装步骤,包括 Docker 和 Docker Compose 的安装、Docker Compose 文件的创建与配置、启动服务、访问 Web 管理界面、基本使用方法以及如何申请和配置 SSL 证书,帮助用户快速上手 NPM。
67 1
|
19天前
|
监控 PHP Apache
优化 PHP-FPM 参数配置:实现服务器性能提升
优化PHP-FPM的参数配置可以显著提高服务器的性能和稳定性。通过合理设置 `pm.max_children`、`pm.start_servers`、`pm.min_spare_servers`、`pm.max_spare_servers`和 `pm.max_requests`等参数,并结合监控和调优措施,可以有效应对高并发和负载波动,确保Web应用程序的高效运行。希望本文提供的优化建议和配置示例能够帮助您实现服务器性能的提升。
41 3
|
2月前
|
编解码 Ubuntu 应用服务中间件
Jetson 环境安装(三):jetson nano配置ffmpeg和nginx(亲测)
本文介绍了在NVIDIA Jetson Nano上配置FFmpeg和Nginx的步骤,包括安装、配置和自启动设置。
168 1
Jetson 环境安装(三):jetson nano配置ffmpeg和nginx(亲测)
|
1月前
|
缓存 负载均衡 应用服务中间件
Nginx配置
【10月更文挑战第22天】在实际配置 Nginx 时,需要根据具体的需求和环境进行调整和优化。同时,还需要注意配置文件的语法正确性和安全性。
48 7
|
2月前
|
前端开发 JavaScript 应用服务中间件
终极 Nginx 配置指南
本文介绍了Nginx的基本配置及其优化方法。首先,通过删除注释简化了Nginx的默认配置文件,使其更易于理解。接着,文章将Nginx配置文件分为全局块、events块和http块三部分进行详细解释。此外,还提供了如何快速上线网站、解决前端history模式404问题、配置反向代理、开启gzip压缩、设置维护页面、在同一IP上部署多个网站以及实现动静分离的具体配置示例。最后,附上了Nginx的基础命令,包括安装、启动、重启和关闭等操作。