PHP website, should I develop into a Linux distribution instead of Windows? - php

In few months I start a project in PHP and I am hesitating to do like usual : develop on my Windows Vista 64bits machine. Since I know few things on Linux, I think it can be a good way to learn by working on a Linux distribution.
Do you think it's a good idea or not? I would run a VirtualBox with Ubuntu (on my Vista64bits). I was thinking to install XAMPP to be able to develop in PHP.
If you think it's a good idea, feel free to suggest me some tutorial about what I should know with Virtualizing an OS, or Linux/dev.
Update
I have build many website in PHP with Windows, the question is more about if it's a good way to start learning Linux by developing on it via a Virtual machine? I have 4 gigs rams, will it be smooth if I install Eclipse in the Virtual Machine? etc.

You should really develop on the same platform where you are going to deploy. I'm not saying it is bad to do differently, but it can save you some pain in the long run. OTOH, you might learn faster about platform differences that way. So, the main question is: do you want to have a production system running ASAP without much headache? Or, you want to spend some time and make some effort to learn how to develop cross-platform stuff?
And yes, there are differences. For example, case sensitive and case in-sensitive filenames. Then, some PHP functions use native C functions that have different implementation. For example, printf() does not produce the same amount of whitespace for some of the types. Resolution of time measurement (milliseconds vs microseconds) can be different, etc. Then, you have different ways filesystem permissions are handled. These are just some recent problems I've found that I can remember off the top of my head.

PHP should be the same on any platform - so where you develop shouldn't matter.
However, in my experience and observation,more sites running PHP are running on Linux than Windows.
Getting Apache and PHP setup on something like Ubuntu or Fedora is a cinch, and testing everything is pretty simple, too.
Also, when you go live with your site, what platform will it be running on? I prefer to do development on the platform it will be running on whenever possible.

Personally, I don't think that for local production you should be using a VM. Would you be running your IDE inside the VM too?
If you are aware enough of the pitfalls of moving between Windows and Linux environments (such as case sensitivity and permissions), you should have no problem developing on Windows and deploying on Linux.

Working on a Linux distribution is defnitely the easiest way to learn it. And setting up some servers and doing some dev work is an excellent start.
Virtualising Linux is also really easy. I've done it quite a few times and it's really obious. Also, going this way will ease you into using Linux, much better than just jumping in and finding out your wireless card is unsupported like I did :)
As for PHP development on Linux... I've done some PHP coding on Windows and on Linux and I can tell you there's very little difference between the two. I use Eclipse on both platforms and Apache &MySQL / XAMPP. The only major difference I've seen is that Linux is much more finicky about permissions and case.

PHP is not the same on all platforms, and until very recently the windows versions had problems which were not found in the Linux versions. Lots of useful features are *nix specific.
I would echo #Milan's sentiments about developing in the deployment environment. You learn a lot more about the deployment environment by doing so too.
On the VM issue, if you want all your Windows tools and your windows machine, setup a linux server in your VM (can have a GUI if you want, but you're going to mainly use it as a server). Set it up so that windows can view the apache install running in your VM and you use samba shares to access the vm's files like a drive in windows. That way, you develop in windows but are testing deploy / setup on a running linux server. While two devs at my shop run Ubuntu, a third needs to use Photoshop and various other bits of windows software all the time, so she uses this method of running a server in a VM but developing from windows.
Oh, and if you're running on Linux, don't use XAMPP! A few simple commands will have you up and running and you'll get a much better understanding of your deploy. XAMPP is fine, but it's for OS's that don't have Linux's package management.

while XAMPP works great, running Apache and PHP on Linux is a given; while on Windows it's something extra you have to do... and support. Also, most parts of the stack are far more optimised and mature for a POSIX environment. The database engine(s) performance is particularly sensitive to the available primitives.
Most OSS runs on windows, but it's a round peg whammed on a square hole.

On principle, I would advise against "learning by doing" in a real project - unless it it really small, or you have doen very similar projects before, so that the learning curve on project related issues would not be steep. In that case you may have ressources free for learning about the developing environment.

Generally I like the Linux environment better than Windows. Mainly because all the CLI tools you would need are provided and Bash beats cmd.ext any time. But with Cygwin I find even Windows a comfortable development environment.
Regarding PHP development I can't really see how it would be much different. Maybe there is some benefit in being forced to make the code more portable (things like line endings, forward slashes in filenames and such) if you use booth systems.
As a desktop or workstation there isn't much difference between the two. I find that the biggest differences lies in how you administer them, but hopefullt you have some other people doing that for you.

In my opinion you needn't to develop in a linux distribution.
Web Development can be done from any OS. I don't know, why you are programming for the web... as a professional? for your personal homepage?
I think, it's enough to get some free webspace running a PHP Server and to upload your files there... it doesn't take you much time and there are less things to manage.
a german student ;)

Use the OS your deployment server will be running, and it is highly probable to be linux. I have recently seen a deployment gone ultra bad cuz it was developed using wampserver and deployed on CentOS. With major differences in apache and PHP config. So know your deployment server and match it as closely as possible.

Try creating a development environment using VmWare Player. I have several Linux environments that I run on my Vista laptop. You could also just dual boot. I use Ubuntu, it is easy.

The side effect of developing inside a VM: more overhead and eventually the needs of additional tools to make the development more comfortable.
Often people need special tools for their development like Photoshop or some vector design tools not available on Linux. If the working copy of the project is inside the VM, it makes sense to have easy access to it. So you will setup SAMBA (which makes often problems with the login from XP) or setup SSL(SFTP)/FTP.
Also you must learn how to use networking with the VM (NAT, bridging, port forwarding).
On the other side, developing on another platform as the target can give some headache. I found myself often confused with .htaccess files for password protection, because oft the different path on Windows/Linux. If you forget to change this entries later on the production server, you have a problem...
A better solution: use the best of both worlds.
A VM eventually running later headless (no gui, more like a "remote server") with Ubuntu/Debian/FreeBSD) and only running the needed servers (Apache, MySQL, FTP, SSH...).
Eclipse or the other development tools on Windows/Mac.

5 years later: My opinion is to use the Linux solution. There are many advantages for using PHP in Linux. The primary reason is the level of help available from the community. PHP seems to be optimized for Linux environments as well.
There is also safety in numbers as an overwhelming number of sites are hosted and run with LAMP solutions. There are a wide range of frameworks and CMS' that run best on Linux with Apache2.
Make your life easier and start learning PHP straight away.

Related

Using PHP and MySQL to develop website

I want to develop a professional website using PHP and MySQL. Can i do it in Windows 7 (64-bit) or i need to install linux based OS. How to go for it.
You can run an AMP Stack (Apache, mySQL, PHP) on Windows no problem. I have been doing this for ten years now. Running on Windows 7 64-bit is also no problem.
There are several pre-packaged installers available. My favourite is XAMPP. They usually allow full customization where needed.
You can also download the stand-alone binaries of each product and install them manually. Makes for very, very good learning but is more work.
Yes, you can.
Though a platform is the least thing you will need...
As mentioned it is possible to develop Php and MySQL sites quite happily on Windows using something like XAMPP, even if they are later to be deployed on a Linux web server and I know a lot of people do this and it works great for them.
However I have found in the past you can run into problems later on this way. For example, a lot of people who have only used Windows in the past can get caught out by case-sensitivity in Linux. So your site runs great locally but then you start getting lots of 404 errors when you go live because for example, mypage.php is not the same as myPage.php any more.
At the other end of the development spectrum, you can achieve some really powerful functionality when you start to work the server a bit more - things like video encoding or audio conversion are possible using PHP (with a bit of help from some other apps) on both Windows and Linux but the ways that you would do it are different therefore your development environment becomes much less useful and again you run the risk of putting something live that doesn't work, even tho it runs fine when you test it locally.
Personally, I think it is always best to develop on as close an environment to the intended production server as you can to avoid any nasty surprises when you go live.
Develop on the same platform you are going to be deploying to (if possible). It'll make it extremely easy to deploy with less room for possible error.
Installing the 64-bit versions Apache/PHP/MySQL on Windows 7 is a bit of a pain, but you can easily install the 32-bit versions using XAMPP (as mentioned by Pekka) from apachefriends.org
For Windows you can use a light package, which content php, apache, mysql, pear. link text

Quickest way to run a linux dev-environment inside windows

I get more and more trouble from running WAMP on my XP computer to solve my local development needs. It feels like as more and more things just go wrong or could not be installed at all to a Windows version of PHP.
I have been looking for an alternative and found AndLinux plus this link.
Would it be a good idea to get an Ubuntu box running virtually on my XP computer to simulate the production web server?
Yes, in case you don't want to use Linux as desktop OS running it virtually in a VM is quite practical. by using the VM's "shared folder" support you can use the same directory for local development using your Windows IDE and serving requests from the Web Server inside the VM.
In the past - ~5 ears ago or so - I used coLinux and wasn't too happy. On modern systems a small Linux VM just works well.
Regarding virtual machines:
Advantages
Isolation: Everything in the VM is completely separate from the host; no cross contamination.
Easy Testing: Most VM software have snapshot and rollback capabilities.
Mobility: If you wanted to, you could easily move the self-contained VM over to another machine.
Disadvantages
Inconvenient: File transfer between the host and guest. Using "shared folders" alleviates this somewhat.
Virtual Hardware: Not good for graphics-intensive programs or other software that relies on certain hardware features (which shouldn't be a problem in this case).
Generally speaking, the closer you can get to the production environment the better. Developing on Windows isn't wrong, per se, but you need to be able to test in an environment which matches production.
If you have the resources on your PC to do it in a VM, that will work just fine. If you don't, running it natively or using a remote server somewhere would also work.
Hope that helps!
Thanks,
Joe

what are the Advantages and disadvantages of running php on windows

the linux environment is natural to php,
what are the Advantages and disadvantages with run php on windows ?
Are there some limits in windows ?
what is the best (lamp/wamp) in term of performance ?
thanks
It's not so much that it is natural on Linux but the tendency was for developers to use PHP in the earlier days as the ASP on Linux. For years MS never even mentioned PHP and never gave it any support and so most development work happened in the Linux arena with the result that it is more advanced as it has simply had more development hours spent on it.
Again in the early days it was more difficult to get PHP running on ISS but apache makes it easier but then you need to install it. I rarely develop on Windows but i think the environment has changed for the better with more integration.
The emergence of packages such as XAMPP and WAMPP make installation and running a lot easier but as Karsten says not really for the production environment as they are not geared for it in performance and especially on the security level, because of this i also doubt if they are geared for performance, they are geared for ease of install and development.
Case sensitivity can be a problem if you develop in Windows and later move to Linux.
Well, there's the obvious problem of trying to compile PECL extensions on a Windows platform, and the problems associated with not having sendmail running and trying to use the mail function.
Other than that, as long as the source has been ported correctly, it should do fine.
There is an Site from Microsoft for this http://php.iis.net/
For good Performance also check out http://www.iis.net/expand/fastcgi
I can't give you performance statistics. Would guess that an extremely stripped-down version of Linux or BSD is best from that standpoint.
There are two main disadvantages of Windows. One is that you're likely to have to build some of the lesser-used extensions yourself, if you need them. (There are Windows builds of the common stuff - APC, etc. - available on the net for 32-bit, though. For 64-bit Windows... well, it's a jungle out there.) The other is that you're going to be in the minority, so expect all the things that go hand-in-hand with that. (If you run into configuration difficulty, for example, there will probably be fewer people able to help you.)
The advantage is that (especially if your favorite IDE is something like Visual Studio) you can run all your favorite Windows stuff on the machine. This is really only an advantage if this is, say, a development box - something you're going to use for other purposes as well, not just as a server.
If you are working in an windows environment, running your application/php scripts there makes a lot of sense if you want to debug locally.
I wouldn't use WAMP for production environments, because its nature is in linux imho.
XAMPP solves the sendmail issue amphetamachine is talking about by installing mercury mail.
It also comes with prebuilt xdebug, apc and memcache modules, which are for me the usual pecl compiled extensions.
An obvious problem with PHP on Windows/Apache is not being able to configure PHP APC for current versions of PHP. Hence, no way to create elegant file uploads with progress bar.
Most and main PHP developers (I mean, those that create the language) seem to work under Unix platform. Also, almost all Linux distros take care of building, packing and fixing PHP to suit their systems. And this also applies to auxiliary software like Apache. As a result:
There's always some functionality that doesn't work on Windows, e.g. strptime() or has more bugs.
Windows binaries are not optimized for your system. You can't even get 64 bit binaries unless you compile them yourself.
The MSI installers are not as polished as they should.
Installing PECL extensions is very complicate since there aren't official DLLs.
Of course, there's also Windows-only functionality in PHP, such as Windows only extensions or third-party extensions like the Microsoft SQL Server Driver for PHP, or functionality that's way easier to use under Windows, such as ODBC.
Talking about performance itself, it's difficult to make a fair comparison. The operating systems themselves have very different hardware requirements and it'd be misleading to compare optimized Unix builds with generic Windows binaries. My intuition says that the decision of choosing either platform should be based in other considerations, such as budget, required features or ease of maintenance.
There are many quirks across platforms with PHP, and I don't recommend switching between LAMP / BAMP / SAMP and WAMP / WIMP.
For one thing, permissions are completely different -> usually being a lot harder to work with in Unix/Linux (as Windows doesn't seem to care all that much about permissions as far as I have ever seen). This is a good thing, in my opinion, though (I'm relatively safety paranoid).
Here are a couple more things that differ:
http://php.net/touch (could't change windows directory modified times until 5.3)
http://php.net/flush (still can't flush or ob_flush from some win32 machines)
Both have system specific issues that were just SUPER recently worked out or haven't been fixed yet...

Does most professional PHP development take place on PCs or on Macs?

I'm trying to determine how likely it is that my next job will involve the use of a Mac/PC if I am hired as a PHP programmer. With Rails, most shops seem to develop on the Mac. I'm wondering whether the same is true of PHP.
Most PHP development houses will have you debug and run your code in a testing environment that mimics the production environment. This way you are able to use the OS/editor/IDE of your choice and it should all come out okay. One of the advantages of PHP over other web service languages (ASP.net, et al.) is that it is multi-platform at its heart. I would be more worried about things like what version control system are they using and what is their production environment like than what desktop OS you will have to use, as these are the variables that get locked in stone while your desktop machine isn't.
The simple answer would be more people use PC's so more developers develop PHP on a PC. I use Linux.
They all can do it very well, I would just make sure you are comfortable with all 3 operating systems. My office does almost ASP.net development exclusively, and the guy next to me develops on a Mac!
Basically, as a professional, you need to be able to hop on anything and be able to develop on it.
When I did PHP, I developed on XP, deployed on Linux, FWIW.
Irrelevant. I use Linux and Windows, but it doesn't really matter, because on both I use the same editors (ActiveState Komodo and Zend Studio), both of which are also available for Mac.
There is no limiting factor in regards to the language itself. We're a pure PHP development environment and all of our developers use Macs. But it wouldn't be a problem if any of them used Windows boxes or Linux boxes to develop on. The only problem would be if the company had development tools that had to be run on a specific platform. The short answer is: it depends on where you get a job.
I have seen a few companies say in their job advertisement that they use Macs to develop on. In reality though I think that was just put there for the "cool" factor.I am willing to bet that they would allow you to use whatever you wanted to develop PHP on as long as your PHP + Apahce/IIS/whatever configuration is not a million miles away from what is used on the production servers.
I don't think it should matter all that much when it comes to web script programming like PHP or JavaScript, unless you are partial to a specific IDE or something. I do all of my web programming code in a notepad editor, but it does not seem like it would be all that hard to code just as well on a Mac or a Linux box or even a Blackberry.
I do all my development at work on Windows XP.
For PHP development at work I use Nusphere PHP Ed on Windows. It has a lot of useful features like debugging and code intelligence, but I've found it to be a little unstable for software that costs money. Still, if you don't mind it freezing up every so often and want to pay for it, it's a great PHP IDE for Windows.
My personal favourite is Eclipse with the PHP IDE Project plug-in (there's a few options), if you use that it doesn't matter which OS you use (it works on PC, Mac and Linux).
I would say PHP is more on windows as it has been around much longer and likely spread to more development environments.
I do most of my heavy development on Linux. If you are running Linux servers, like we do, and your site uses specific services, it's best to keep your development platform as close to your target production server.
I use a Mac to do personal development, but I'm not as comfortable with that as I am on Linux.
I bet quite a few people use Windows for web development as most people use windows full stop, and I see no reason why not, if that's what they prefer. I don't.
At the moment i am doing all my PHP development on a macbook using a Centos Virtual box. Its great as you do not have to install anything on your actual mac apart from Virtual box as its Free. It takes around a 1 or 2 hours to set up the guest correctly and you can be on your way. From there i am using Eclipse PHP for the actual code development.
I like to work on Windows 7 and the IDE is Sublime Text which is also convenient for Mac users as well. OS is really doesn't matter for PHP development as its multi-OS dependent.
My PHP Environment Setup:
Windows 7
Sublime Text
Xampp Server
GIT

PHP Deployment to windows/unix servers

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.

Categories