All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
nginx wordpress with hhvm at root and another app in subdirectory with php7
EDIT2
my comments below gives brief solution. please check.
EDIT:
Too long to read, right?
Let me make it simple: I want
http://example.com leading to wordpress under HHVM,
http://example.com/analysis leading to piwik (or something like http://example.com/database leading to phpmyadmin) under php7. how can this work, thanks XD
I am now looking at following links, still trying...
http://serverfault.com/questions/218818/nginx-projects-in-subfolders
http://stackoverflow.com/questions/24328628/nginx-php-fpm-subdirectory
http://programmersjunk.blogspot.com/2013/11/nginx-multiple-sites-in-subdirectories.html
http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
http://stackoverflow.com/questions/17805576/nginx-rewrite-in-subfolder
there is a question one stackoverflow, asked "nginx php with wordpress at root and another app in subdirectory", looks like the answer works well. Actully, I just directly put another app folder in wordpress' folder and visit it well.
For example, my wordpress is at /var/web/example.com, and I simply put piwik under /var/web/example.com/piwik, then I can visit piwik at http://example.com/piwik. everything works fine.
I push this question further, is it possible that 'nginx wordpress with hhvm
at root and another app in subdirectory with php7
'?
I would like to visit wordpress at http://example.com and visit piwik (or other php app like phpmyadmin) at http://example.com/analysis/. Further more wordpress works on hhvm, and other app work under php7.
i did some research and found these:
http://robido.com/nginx/configure-an-nginx-virtual-host-with-phpmyadmin-and-php-fpm/
http://stackoverflow.com/questions/11146411/nginx-php-with-wordpress-at-root-and-another-app-in-subdirectory
http://stackoverflow.com/questions/6154879/nginx-wordpress-in-a-subdirectory-what-data-should-be-passed
my hhvm and php7 are listening on different socket files. Based on above links, here are my configure:
server { ..... # webroot location root /var/web/example.com/; # rewrite rules location / { try_files $uri $uri/ /index.php?$args; } location ~ \.(hh|php)$ { fastcgi_keep_conn on; #fastcgi_pass 127.0.0.1:9001; fastcgi_pass unix:/var/run/hhvm/hhvm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location /analysis/ { alias /var/web/example.com/piwik/; index index.php; } location ~ ^/analysis/(.+\.php)$ { alias /var/web/example.com/piwik/$1; try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
ofc, it doesn't work..... (that's why I am here :P) which retures 404 for http://example.com/analysis/
i also tried different location context
for php part, like:
location ~ /analysis/\.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
doesn't work as well.... i also see other ways to write location context,
like location ^~ /wordpress {...}
with.
root /var/web/example.com/
doesn't work and what is the difference?
this is just for curiosity, and I try to understand more about php, hhvm and nginx. Although I don't really think anyone will use php and hhvm at the same time in a production environment.
But it is possible, isn't it? then HOW?
I do this also because hhvm supports wordpress well but a lot of other php app may work better with php7. so it may be better to let wordpress run on hhvm and others on php7, here I take piwik as an example.
Please help figure this out, thank you very much.
when I was writing above, I kept getting some like this:
what's wrong?
Comments
Well, you're facing the pain in the arse software called CloudFlare.
Apparently, the Web Application Firewall hates LET and thinks any time we post a thread with the following words together: "/ var / www / html", we're automatically hackers that want to ruin LET.
In fact, it has a 99%
successfailure rate in stopping criminals.Finally, someone gives help, thank you!!
I am not criminal anyway, so add one more to that 99% :P
whole day on this...
finally solved..
briefly explain here, in case someone may also be interested in this.
the tricky part is the
order
of location contexts. nginx may apply php configure one by one, so make sub-directory's configure first, then for the whole server directory.Also a little bit thinking of
wordpress url
andsite url
, I read that official definition many times, but just realize its meaning today. wordpress is a program, an app, and the "site" is what the app wordpress generated. Thus wordpress url is defining where this app located and site url is where the "site" itself can be visited. (stupid... takes so long to understand... such apparent meaning)about permalinks. Don't like some online posts, I found rewrite rule is not necessary specified for a sub directory.
location / {}
is okhopefully above may help.
found a problem here, after modifying above. When I click the permalink option under setting, it directly donwload the file options-permalink.php instead of running it, what wrong here?
anyone may help?
That means none of the PHP
location {}
parts are matching that file, so instead of being sent to the backend PHP interpreter, it's just being served as a regular file. You'll probably need to post a updated version of your config for anyone to tell you why this is happening.Edit:
as stupid as you can imagine... it is not a problem of configuration, it is about BROWSER!! my chrome will go to download the file not to run it, but everything runs well on IE. Maybe Chrome cache policy leaded to this.
after flushing the chrome cache,everything works great... WTF is Chrome.... well new question raised, but how? :P I can't repeat it ...
thank you for help. but probably the problem is not
because other setting files under the same directory work well, such as options-general.php and a lot of other php files.
Also, when I move everything about wordpress back root (from its own folder /blog previously), it works fine again.
(then I use
alias
to implement a sub-directory using php7 other than hhvm. another way to solve my original problem :P)When I gave wordpress its own directory which is
/blog
following official guide, the configure is this:no matter the part:
is there or commented out. the website including permalink posts work well, only permalink option in back end setting doesn't work.
is it possible the rewrite rule problem? I tried other ways of rewrite rule, none of them works. possiblely I don't understand other rewrite rules other than
try_files $uri $uri/ /index.php?$args;
, so i can't adjust them to meet my situation.