473,799 Members | 3,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Portability of PHP from windows to Linux

Hello,

I am new to the open source environment. We have to develop a web
application using Apache/PHP/MySQL on Windows (A component that we want
to use is available only on Windows for now). Later when the component
is available on Linux, we would like to move the code.

The web application is a simple one - collects data, does some simple
validations and stores in the database.

I would like to know how portable the code will be. Do we need to
rewrite a lot of code when we move from Windows to Linux? What are the
issues I need to be aware of?

Thanks for your help,
seth

Aug 30 '05 #1
8 2093
Probably not too bad. The main thing would be adjusting any hard-coded
paths to files -- both in the code and in php.ini (since the filepaths
in Linux use / to separate directories). You will probably need to
check permissions on directories and files that the application
requires.

The other place you might run into trouble is connecting to any
databases -- only because modules and extensions are loaded differently
under Linux than they would be on Windows. That's more of a PHP setup
issue than a code problem.

There are probably also differences in how you might interact with the
operating system -- especially the file system. Opening and writing to
files, etc. might have slight different requirements or limitations
under a different OS.

I'd say that it shouldn't be too difficult, but be prepared to spend a
little time adjusting your PHP configuration and make some minor code
changes. Above all, test it first!

Aug 31 '05 #2
seth wrote:
Hello,

I am new to the open source environment. We have to develop a web
application using Apache/PHP/MySQL on Windows (A component that we want
to use is available only on Windows for now). Later when the component
is available on Linux, we would like to move the code.

The web application is a simple one - collects data, does some simple
validations and stores in the database.

I would like to know how portable the code will be. Do we need to
rewrite a lot of code when we move from Windows to Linux? What are the
issues I need to be aware of?

Thanks for your help,
seth


If it is simple what is the component that will only work on Windows?

It is usually the case that all of the really nifty components are more
readily available on Linux, because PHP is really just an interface into
the many libraries available on that platform.

--
Kenneth Downs
Secure Data Software, Inc.
(Ken)nneth@(Sec )ure(Dat)a(.com )
Aug 31 '05 #3
seth wrote:
I would like to know how portable the code will be. Do we need to
rewrite a lot of code when we move from Windows to Linux? What are the
issues I need to be aware of?


The code I wrote that works fine on my local EasyPHP testing server
(Windows) failed on a commercial server (Linux) because table/field
names in the MySQL database were apparently case sensitive on the server
(Worked fine here). Watch out :). All lowercase names is a good standard.

Cheers,
Nicholas Sherlock
Aug 31 '05 #4
NC
seth wrote:

I am new to the open source environment. We have to develop a web
application using Apache/PHP/MySQL on Windows (A component that we want
to use is available only on Windows for now). Later when the component
is available on Linux, we would like to move the code.

The web application is a simple one - collects data, does some simple
validations and stores in the database.

I would like to know how portable the code will be. Do we need to
rewrite a lot of code when we move from Windows to Linux? What are the
issues I need to be aware of?


Generally, PHP code is portable with zero rewrites, unless OS-specific
extensions are used. For example, shared memory and semaphores are not

available on Windows, while COM is available only on Windows. So an
application relying on shared memory or semaphores will not work under
Windows, while an application using COM will work only on Windows.

Check the documentation for extensions you are using for any
OS-specific
notes.

Cheers,
NC

Aug 31 '05 #5
Following on from seth's message. . .
I would like to know how portable the code will be. Do we need to
rewrite a lot of code when we move from Windows to Linux? What are the
issues I need to be aware of?

Not a big issue, in fact I would say just the same as going from one
version of something to another: There might be odd niggles which cause
frustration but nothing to cause you to do any serious rewrites. You'll
just find that something that worked fails possibly with an error and is
fixed by trivial tweak to paths, filenames and permissions. This might
be due to different versions of PHP, mySQL, Apache and sillynesses with
config files.

Bottom line is assume it will work as-is but be prepared for some
tweaks.

--
PETER FOX Not the same since the statuette business went bust
pe******@eminen t.demon.co.uk.n ot.this.bit.no. html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.dem on.co.uk>
Aug 31 '05 #6

"Nicholas Sherlock" <n_********@hot mail.com> wrote in message
news:df******** **@lust.ihug.co .nz...
seth wrote:
I would like to know how portable the code will be. Do we need to
rewrite a lot of code when we move from Windows to Linux? What are the
issues I need to be aware of?


The code I wrote that works fine on my local EasyPHP testing server
(Windows) failed on a commercial server (Linux) because table/field
names in the MySQL database were apparently case sensitive on the server
(Worked fine here). Watch out :). All lowercase names is a good standard.

Cheers,
Nicholas Sherlock


I have had the same experience. The bigger problem was different versions of
PHP and MySql on the Windows and Linux servers. Usually the Linux servers
seem to be running newer versions.

Al Kolff
Aug 31 '05 #7
On 31 Aug 2005 00:43:46 -0700, "NC" <nc@iname.com > wrote:
For example, shared memory and semaphores are not
available on Windows


Actually shared memory is available through: http://uk2.php.net/shmop
The example script runs fine here on Windows 2000.

But presumably you were referring to the System V IPC stuff.

--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Aug 31 '05 #8
People,

Thanks for all your replies. The information you have provided is
really helpful. I really appreciate you all for taking time to respond.

It started me thinking.
Can PHP call APIs in a 'custom windows dll' as effectively as ASP?
Looks like there could be some issues here, based on some of the posts
I saw.

Thanks,
seth

Sep 1 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2154
by: Google Mike | last post by:
No, this isn't what you thought the subject of this post meant. It's better. I just wanted to share with you something I did that makes editing PHP and carrying your projects back and forth a little easier. (That's what I mean by portability in this case.) I often go between my day job and my home, carrying code. I used to either email it to myself and pick it up, or FTP it to my website, or risk everything and put it on a floppy....
5
3698
by: Nick Mudge | last post by:
I have PHP 4 running as a module on windows XP, I also have MySQL and Apache 2 running on windows XP. If I write a big website on my computer that has XP and I use PHP, MySQL and Apache 2, and HTML and Javascript to write my web site, how hard will it be to transfere my whole website from my home computer to a hosting company that I find on the web. Does anybody know how hard the portability issue would be? Are there a lot of...
7
1623
by: fabio de francesco | last post by:
Hi, I'm not a professional programmer, but I've been writing C/C++ and Ada programs for a few years on GNU/Linux without ever concerning on standards and portability to other OSs. I've always noted that when I write code I must use lots of platform specific system calls (POSIX and X/OPEN). Often I found myself using threads and concurrent processes with some sort of IPC. Some time I need some socket API. When I just want to open a...
3
2777
by: Walter Dnes (delete the 'z' to get my real address | last post by:
I'm doing some stuff at home that I can't justify doing on work time, mostly to learn C programming. But it might possibly be useful at work. I run linux at home at home and Windows at work. One portability question arises. Given fgets() on a file... linux file with a line with 22 columns of data plus CHR(10), strlen() of the resulting string = 23
93
3688
by: roman ziak | last post by:
I just read couple articles on this group and it keeps amazing me how the portability is used as strong argument for language cleanliness. In my opinion, porting the program (so you just take the source code and recompile) is a myth started 20-30 years ago when world consisted of UNIX systems. Well, world does not consist of UNIX systems anymore, but there are 100s of different systems running in cell-phones, DVD players, game consoles...
25
352
by: Stephen Mayes | last post by:
From lurking on this most excellent newsgroup, I have garnered that an expressed benefit of having a standard is portability of code. I see a lot of open source endeavors that inspire my awe, but I can't see how the authors get paid, so they don't much inspire my ambition for pursuing perfection, which is inate nonetheless. In real life, how many of you knowledgable people are ever actually consigned to write code that will port to very...
35
5482
by: Sunil | last post by:
Hi all, I am using gcc compiler in linux.I compiled a small program int main() { printf("char : %d\n",sizeof(char)); printf("unsigned char : %d\n",sizeof(unsigned char)); printf("short : %d\n",sizeof(short)); printf("unsigned short : %d\n",sizeof(unsigned short)); printf("int : %d\n",sizeof(int));
4
2685
by: Abra | last post by:
I need to write a Windows application with GUI, that should be able to run also on Linux. I have already a .NET application (written in C#) that uses (among others) Windows.Forms, ADO.NET, and TCP/IP (sockets). Which is the best way to get it running under Linux ? I read about Mono, would this be a reliable way ? Is Mono already "production-ready", or still beta ? Are the .NET parts that I mentioned above already completely implemented in...
93
4015
by: jacob navia | last post by:
In this group there is a bunch of people that call themselves 'regulars' that insist in something called "portability". Portability for them means the least common denominator. Write your code so that it will compile in all old and broken compilers, preferably in such a fashion that it can be moved with no effort from the embedded system in the coffe machine to the 64 bit processor in your desktop.
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10260
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10243
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10030
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9078
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5590
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.