Why HHVM and NGINX are used together? - php

I thought HHVM can already serve the website. Why do we need NGINX?
I used to install mediawiki on just Apache and MySQL and it worked fine.

NGINX is used as a reverse proxy with HHVM. Depending on what you're doing with it, HHVM might be a better processor for PHP than letting NGINX deal with PHP on its own. I'm not in a position to say which solution is best, only that those options exist.

Related

GKE / running php apps / exposing via nginx or apache?

Not that much experienced in php, currently running a php app
The cluster uses an nginx ingress load balancer
The php container currently uses nginx (FROM that one https://hub.docker.com/r/wyveo/nginx-php-fpm/), so the pod is exposed via nginx
I'm having some weird behaviours by using this image, so I had in mind to give apache a shot, in case it would provide a more stable result
That is, it does not change the game; is there any other ways to run a php app in such context ? What would be the best way ?
Have you checked the official images?
For safety is better to use official images rather than other ones.
Check the php official repo, they have a version with apache installed.
I am not a php expert either, but the configurations I have made usually use apache to handle requests.
The official repo:
https://hub.docker.com/_/php
Check the tags that use apache. There are versions in stretch and alpine.

Is there a tool to manage multiple installations of PHP on one machine (e.g. to support different versions)?

perlbrew is a tool to manage multiple installations of Perl on your system, making it easy to, say, quickly run a suite of test scripts against many different versions of Perl.
Is there anything like that for PHP? For now when I want to change the version of PHP that my system uses, I'll go into the build directory for my desired version and run make install.
Here's one: http://www.navicopa.com - it allows you to switch between different versions of php in one click (just install them into different directories)
And here's a free one: https://github.com/c9s/phpbrew
Also - you might like this solution as an alternative, if you don't want to use side software: https://stackoverflow.com/a/5299385/1337343
Also missed that you use linux environment, so you would really like this: https://github.com/tobiasgies/php-switch
Install all php versions you need and switch between them using this tiny bash script.
Maybe phpfarm could help you...
When you run ./configure, add --prefix=/usr/local/php-{version} (replacing {version} with the php version). Then to run a script with a certain version:
/usr/local/php-{version}/bin/php script.php
To run under a CGI environment
Make a symlink from /usr/local/bin/php-cgi to /usr/local/php-{version}/bin/php-cgi and then remake the symlink and restart the server when you want to switch php versions.
Maybe light offtopic, but for local development under windows some WAMP stacks provide excellent one-click switching of php versions. i had positive experiences with:
http://www.wampserver.com
http://www.uniformserver.com
Not sure whether this is all clear for you, but let me know if it's not :)
cli
For simple cli testing you can just install each version into their own folders, e.g. /usr/local/php-5.4/bin, /usr/local/php-5.3.10/bin, etc.
fastcgi
For some time you can run PHP in FastCGI mode. You can let a few versions run simultaneously and bind them to different ports, e.g. :9000, :9001, :9002, etc.
The next step is to set up multiple name based virtual hosts in either Apache, Nginx, Lighttpd or Node.js. Each virtual host binds to another FastCGI process and therefore uses a different version of PHP.
Maybe this is overkill for what you need, but if you don't mind using virtual machines Vagrant may be helpful.

Is it possible to install PHP 5 and MySQL on Apache Tomcat 6.0.32 WITHOUT Apache HTTP Server?

There's a webserver which serves dynamic JSP contents, but we would like to serve some PHP contents too.
Is it possible to install PHP 5 and MySQL on Apache Tomcat 6.0.32 WITHOUT stopping the service of current contents, uninstalling Tomcat, installing the Apache HTTP Server (via AppServ, XAMPP or something similar which installs PHP, MySQL and phpMyAdmin too with just some simple clicks), and after that, configuring the Apache Tomcat Connector?
Currently I don't have the opportunity to configure the mentioned "target" webserver, but I installed Tomcat on my local machine, so with my own webserver I can try doing anything suggested.
I know there are lots of questions related to the topic even on stackoverflow, but none of them answered my question.
Thank you in advance!
You could use Quercus or JSR223 + PHP-bridge to read/parse/run PHP files using Java.
As to MySQL, as being just a simple and standalone DB server, it doesn't require a specific webserver. MySQL totally doesn't care wat webserver you're running. Just install and configure it the usual way.
Oh, please note that the Apache Tomcat Connector requires Apache HTTPD server. So if you don't want to install Apache HTTPD, then the Tomcat Connector is worthless to you.
Tomcat supports CGI so why not install php5-cgi?
I don't know whether it's possible to install Apache Tomcat without HTTPD, but I can answer your question partially:
By default, it's not possible. I don't know why, but package-installers (I used YUM at EC2) require you to install HTTPD too as a dependency of PHP. So if your package-installer requires this too, you need to build PHP from source (which isn't very hard though). Edit: I'm using FastCGI, 'just' PHP might not work, but it would surprise me though. (FastCGI works since, just like MySQL, you can install PHP-FastCGI on a separate server).
MySQL is fully independant. Since you can also install it on a separate server (db-server) without PHP and a HTTP-server, it's possible to install MySQL without HTTPD.

PHP and Django: Nginx, FastCGI and Green Unicorn?

I'm curious... I'm looking to have a really efficient setup for my slice for a client. I'm not an expert with servers and so am looking for good solid resources to help me set this up... It's been recommended to me that using FastCGI for PHP, Green Unicorn (gunicorn) for Django and Nginx for media is a good combination to have PHP and Django running on the same slice/server. This is needed due to have a main Django website and admin, but also to have a PHP forum on there too.
Could anyone push me to some useful resources that would help me set this up on my slice? Or at least, any views or comments on this particular setup?
I think one solution could be using a combination of PHP as apache module or through FastCGI and use mod_proxy apache module to do some reverse proxy to access your administration app running with gunicorn
You can have a setup like :
Front HTTP Server apache on port 80 : www.host.com:80
Backend HTTP Server gunicorn on another port : other.host.com:8080 or localhost:8080 publicly accessed with mod_proxy and url like www.host.com/admin/
Media HTTP Server : media.host.com, if it has to be on the same system you can use mod_proxy and run the NGINX server on another TCP port.
Note that you should not be able to get the best performance with the NGINX as a media server hidden behind apache with mod_proxy.
This part of setup relies upon the possibility of having more than one public IP adress on this slice.
I found this question and almost went down the path of using Green Unicorn myself. Just a note that uWSGI seems to give significantly better performance than Green Unicorn, see a set of benchmarks here.
Linode has a great howto for configuring uWSGI with Nginx on Ubuntu (it works fine on Debian too).
I'm now using this setup and very happy with it so far.
For the PHP part consider to install any PHP accelerator like eAccelerator or any other bytecode cache.
This is a more general article but could also be interessting for you.
For the Django part I have no idea / experience.
I've been trying to run django behind nginx with WSGI module. It runs OK and pretty fast.
You'll have to compile your own nginx, but it's really painless.

Equivalent of Mongrel/Webrick for PHP Development?

Is there an equivalent in PHP development to using Mongrel/Webrick during Rails development?
I normally use Mongrel on port 3000 to serve up my Rails app during development.
Its been a couple of years since I've done PHP development. From what I recall, the method was to run Apache on the dev machine during PHP development (which involved setting up virtual domain in Apache etc....).
Is this still the case or is there a simpler method these days. Unfortunately a quick Google did not yield anything of interest.
Before I forget, the dev environment is on Debian Lenny. Ubuntu solutions also welcome.
Thanks for any and all suggestions.
I found interesting answer on serverfault:
A built-in webserver will be included in a future version of PHP
You could take a look at lighttpd - that's quick & easy to install and configure with PHP.
If you're on Debian/Ubuntu it's fairly easy to set up an Apache environment. Everything you need is in Synaptic.
Below is how to do it in ubuntu, but if you want really easy, use a VM appliance:
LAMP appliance.
XAMPP may also be workable, but I have only used that in windows.
In ubuntu:
sudo tasksel
select LAMP, and that will set up apache, etc. In the middle of the install it will ask for the mysql password.
Files live within /var/www, but this can easily be changed in vhosts (I use a subdirectory of my home folder which is more often backed up). A quick check of the ubuntu online documentation should show you the correct files to edit (since I think there was a change after hardy).
Subversion and phpmyadmin are a good idea as well, as I'm sure you are aware.
a2enmod will enable mod-rewrite, etc, as that is not enabled by default

Categories