Wallogit.com
2017 © Pedro Peláez
日本語ドキュメントはコチラ, (*1)
Add geeks-dev/ngxcache as a requirement to composer.json., (*2)
{
"require": {
"geeks-dev/ngxcache": "dev-master"
}
}
Update your packages with composer update or install with composer install., (*3)
Once Ngxcache is installed you need to register the service provider with the application. Open up app/config/app.php and find the providers key., (*4)
'providers' => array(
'Geeksdev\Ngxcache\NgxcacheServiceProvider'
)
Ngxcache also ships with a facade which provides the static syntax for creating collections. You can register the facade in the aliases key of your app/config/app.php file., (*5)
'aliases' => array(
'Ngxcache' => 'Geeksdev\Ngxcache\Facades\Ngxcache'
)
Add fastcgi_pass_header (X-Accel-Redirect,X-Accel-Buffering,X-Accel-Charset,X-Accel-Expires,X-Accel-Limit-Rate) ., (*6)
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_pass_header "X-Accel-Redirect";
fastcgi_pass_header "X-Accel-Buffering";
fastcgi_pass_header "X-Accel-Charset";
fastcgi_pass_header "X-Accel-Expires";
fastcgi_pass_header "X-Accel-Limit-Rate";
fastcgi_cache_key $scheme://$host$request_uri;
.
.
.
Run this command., (*7)
php artisan config:publish geeks-dev/ngxcache
See the configuration file of your Nginx., (*8)
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=cache:4m inactive=7d max_size=50m;
Edit app/config/packages/geeks-dev/ngxcache/config.php
Please specify the directory where the cache of the proxy or FastCGI is stored, (*9)
/* |-------------------------------------------------------------------------- | Nginx Cache Location
'nginx_cache_path' => '/var/run/nginx-cache', /* |-------------------------------------------------------------------------- | Nginx Cache Levels |-------------------------------------------------------------------------- */ 'nginx_levels' => '1:2',
ngxcache:backtrace Nginx display URL by tracing back all caches. <= 2014/09/25 NEW ngxcache:purge <URI> Nginx purge single cache. (URL argument is required.) ngxcache:purge-all Nginx purge cache of all. ngxcache:rebuild <URI> Nginx cache rebuild. (URL argument is required.) ngxcache:refresh-all Nginx refresh and build cache of all. ngxcache:search <URI> Nginx search single cache. (URL argument is required.) ngxcache:show Nginx display cache of all.
Usually are not cached . You can select the page to be cached by that, as shown in the following example , you define a filter ., (*10)
filter.phpExample, (*11)
Route::filter('nginx.cache-enable', function()
{
Ngxcache::enable();
});
Route::filter('nginx.cache-disable', function()
{
Ngxcache::disable();
});
routes.phpExample, (*12)
Route::group(array('prefix' => '', 'before' => 'nginx.cache-enable'), function(){
Route::get('/', 'HomeController@getIndex');
Route::get('{id}/show', 'HomeController@getShow');
});
Route::group(array('prefix' => '', 'before' => 'nginx.cache-disable'),function(){
Route::post('auth/login', 'AuthController@postIndex');
Route::controller('auth', 'AuthController');
});
/**
* Search nginx cache of all.
* example:[$result = Ngxcache::items();]
*
* @return result
*/
Ngxcache::items();
/**
* Purge nginx cache of all.
* example:[Ngxcache::purgeall();]
*
* @return result
*/
Ngxcache::purgeall();
/**
* Purge or search Nginx cache.
* example:[Ngxcache::purge($uri);]
*
* @param string $uri
* @param bool $searchmode
* @return result
*/
Ngxcache::purge($uri,$searchmode=false)
(It does not purge is performed only search Search Mode)
/**
* Rebuild Nginx cache.
* example:[Ngxcache::rebuild($uri,true,false);]
*
* @param string $uri
* @param bool $overwrite
* @param bool $usecurl
* @param bool $cached_only
* @return result
*/
Ngxcache::rebuild($uri,$overwrite=false,$usecurl=false,$cached_only=false)
(Second argument will do the forcibly overwritten.
Only if the cache does not exist , the cache is created normally.
Third argument is curl or file_get_contents)
/**
* Backtrace uri from Nginx cache.
* example:[Ngxcache::rebuild($cachePath);]
*
* @param string $cachePath
* @return string $uri
*/
Ngxcache::backtrace($cachePath);
Add the cache directory of Nginx to open_basedir in the php.ini If the operation of the cache does not work if., (*13)
(Example) open_basedir = .:/usr/share/php:/usr/share/pear:/var/run/nginx-cache
Measures There are two ., (*14)
Run vagrant ssh after sudo vim /etc/nginx/sites-available/homestead.app, (*15)
server {
- listen 80;
+ listen 8000;
After run exit command., (*16)
Next step => edit scripts/homestead.rb, (*17)
# Configure Port Forwarding To The Box - config.vm.network "forwarded_port", guest: 80, host: 8000 + config.vm.network "forwarded_port", guest: 8000, host: 8000
Please try to run the vagrant reload when finished., (*18)
Run vagrant ssh after sudo vim /etc/nginx/sites-available/homestead.app, (*19)
server {
listen 80;
+ listen 8000;
Please try to run the sudo service nginx reload when finished., (*20)