We are about to deploy a php5 / symfony / mysql application on a windows stack (windows 2003 server)
Our IT department doesn't have much experience administering any other stuff but microsoft technology, so I'd like to know what configuration would you propose for a production environment...
apache and php on windows?
php on iis?
etc...
the application should use integrated security (that means the have should have some way to find get the domain/username of the logged user, in classic asp is as easy as Request.ServerVariables(“AUTH_USER”) )
it would also be very useful if you could point me to documentation on the subject.
This question and especiually the links in it may answer parts of your question: Apache vs. IIS PHP performance comparison
PHP works fine with IIS, although I've only been able to configure it to run with the site in the IIS directory hierarchy. (c:\inetpub\wwwroot). I've never been able to get it to run with a virtual directory outside that hierarchy.
Also, assuming that IIS is running (it is by default in Server 2003), IIS and Apache can't share port 80. If you have both running on the same box, one or the other will get port 80, but not both.
Related
I do not understand fully how might the operating system have anything to do with something deployed on the web if you are not hosting the site locally.
Also, if I do not have a Linux machine, can I replace it by running WSL on my Windows PC? Or are there some fatal drawbacks that might point to not doing that?
No, you can develop PHP fine in Windows or MacOS.
You will have to install the right tools though like a webserver (Apache, Microsoft IIS, etc).
I good starting point is to use XAMPP.
PHP can be installed and run on Windows and MacOS as well as Linux and others - see https://www.php.net/manual/en/install.php for details.
Having said that, if you're planning to host the live site on a remote webserver which runs Linux, then developing that site on a machine which runs a similar operating system is likely to result in fewer unexpected compatibility issues when you deploy it to the live server. There are ways you can write the code in a cross-platform way (and 90+% of it isn't an issue anyway, there are just a few sticky areas mainly around files and paths etc), but there's always the danger of missing something.
If you prefer to develop mainly on Windows you could mitigate the above by having a virtual machine, or container, or by using WSL (Windows Subsystem for Linux), where you run tests against the site in a comparable environment to its live environment before deploying it to live. There are other resources already available such as this online which discuss the specifics of using PHP with WSL, if you want to pursue that.
No, you can do PHP development on any OS.
BTW I will suggest you to do learn linux in future.
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 started trying to create a website which uses PHP on an old computer (previously used by another programmer).
I wanted to test my PHP code without uploading it each time, so I downloaded Apache and installed it. I was starting to set Apache up when I discovered this computer already had Apache on it.
Now I had multiple versions of Apache, so I went into add/remove programs and got rid of Apache (which only showed up once in the list).
Unfortunately windows decided it would uninstall the old version and keep mine which was not functioning properly. Also for whatever reason it seemed to have kept a good few files from the old version, but not enough that I could actually use it in any way. I believe it just had some configurations files.
I thought I would copy my files from the new version into the old version and not replace anything so hopefully I would be able to run under the older configurations, but that didn't work.
At this point I just wanted to cut my losses, so I put all the versions of Apache in an archive so there was no way the computer could be using them. I also removed Apache from the windows startup and rebooted the computer after configuring one single version of the newer copy of Apache to supposedly run PHP.
The problem is upon startup I could immediately log in to localhost and apache was already running. Also when I opened Apache manually from the files I had left unzipped, it only gives me the option to start Apache (not an option to stop or restart implying it is not running) and when I click it, it says "The requested operation has failed!" which is less than helpful.
So anyway, I just want to be able to run PHP locally and now I don't feel like I can even successfully uninstall and start from scratch anymore. Does anyone know what I have to do to get this to work? Sorry for the long description, I wove such a tangled knot.
One way to solve is use a XAMP (Apache + MySQL + PHP) client like XAMPP http://www.apachefriends.org/en/xampp.html brings it all set up for you to use. The problem of conflict can be caused by any IDE (Netbeans for example) that already carries a version of Apache.
Try to configure config files of Apache case exist.
Assumption: Running Windows OS for development and linux for production environment.
My recommendation is to not mix the Windows and Linux worlds as while they can be made to behave after lots of work, it is usually more pain than good.
Instead, as a humble windows and linux user, download and install Virtualbox [https://www.virtualbox.org/wiki/Downloads], a free open source virtualisation tool.
Then download a linux distribution of your choice and install that into a new virtual machine.
Configure the linux tools inside linux and leave your windows machine relatively untouched.
A useful linux service to install would be Samba - windows file sharing - you can use this to edit your code in windows using any IDE of your choice, while saving directly to linux and testing through linux. When happy, upload from the linux system (again like any other file uploader) and all will be well.
If you are deploying to a linux based environment in your production service then this will help you avoid common mistakes such as case-sensitivity trouble and many others.
Building and running this system is free and it will help teach you more about the linux environment you are deploying to also.
Equally, when you don't have the virtual machine booted, there's no services lying around exposing your computer to possible local network threats and consuming resources - as opposed to installing Apache on Windows where it will be using some resources all the time.
I have a VPS account on which I set up a Linux server to host some customer websites, and to upload "previews" of websites before publishing them to the production server.
I develop the websites on my own machine (Windows) and do most of the testing there. Because of the difference in platform, sometimes problems appear on the Linux host, and I could use a debugging interface on that...
My question is how safe is it to have xdebug on a remote public server which would also be used for hosting production websites? Is it possible? Recommended? What do you think?
Thanks...
xdebug is perfectly safe on a remote instance as long as you set the xdebug.remote_host variable. Otherwise it is a MAJOR secuirty problem because it would allow the attacker to view any variable in memory during runtime. It could be used to obtain your mysql login or any other secret variables you may have.
edit: A VPN is a good solution to keep leaking sensitive data over the net in plain text.
XDebug is possible, but not recommended on production, as it can slow your application. You should think the other way round and use linux as a development machine. If you can't (or don't want) to switch to Linux you can stay on Windows and use a virtual machine as a linux development server. If you do, try to be as close as you can as the production environment : same linux distribution, same version of php.
I work on linux and so does everyone in my firm, and the recommended solution in my firm is LXC, a very light virtualization solution. By light I mean it won't take ages to refresh your working tree in your IDE, because you don't have to mount the working tree on the host: the guest filesystem is a subtree of the host filesystem.
This way, I still can have an up-to-date fedora linux for my desktop, and develop on a debian with php 5.2 if I need to (and I need to). The thing is, when the virtual machine is configured for a given project, I can archive it and send it to a colleague that joins the project. This makes starting projects easier for newcomers.
I just got my self a new laptop, it runs on windows 7 and i am in deliberation what dev environment to set up.
I have most of my life used wamp set up, on windows machines for local dev environments. Here i recently installed IIS and it looks very convenient to set up sites and so on and so forth.
So I am thinking of installing php and mysql and runing local dev environment via IIS. The question is as I am fairly new to IIS. Are there any draw backs to running php/mysql via IIS in local dev environment. What are my limitations, will running php/mysql create any limitations if any that will hinder development and might effect deployment.
Back in a day i had some exposure to ISS with php running on server, it was long time ago, but php was not completely supported and some dev issues arose.
Thank you guys for any input. Greatly appreciated.
Usually it is a benefit if you can use identical environments for development and production. So the question is:
On what stack do you deploy you applications?
I personally believe that apache on windows is still a better solution to develop PHP. Reasons:
much more documentation about the interaction between PHP and apache (for example url rewriting, proxying, etc...)
apache is the de-facto standard for PHP, so if you plan to deploy to apache later, you will face less potential problems due to platform differences (also regarding the rare subtle bugs which can plague ported software)
I find it easier to get meaningful error messages out of apache than from IIS
I try to install the same PHP and Apache versions I will be deploying to, so the chances to have differences is minimal...
I would go for Apache - mainly for the .htaccess functions - rewriting etc are slightly more tricky in IIS and you may not get as great portability when transfering to a LAMP setup.