1. 程式人生 > >【Nginx】Nginx下的Yii部署

【Nginx】Nginx下的Yii部署

Url的重寫

nginx的配置檔案

[[email protected] protected]# vim /etc/nginx/conf.d/default.conf

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }


    location / {
        try_files $uri $uri/ /index.php?$args;
        if (!-e $request_filename){
        rewrite ^/(.*) /index.php last;
        }
        root   /usr/share/nginx/html;
        index  index.php  index.html  index.htm;
    }

    location ~ /(protected|framework|nbproject|themes/\w+/views|index-test\.php) {
        deny all;
        # for production
        internal;
        log_not_found off;
        access_log off;
    }


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

    # 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           /usr/share/nginx/html;
        include  fastcgi_params;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$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;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /(\.svn|\.git|\.ht|\.DS) {
        deny all;
        internal;
    }
}

yii的配置檔案

/project/protected/config/main.php

<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>'My Web Application',

	// preloading 'log' component
	'preload'=>array('log'),

	// autoloading model and component classes
	'import'=>array(
		'application.models.*',
		'application.components.*',
	),

	'modules'=>array(
		// uncomment the following to enable the Gii tool
		/*
		'gii'=>array(
			'class'=>'system.gii.GiiModule',
			'password'=>'Enter Your Password Here',
			// If removed, Gii defaults to localhost only. Edit carefully to taste.
			'ipFilters'=>array('127.0.0.1','::1'),
		),
		*/
	),

	// application components
	'components'=>array(

		'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
		),

		// uncomment the following to enable URLs in path-format
		
		'urlManager'=>array(
			'urlFormat'=>'path',
                        'showScriptName' => false,
                        'urlSuffix' => '.html',
			'rules'=>array(
				'<controller:\w+>/<id:\d+>'=>'<controller>/view',
				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
			),
		),
		

		// database settings are configured in database.php
		'db'=>require(dirname(__FILE__).'/database.php'),

		'errorHandler'=>array(
			// use 'site/error' action to display errors
			'errorAction'=>'site/error',
		),

		'log'=>array(
			'class'=>'CLogRouter',
			'routes'=>array(
				array(
					'class'=>'CFileLogRoute',
					'levels'=>'error, warning',
				),
				// uncomment the following to show log messages on web pages
				/*
				array(
					'class'=>'CWebLogRoute',
				),
				*/
			),
		),

	),

	// application-level parameters that can be accessed
	// using Yii::app()->params['paramName']
	'params'=>array(
		// this is used in contact page
		'adminEmail'=>'
[email protected]
', ), );

重啟nginx

[[email protected] protected]# service nginx restart
停止 nginx:                                               [確定]
正在啟動 nginx:                                           [確定]


相關推薦

NginxNginxYii部署

Url的重寫 nginx的配置檔案 [[email protected] protected]# vim /etc/nginx/conf.d/default.conf server { listen 80; server_name

筆記linuxnginx自動安裝

前言: nginx依賴的元件比較多,大概有這幾個: a、openssl b、pcre c、zlib 安裝過程較為繁瑣,所以,這裡拿券君已經幫你整理好啦,只需要一鍵執行即可!   話不多說,開始! 1、下載整理好的nginx: https://downlo

筆記linuxnginx配置(做動態服務)

上一篇,我們介紹了nginx配置靜態服務的方法(https://blog.csdn.net/oceanyang520/article/details/83107595), 這一篇,我們來介紹動態服務的方法 nginx動態代理,主要是反向代理,這一篇,我們來介紹下如何用域名訪問你的應用。

NginxNginx部署安裝

環境:CentOS7.2 x64 一、安裝及執行nginx 1、下載&解壓: cd ~/app wget https://nginx.org/download/nginx-1.14.0.t

linuxcentosnginx自動原始碼編譯安裝指令碼,以及通過service 啟動/停止/過載 nginx的服務指令碼

 第一:指令碼為nginx原始碼編譯安裝的指令碼,可以幫助使用者自動建立系統使用者“nginx”;可以使用者自己指定安裝路徑,配置檔案路徑,執行檔案路徑等; 第二:可以配置第二個指令碼使用,通過service服務來管理nginx。 [[email protect

NginxNginx部署Windows設定80埠

  Nginx部署在Windows埠做負載均衡時,配置其監聽80埠。Start時會發現無法啟動,原因為其80埠已被佔用。 即使IIS中關閉全部80埠的網站後訪問此80端口出現的是404,而非網路斷開連線。可以推斷出IIS或相關容器一直監聽 導致Nginx無法啟動的。通過CMD->netstat -a

NginxNginx部署Windows設置80端口

沒有 art 手動 網站 被占用 斷開連接 導致 目前 stat   Nginx部署在Windows端口做負載均衡時,配置其監聽80端口。Start時會發現無法啟動,原因為其80端口已被占用。 即使IIS中關閉全部80端口的網站後訪問此80端口出現的是404,而非網絡斷開連

djangoNginx+uWSGI+Django部署我的部落格網站

一.前言 我們通常將nginx作為伺服器最前端,它將接收WEB的所有請求,統一管理請求。然後nginx把所有靜態請求自己來處理(這是NGINX的強項),並將將所有非靜態請求通過uwsgi傳遞給Django,由Django來進行處理,從而完成一次WEB請求。

NginxNginx簡介及在CentOS7.0安裝教程

是什麼 Nginx是一款輕量級的Web 伺服器/反向代理伺服器及電子郵件(IMAP/POP3)代理伺服器,並在一個BSD-like 協議下發行。其特點是佔有記憶體少,併發能力強,事實上nginx的併

NingxLinuxNginx的安裝配置

Nginx 安裝配置Nginx("engine x")是一款是由俄羅斯的程式設計師Igor Sysoev所開發高效能的 Web和 反向代理 伺服器,也是一個 IMAP/POP3/SMTP 代理伺服器。在高連線併發的情況下,Nginx是Apache伺服器不錯的替代品。Nginx 安裝系統平臺:CentOS re

NginxUbuntu安裝配置Nginx

一、安裝和解除安裝: 安裝: apt-get install software-properties-common add-apt-repository ppa:nginx/stable apt-get update apt-get ins

解決nginx $_SERVER['PATH_INFO'] 無法獲取到內容

end 支持 解決方案 doc 加載文件 color read inf oca Apache是模塊加載文件的,默認支持$_SERVER[‘PATH_INFO‘] ; 而對於Nginx下, 是不支持PATH INFO的, 也就是它不會默認設置PATH_INFO. 而因為N

Linuxnginx服務配置

網站目錄 write timeout per dex 修改 header www val 一. 部署LNMP環境 準備工作 Linux系統準備 設置IP 關閉防火墻

WebNginx 反向代理與負載均衡

連接 代理服務器 body 後端服務 style 執行 class redirect 配置文件 反向代理   反向代理(Reverse Proxy)方式是指以代理服務器來接受internet上的連接請求,然後將請求轉發給內部網絡上的服務器,並將從服務器上得到的結果返回給in

Nginx--nginx入門教程

較高的 其中 8K 三臺 finance 輸出 nginx安裝 全局 通過 nginx入門教程 一.概述 什麽是nginx? Nginx (engine x) 是一款輕量級的Web 服務器 、反向代理服務器及電子郵件(IMAP/POP3)代理服

Nginx Nginx實現端口轉發

nbsp 都是 localhost ron tro ups server 搭建 div 什麽是端口轉發 當我們在服務器上搭建一個圖書以及一個電影的應用,其中圖書應用啟動了 8001 端口,電影應用啟動了 8002 端口。此時如果我們可以通過 localhost:80

20180712Nginx 參數優化和內核參數優化

關閉連接 pla GZip壓縮 con soc java squid服務器 val expire Nginx 參數優化 worker_processes 這裏的數值不能超過CPU的總核數,因為在單個核上部署超過1個Nginx服務進程並不能起到提高性能的作用。 wor

NginxNginx配置REWRITE隱藏index.php

php div nginx配置 pan request 只需要 span col lena 只需要在server裏面加上   if ( !e $request_filename ) {     rewrite ^/(.*)$ /index.php/$1 last;  

Nginx學習---Nginx&&Redis&&hcache三層緩存架構總結

inux 次循環 地址 本地緩存 lin 同步等待 獲取數據 分發 到來 【原文】https://www.toutiao.com/i6594307974817120782/ 摘要: 對於高並發架構,毫無疑問緩存是最重要的一環,對於大量的高並發,可以采用三層緩存架構來實現,n

Nginx work_processes配置

worker_processes:作業系統啟動多少個工作程序執行Nginx。注意是工作程序,不是有多少個nginx工程。在Nginx執行的時候,會啟動兩種程序,一種是主程序master process;一種是工作程序worker process。例如我在配置檔案中將worker_processes設