I a have an application that is written in PHP and runs on Linux using LAMP stack and in Windows using XMPP stack (The PHP functions are called from Apache). I have requirements to kick off some activity periodically from the server side.
Currently I have the user use cron in Linux and and task scheduler in windows to kick off a PHP script which in turn calls the webserver to start the activity.
Both (Linux Cron and Windows Task scheduler) these options are cumbersome during deployment (Even with a detailed instructions it ends up incorrectly setup). So I am looking for a platform agnostic way to schedule async jobs.
Looking around, I see things like Celery (which seems more suited for Python). Are there any other facilities that can be used to achieve this function?
Can you explain what is your deployment model? I have worked with many deployments, where the post deployment sets the cron job in Linux properly. I am not familiar with Windows deployment, but that wont be difficult if you have proper deployment model and scripts to do this. There are many ways to do 99% reliable post installations and do more than cron job setup. But without knowing your deployment model i could not suggest you proper options.
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'm tasked with maintaining several web apps, all of them using the LAMP stack. Some of them run on PHP 5.6, some of them on PHP 7.0, some using Wordpress, some using Symfony... Ideally, I'd like to set up at home testing/development environments that are as identical possible as the production ones.
I've been investigating Docker (warning: total novice here!) to see if it suits my needs. I'll be working on Windows and Mac, and I'd like to have in my machine several LAMP environments, each of them with their version of PHP/MySQL/etc., isolated from each other and all of them running in the same VM (because otherwise I might as well just use what I'm familiar with and set up different VMs). Can Docker do this?
(Sorry if this sounds like a silly question: reading about Docker, my impression was that the container philosophy allowed you precisely to do what I described without wasting resources like with VMs, and yet, I haven't found any guides about running more than one LAMP environment at the same time).
Php Docker Stack
Php Docker stack to run Php Apps in Production and Development, using Docker Compose Services to run any Php version, Databases, Cache, Queues, Logs and much more...
From now on, no need to keep messing around the Operating System to have a full development stack ready to build our awesome Php Apps.
It can be included in each php project via composer:
https://packagist.org/packages/exadra37-docker/php-docker-stack
Or if you prefer you can clone it directly from here.
It comes with some default images for each service but is all configurable via .env, thus we can pass any docker image we want for any of the supported services in the docker compose file.
Php Docker Stack Services:
Http - Nginx, Apache, etc.
Php - Php-Fpm.
Database - Perconna, MariaDB, Mysql, etc.
Cache - Redis, MemCached, etc.
Logs - Logstash -> ElasticSearch <- Kibana.
Queue - Beenstalkd, RabbitMQ, ActiveMQ, Apache Kafka, etc.
Cron Jobs - Just to schedule cron jobs.
Dev CLI - Access to the container shell.
Database CLI - Like the awesome mycli propmt for mysql.
Cache CLI - Like the redis cli.
I was using it daily at my old job for development.
I am the author of it and I have some local enhancements that need to be polished and merged upstream.
Feel free to try it and reach to me for any doubts or feedback.
Okay, after a lot of time, I thought I should share the solution I found and that I'm currently using: devilbox. It's awesome, and once you get your head around it, it's incredibly powerful, flexible and customisable.
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 am developing a site locally using xampp. I would like to configure cron, so the dev environment is the same as the production environment. However, my system is windows vista. Is there any way to do this, or am I forced to accept that my dev and production environments will be forks?
I would highly recommend looking into Cygwin. I was using that when I wanted linux/unix utilities on Windows. It supports Cron as well.
Jacob
Btw this is a really good question...there are a lot of good scheduled task apps out there. The 1 I liked is Visual Cron at http://www.visualcron.com/
Running a scheduled task, is a very tough thing for web server/web apps to do...Because they have to check every x seconds or minutes to see if a task needs to be done, which can suck up cpu cycles for your web server/apps.
Which is why i prefer using an os based task scheduler or os task scheduling software, better performance I believe.
One trick that I had learned, was using php's -f command to create scheduled tasks without having to open a browser window, then it can run tasks...
On window's systems the only other way was opening up ie/firefox/opera whatever to run your web-based task..
good luck!
You could create a windows scheduled task to run cron.php (or call it in the browser).
We have various php projects developed on windows (xampp) that need to be deployed to a mix of linux/windows servers.
We've used capistrano in the past to deploy from windows to the linux servers, but recent changes in architecture and windows servers left the old config not working. The recipe works fine for the linux deployment, but setting up the windows servers has required more time than we have right now. Ideas for the Capistrano recipe are valid answers. obviously the windows/linux servers don't share users, so this complicates it a tad (for the capistrano assumption of same username/password everywhere).
Currently we're using svn-update for the windows servers, which i dislike, since it leaves all the svn files hanging on the production servers. (and we still have to manually svn-update them on windows) And manual updating of files using winscp and syncing the directories with their linux counterparts.
My question is, what tools/setup do you suggest to automatize this deployment scenario:
"Various php windows/linux developers deploying to 2+ mixed windows/linux machines"
(ps: we have no problems using linux tools or anything working through cygwin, we simply need to make deployment a simple one-step operation)
edit: Currently we can't work on a all-linux enviroment, we have to deploy to both linux and windows server. We can start the deploy from anywhere, but we'd prefer to be able to do it from either enviroment.
I use 4 different approaches depending on the client environment:
Capistrano and similar tools (effective, but complex)
rsync from + to Windows, Linux, Mac (simple, doesn't enforce discipline)
svn from + to Windows, Linux, Mac (simple, doesn't enforce discipline)
On-server scripts (run through the browser, complex)
There are some requirements that drive what you need:
How much discipline you want to enforce
If you need database (or configuration) migrations (up and/or down)
If you want a static "we're down" page
Who can do the update
Configuration differences between servers
I strongly suggest enforcing enough discipline to save you from yourself: deploy to a development server, allow for upward migrations and simple database restore, and limit who can update the live server to a small number of responsible admins (where the dev server is open to more developers). Also consider pushing via a cron job (to the development server), so there's a daily snapshot of your incremental changes.
Most of the time, I find that either svn or rsync setups are enough, with a few server-side scripts, especially when the admin set is limited to a few developers.
This will probably sound silly but... I used to have this kind of problem all the time until I decided in the end that if I'm always deploying on Linux, I ought really to at least try developing on Linux also. I did. It was pain free. I never went back.
Now. I am not suggesting this is for everyone. But, if you install VirtualBox you could run a Linux install as a local server on your windows box. Share a folder in the virtual machine and you can use all your known and trusted Windows software and techniques and have the piece of mind of knowing that everything is working well on its target platform.
Plus you'll be able to go back to Capistrano (a fine choice) for deployment.
Best of all, if you thought you knew Linux / Unix wait until you use it everyday on your desktop! Who knows you may even like it :)
Capistrano is the nicest deployment tool I've seen. Do the architecture changes make it impossible to fix the configs so it works again?
Why you can't use capistrano anymore?
Why you dislike svn-update?
What things in your app requires an special deployment ?
You can setup svn:ignore property on configuration files, so that svn update doesn't erase them, and then use svn export /target/path/ to get rid of .svn files in your Subversion repository.