We've built a php application that we need to host on a Windows Server 64 bit platform (due to another software being present that we need to access).
However, our php application has been built on a linux environment.
Is there anything we need to be watchful of when running apache and this php application on a Windows environment?
Mostly any PHP script is cross-platform and normally you don't care about platform, but there are some platform-specific things like absolute paths (C:/www | /var/www/) and shell commands. If you don't use them then it will work. If not, it will not take much time for fixing.
There may be some good reading here on the official PHP documentation on running PHP on Windows.
Related
I'm developing a PHP app on windows, and so far I've been using the built-in web server of the php executable (https://www.php.net/manual/en/features.commandline.webserver.php).
However, the application now has grown, and it makes many php requests. On windows, the built-in web server does not allow forking and therefore can only answer one request at a time, which makes it very slow.
I'm looking for something very simple, just serve a local folder with php interpreter. It must be a portable solution, just copy/paste to another computer and it works, and it must run multithreaded in windows.
I've been trying the windows subsystem for linux, and running the server there, but I wanted to ask for an alternative. This requires too much installation, I really wanted something much more portable: just copy/paste the folder and run a .bat to start the server.
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 originally started developing PHP via WAMP/MAMP stacks. These work, but there are a lot of painful caveats to deal with.
More recently, I've begun working with other software stacks, like rails, that can run the server from arbitrary directories with a minimum of configuration, muss, or fuss. Just a simple rails -s or python -m SimpleHTTPServer 8000. (OK, the second one might not be simple).
Unfortunately, the rails one is for running a rails server. The python one sets up a very simple HTTP server. Neither one is appropriate for running PHP code.
Are there any alternatives out there to run a PHP based server from an arbitrary directory -- in this case, the development directory of the app I want to work on? I'd strongly prefer Mac OSX, but if there's a windows version available as well, I'd love to hear about it.
As of 5.4, PHP includes a built-in web server that can be used for development.
For example:
php -S localhost:8000 index.php
Documentation: Built-in web server
But keep in mind:
This web server was designed to aid application development. It may also be useful for testing purposes or for application demonstrations that are run in controlled environments. It is not intended to be a full-featured web server. It should not be used on a public network.
I'd like to develop a PHP application that users would download and then could run. The application will have a web service.
I assume they will need Apache, but my main question is what is needed for PHP to run on their machine? Is there something needed like the JVM in Java or the .Net framework in .Net? What is it called and how difficult is it for them to download (size, etc.).
Is anything else required that I did not mention?
Thank you,
They will need a web server with a compatible version of php. That's it.
Are you asking what is required to run a .php file on a windows machine? Do you mean like an executable or a web server script?
If like an executable need the php files:
Download the php installer from http://windows.php.net/download/, and then you can run php.exe script.php
If like a web site:
You need a webserver (like apache) and the php.exe files. I would suggest if testing to download a prebuilt webserver like XAMPP (download from http://www.apachefriends.org/en/xampp-windows.html)
It depends on the application. At a minimum it will need PHP.
Is there something needed like the JVM in Java or the .Net framework in .Net? What is it called and how difficult is it for them to download (size, etc.).
PHP. Presumably as difficult as it is for you, but it depends on the platform. OS X comes with it. Most Linux variants either come with it, or allow it to be installed with one command to the package manager. Windows users will have to download it seperately.
As for other things that might be needed…
If it has a GUI, it might need PHP-GTK.
If it expects to be accessed via HTTP then they will need a webserver which supports PHP. This could be Apache, IIS, or one of numerous other servers.
(It isn't clear if, when you say "The application will have a web service.", you mean "The application will access a web service" or "The application will provide a web service". If the latter, then a web server will be needed).
If you use any non-core modules, then they will be needed as well.
You need to describe your proposed application a bit better. Is there a reason the application must be in PHP? It may be possible, but it's certainly not common to code and distribute a desktop application written in PHP.
There are a few options.
If you are just writing a script (command line, etc) you don't need a webserver. You just need PHP installed to run it (there are even downloadable installers for it).
If you are writing a web-based tool, then you will need your users to have a webserver if they are meant to run it on their physical machines. And you don't need a framework...
just think of it as a Webserver + PHP as a plugin. Some webserver options: Apache, nginx, lighttpd
Try having users install WAMP, MAMP, or Zend Server CE all of which are free and come with both a webserver and PHP.
If you really want a deployable PHP script/tool, maybe look into something like PHPDock, which gives your users a single installable app (embedded server, php). NuSphere PHPDock
Honestly, it's not the greatest language to use for this type of deployment, but it's certainly fun to try to figure out! Sorry for not linking out also, don't have enough rep points for all of the links I had intended to supply.
Actually you can run php script without the need to have a webserver installed.
Just install php and then from command line:
$ php myscript.php
If you really want you can even build GUI application with php even though I would not suggest it.
Cheers Andrea
you could also try to use quercus.
Quercus is Caucho Technology's fast,
open-source, 100% Java implementation
of the PHP language (requires JDK
1.5).
This way you only will need a jvm+quercus. It also is platform independent this way because it runs in the JVM.
I wanted to know, is a server that supports ASP.NET and PHP on the same box common? wordpress/mediaWiki/phpBB3 seem like a nice combo but i am developing a ASP.NET project.
Most windows webhosts support PHP as well. Big drawback to PHP being lack of URL rewriting support. IIS handles multiple handlers pretty well, so running both concurrently isn't even particularly tricky.
Take a look at the Microsoft Web Platform if you want to have a drop in replacement, otherwise PHP will install into IIS as a SAPI module or, if you are using IIS 7 you can also run it as FastCGI.
php|architect is also giving away the May 2009 issue which is all about running PHP on Windows.
Using IIS will certainly help you.
Download Microsoft's PHP for IIS, here, http://www.microsoft.com/web/platform/phponwindows.aspx
This'll help you start.
Don't forget to edit php.ini either in C:/Windows, or whereever the application was installed to, in order to ensure everything is set optimally for you.
We know PHP hasn’t always run smoothly on the Windows platform, so we’ve now optimized Windows Server to support your PHP applications through a new component: FastCGI. FastCGI works as an interface between PHP engine and IIS, and it ensures that PHP runs much faster than with CGI and way more reliable than PHP ISAPI.
with IIS you can host Asp.net and PHP
Another option is the Phalanger project that integrates PHP so you can use it either separately or inside ASP.NET on IIS.
It is compiled down so it should run much faster than standard interpreted php.
Phalanger
You could use Ubuntu Server (which a variety of hosting providers offer), among other GNU/Linux distros. Take a look at http://www.google.com/search?q=ubuntu+server+hosting , then just get apt-get Mono for ASP.NET, along with PHP 5:
sudo apt-get install mono-xsp2 php5
and anything else you need.