Grav CMS System(2)Nginx and FPM
GravCMSSystem(2)NginxandFPM
Downloadthelateststablenginx
https://nginx.org/en/download.html
>wgethttps://nginx.org/download/nginx-1.14.0.tar.gz
Configureandmakeandmakeinstallthattool
>./configure--prefix=/Users/hluo/tool/nginx-1.14.0
Onceeverythingisdone,hereisthecommandtostart
>sbin/nginx
Commandtostop
>sbin/nginx-sstop
SetUpandFPM
Lasttime,IalreadyinstalllatestPHPonmymachine.SoIalreadyhavePHP-FPMinstalled.
Preparetheconfigurationfile
>mvetc/php-fpm.d/www.conf.defaultetc/php-fpm.d/www.conf
>mvetc/php-fpm.conf.defaultetc/php-fpm.conf
Youcanchangetheportnumberorlisteninwww.conf,hereisthecommandstartphp-fpm
>sudosbin/php-fpm-R
Checktheportrunning
>netstat-ant|grep9000
tcp400127.0.0.1.9000*.*LISTEN
Checktheprocess
>ps-ef|grepfpm
017164108:15AM??0:00.01sbin/php-fpm-R
70171651716408:15AM??0:00.00sbin/php-fpm-R
SetUpNginxtoRedirectrequesttoFPM
Makesomechangestonginxconfigurationfile
>viconf/nginx.conf
location~\.php${
roothtml;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
includefastcgi_params;
}
EditPHPtestpage
>vihtml/info.php
<?phpphpinfo();?>
Visitthispage,youcanseethePHPinfo
http://localhost/info.php
ItcontainsalotofdetailinformationaboutmyPHP,thatisgreat.
SetUpGrav
DownloadthelatestGravandAdminPluginpackage
https://getgrav.org/downloads
Unzipthepackagegrav-admin-v1.5.4.zip
Unzipthefileandplacegravunder/opt/nginx/html/grav,butwhenIvisithttp://localhost/grav/index.phpIfacesomepermissionissues
Checkthenginxrunninguser
>psaux|grep-vroot|grepnginx|cut-d\-f1|sort|uniq
hluo
nobody
Ichangetheconfigurationinnginx.conftousecurrentuser
userusernamegroupname;
Andgiveallpermission
chmod-R777./grav/
Configurationisasfollow:
userhluostaff;
worker_processes1;
events{
worker_connections1024;
}
http{
includemime.types;
default_typeapplication/octet-stream;
sendfileon;
keepalive_timeout65;
server{
listen80;
server_namelocalhost;
root/opt/nginx/html/grav;
indexindex.phpindex.htmlindex.htm;
location/{
try_files$uri$uri//index.php?$query_string;
}
error_page500502503504/50x.html;
location=/50x.html{
roothtml;
}
location~\.php${
try_files$uri=404;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
includefastcgi_params;
}
}
}
Visittheadminpage
FinallyitworkswhenIvisitthispage
http://localhost/admin
VisittheNormalPage
http://localhost/
Editfewpages,allthecontentsarehere
/opt/nginx/html/grav/user/pages
References:
https://www.jianshu.com/p/907eec663cf1
https://learn.getgrav.org/basics/installation
https://github.com/getgrav/grav/blob/master/webserver-configs/nginx.conf
https://medium.com/cupofjoeio/brewing-nginx-and-php7-for-grav-development-on-mac-os-x-el-capitan-bf54237a6327
https://learn.getgrav.org/troubleshooting/permissions