I am running a wamp test/development server on my rig, however I am trying to ensure it replicates the normal behavior of a production server. Last time I moved from a test environment to a live one I had the following issues:
Case sensitive relative paths were being obnoxious on the live server
Case sensitive MySQL commands were being obnoxious on the live server
Some header requests I sent (okay this is embarrassing) in the middle of a 'view' were obviously not getting accepted.
I replicated the behavior of error number 3 on my test server by disabling output_buffer in the ini file.
However, I haven't quiet figured out how to make my test server all touchy about case sensitive paths and sql commands.
Could someone help me out? Also, please point out the other settings I should enable/disable in the ini file to ensure it acts like a live server.
The trouble is that your live server is a non-Windows server, and your test server is a Windows server. PHP is relying on the system to find files. Windows files/paths are not case sensitive.
For everything else, you are likely using different versions of MySQL and what not.
If you want a solid test, either upload directly to your live server, or duplicate the server and run it in a virtual machine, such as VMWare, on your dev computer.
Related
I have been running a PHP site for years on my own servers. I recently purchased a dedicated server package and am trying to move my site to the dedicated server. I recently upgraded to PHP 5, and my current server is running PHP 5.6.16. I moved the files and the database, and put it in a live test domain, but the site is not functioning properly on the new dedicated server. Several key scripts are non-functional. I made sure that the dedicated server is running a version of 5.6. I have configured it to the same settings I have on the old server. I can see that the site is talking to the MySQL database. I turned on error reporting and I see no significant errors suggesting why these important scripts are now non-functional. I made sure the include path is there, and if it wasn't nothing would work. What am I overlooking? What could be different between one server and the other that might impact PHP functionality? I'm basically at my wits end here, so if these seems stupid please forgive me, but I don't know where to look next.
Start with the basics.
Does your web server respond to static page requests?
Is your web server configured to use PHP?
Can your web server execute and/or connect to PHP?
If you have a simple script with <?php phpinfo(); in it, does it work?
Are all the expected modules there in your phpinfo() output?
Do you have rewrite rules that need to be reconfigured? (Check your web server error log. Check your response status codes.)
Assuming PHP is all good, move into your application.
Are you absolutely sure error logging is on? (Again, check phpinfo() output. Try to force an error, maybe a syntax error or something and see if you see the error.)
How do you know your application is connecting to MySQL?
Start with a basic script that just echos some things.
Comment out large swaths of code and see if you can narrow down the problem that way, re-enabling chunks as you go. (You want to bi-sect the problem, cutting in half and in half and in half until you figure out exactly what the issue is.)
Other system-level things to check...
File system permissions? (See also https://serverfault.com/questions/48587/is-there-a-linux-log-for-when-a-user-is-denied-access-to-files-due-to-permission, for Linux.)
Firewalls? (Are you sure you can actually access MySQL over the network?)
Disk? (Are you out of space? Are your partitions set up correct? Is /tmp full?)
Once you figure out the problem, some advice:
Do this sort of thing regularly. Write a provisioning script to build yourself a new machine from one command, and do it regularly. These days with cloud providers (physical hardware or not) there's no reason you can't blow away your application servers on a regular basis, and re-provision them. Consider making this your system upgrade strategy. (Why reboot to get a new kernel when you can just have a whole new server with the new kernel and other patches, that you can cut over to?)
Ensure your development environment closely matches your production environment. (Consider Vagrant for this.)
You're using version control, right? If not, start using version control so that you can hack on your code for things like this and easily roll back when done.
I need to run PHP scripts on server without having to update files it stores - perform testing on real server before deployment. Server has access to database which is inaccessible from outside. For this reason I can't run my scripts locally, I need to run them within server's environment, but I don't want to update files stored on server. Is there any way to do so? Is there a tool for remote PHP debugging?
There are several ways to achieve this thing
You can export database from live server and import it to your local server for testing and debugging purpose.
You can Upload code into a separate folder or subdomain on server to connect with database and test with live server configurations. Once you are satisfied replace live files.
I have found a solution - XDebug for PHP. However as was mentioned in comments, testing against copy of DB and using virtualization is a more common approach, which I personally will probably stick to.
For those who are still determined to go the "hard" way, here is a link to HOWTO on XDebug installation for PHP on Ubuntu - http://ubuntuforums.org/showthread.php?t=525257.
Alright -
So this is a wee bit frustrating. I have my local Development Server and my remote Test Server. They are using identical code deployed from GitHub, including (temporarily) identical login credentials. Both Apache Servers use local MySQL Servers (for now). I have verified on both MySQL servers that the relevant user has identical permissions & passwords to a certain database.
In other words, everything is theoretically the same. EXCEPT my dev server is Windows (running XAMPP) and my Test server is Linux (running LAMP).
I am using a CodeIgniter Framework. So the problem is, my Test code runs fine on my Test box, but when I try to run it on local Dev I get the error "Unable to connect to the database". I am thinking that there must be a configuration issue between PHP & MySQL on my Dev server since I've pretty much eliminated MySQL credentials as being a possibility.
Any ideas? Much appreciated... Debbie
multiple environments with codeigniter
https://www.codeigniter.com/user_guide/general/environments.html
Earlier today I had an issue with my server and it crashed so I had to reboot. Since I rebooted it I've been seeing some strange behavior in some of my php pages. Particularly, some javascript stuff doesn't seem to be working at all. (There are some other issues, but I feel like they're stemming from the failing javascript.)
I'm still getting used to web programming and using servers, so I have no idea why this javascript wouldn't be working after the reboot. I can post the script here if need be - I don't know if this is just a generic thing or is going to be specific to my script.
For the record it's an Apache server on a Redhat machine.
The javascript is executed in the client browser not in the server, so as long as you did not make any modifications to the javascript files, there should not be anything wrong caused by the server.
Did you try accessing your website using another computer ?
From your comment it appears that the page is loading a javascript library from a network location which it cannot find (http://wks-l0000120674/nephiere/validation.js). Thus it will load if the client machine (not the server) is connected to the network AND the wks-l0000120674 workstation is up and on the network AND the client machine has rights to request files from wks-l0000120674. On the reboot you may have booted wks-l0000120674 off the network (assuming that wks-l0000120674 is part of the same network as the server and the server also provides DHCP services). Make sure you can still get to this location from the client machine.
I have no idea about PHP.
I have PHP site hosted on Server A. Now I want to transfer the hosting to another company having Windows hosting on Server B.
Can I just transfer all the contents of WWWROOT folder of Server A to Server B? Will the site work that way? Or I do have to get the source, compile and publish it?
Thanks!
the process is this:
copy the content from server A to B (also db dump)
make sure your site is working on server B correct
set a redirect on server A to server B (usually in .htaccess file)
edit DNS entries to point to server B
wait that DNS changes have been picked up (note: as suggested by Emil you can reduce this time by lowering TTL setting on the DNS entries)
remove content from server A (end hosting)
PHP is not (usually) compiled, you should be able to simply copy the files and directories over and they should at least run. You may have to set up a database and connections to it, change some configuration in the scripts and you may or may not run into incompatibilities between different PHP versions and/or UNIX/Windows problems though, depending on how portable the scripts were written.
you don't need to compile anything. it's enough to copy project directory from one server to another. one thing can cause your project not working on ohter hosting, if there will not be installed some php-extensions that are required for you project.
and of course, if your project uses some databases, they must be created on new server
PHP scripts are source code and are compiled when needed. Simply moving the files is enough. Problems may occur if it is a package that has been isntalled on that server and may have some properties in various files about absolute paths to other files.
Also, issues will occur if the files are talking to a local SQL server or the such.
Many hosting companies offer a free (or sometimes payed) service to copy your website accross including any databases. Ask your hosting company for help.
No need to compile, however you have to make sure that the new server meets all the requirements of your application (e.g. server modules) and that paths are correctly configured. Also under some circumstances the PHP version can matter as well. Only one way to find out!