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.
Related
I have a new CentOS server, plan to use it for all the php projects, currently i have many php 5.6+ projects & one php 7 project at two different servers. We knew we will upgrade the php version or even mysql version in future, so what is the trend or approaches for hosting different versions of php projects?
Did some researches about Docker & Rancher or install multiple PHP versions in one server and controlled by ngnix. But still not sure which one is the best approach, first option seems need to understand well about dockers or kubernetes, the learning curve will be higher.
Currently Cloud environment is not in my consideration. All these projects are system tool and applications (intranet, CRM), not eCommerce.
You should use PHP via FPM (FastCGI Process Manager), which is available for all recent PHP versions including the older releases like PHP 5.6. This is true at least for Ubuntu when using Ondrej's PPA. I guess there should be a way to achieve parallel PHP installations in CentOS as well.
With FPM you could use Nginx as well as Apache as your webserver. I would recommend Nginx, but it's up to you. There are plenty of tutorials for both of them.
Then, you would configure each virtual host according to your needs to use PHP 5.6 or 7.x respectively. With FPM pools each virtual host can be configured independently, even dedicated php.ini files are no problem.
Have a look at this blog post, which is quite to the point from my personal view.
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.
I am figuring out how to use PHP OpenId
I have cloned the repo to the ~/www directory. There are some examples in the php-open-id/examples directory which I wanted to run.
Specifically, I wanted to render the page php-open-id/examples/consumer/index.php in order to better understand the API. I started a server in the php-open-id/examples directory using
python -m SimpleHTTPServer 8000
and I navigated to localhost://consumer/index.php
But it didn't work. It shows a dialog box to save the file. What is the correct way to render this PHP file?
I have found a solution :
Run the server using
php -S localhost:9000
Mac OS
Just Visit your project folder
open terminal on that folder
and Run php -S localhost:9000
then you can see
PHP 7.3.24-(to be removed in future macOS) Development Server started at Tue Mar 30 11:58:49 2021
Listening on http://localhost:9000
After that you are able to access your application on http://localhost:9000
if your port is not available try to change port
You need to have a php server for serving .php files. The simple python server is not a php server and therefore it is just simply listing the files in the directory for download.
If you are on OSX 10 or above, it comes with apache which has php module present and can be setup to serve php file.
Tutorials can be found here
http://php.net/manual/en/install.macosx.bundled.php and here https://discussions.apple.com/docs/DOC-3083
If you would like to setup a dedicated server instead of using apache, MAMP is a good solution. Google It and see tutorials on how to set it up.
Update November 2022:
Unfortunately, PHP has been removed from MacOS. This is a brief tutorial which explains how to get PHP working in Ventura.
I personally dislike the idea to compensate the lack of PHP with the activities outlined in the tutorial. My solution was to install Docker and to run a proper NGINX+PHP container. I consider it to be cleaner, more flexible and better to maintain rather than faffing about with half-baked on-board stuff. But that's a matter of taste, I guess.
Also, as suggested in one of the answers, using the Python approach is not hassle free in Ventura, since it requires xcode to be installed.
In MacOS 10.x I have also been working with the on-board Python and PHP. Having lost those tools as standard installations is annoying.
I am confused regarding using XAMPP as a bundled software for PHP , Mysql , Apache.
My specific requirements are as below
Production server needs to Windows OS (as i need some third party tools to be integrated and need to execute that by command lines and those thirt party tools supports only Windows OS)
Need to make application in Zend Framework 2.0
The points in which i have doubts are ,
We can run this application in IIS , but is ZF2 have performance issue with IIS ?
Can xampp used on production server ?
is there any alternate way to install PHP , Apache , Mysql individually , and it should be secure and reliable method .
Any help is appreciated.
Thanks in advance.
The performance will increase if you select the right components on windows.
For instance, if you use IIS, then also use the Wincache PHP extension.
In general: it is possible to secure a development server stack.
Install the stack and alter the settings until you get a safe environment.
I would suggest to use Nginx as the webserver and MariaDb as the database.
You might choose InnoDb for performance reason.
There is also the option to add Naxsi Firewall Rules to Nginx to secure the server.
For high-performance, especially streaming you might try this: http://nginx-win.ecsds.eu/
It's also worth to look at WPN-XM (sorry, shameless plug).
Keep in mind, that updating the components of your production system is key to keep it safe.
Keeping a production server environment save is easier on Linux, where you have a proper package management tool (e.g. apt-get).
But afaik, WPN-XM is the only server stack with a software registry on windows, which allows that.
For running Zend Framework 2 you need PHP.
You might also consider tweaking the Nginx configuration and add some rewrite rules for short-urls. But a small config like this would suffice: https://stackoverflow.com/a/19734670/1163786
To answer question 2 from your comment: Yes, Nginx and Apache can work together.
Nginx will act as reverse proxy before Apache and will only serve static files.
All request for static files will be very fast and it will consume less memory for concurrent requests because Nginx is event-based.
Apache would handle the non-static parts/ dynamic parts.
"I want Apache , PHP and Mysql only , so is that will be supported by Nginx."
It's possible.
Static request would be handled by Nginx.
Dynamic request would be handled by Apache, so ZF2 is served by Apache/PHP.
XAMPP, with a "secure" config, can be used in a production environment..but it's not recommended. XAMPP is just a stack of software for easy deploying a fully developer friendly environment.
With IIS you can gain performance, cause of it's caching mechanisms.
I would install MySQL, PHP without any software stack like XAMPP and add the IIS to the Windows Server. Configure everything and you are good to go.
If you don't wont to use IIS or Apache, try to have a look to nginx.
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.