Refreshing a PHP Server Cache - php

I have a paypal listener in a directory on a site I maintain e.g. \paypal\listener.php
I have it set to write to a mysql database, but it is writing to my development environment instead of my production environment.
This is weird because I have a model e.g. DAO.php that controls all access to the database. In other directories e.g. \directory2\page.php The page.php successfully writes to the production environment.
THE PROBLEM: To me this means that listener.php is including an old version of DAO.php (which is a class that was internally set to the development enviornment) In other directories though when this file is included the new version is being included.
Is it possible that one PHP implementation would server different versions of a file to different scripts??? If so how do I refresh the server cache that is making this happen?
I have already tried modifying and re-saving every relevant file to make the server think they are new.

Restarting the server probably would have solved this issue, but that was not an option, the Server was a Microsoft IIS machine using application pools and refreshing the application pools solved the problem.

Related

Setting Up PHP Push/Pull With Ubuntu Server

Bear with me here ... I can't show exact examples or provide a link to the web server for security reasons. If anything more is needed I will gladly provide it.
What I HAVE:
I have a server that hosts an internal networked intranet for my company.
Coded with PHP, MySQL, HTML, etc
Ubuntu 14.04LTS
Normal Apache Web Server Configuration
Login access
Couple hundred PHP files for different pages/features needed for the company
Maintenance
FTP into the directories (shown below)
Manually edit PHP files with Notepad++
Test in Beta Directory -> move to -> Secure (overwriting current file there)
I know this procedure for maintaining is horrible so I'm trying to come up with a better solution
What I NEED:
Features
IDE Connectivity (Aptana,Eclipse,etc)
Commit/Push/Pull Capable with Server from IDE
Version Control
Keep backups for Rollbacks
Test & Main Server
Like how I have a Beta and Secure Directory for testing and releasing to everyone
What needs to be done on the Ubuntu Server in order to accept push/pull requests, store multiple versions, and store commit messages?
Do I need to install anything on the Ubuntu server in order to communicate with the remote computer I'm trying to access from?

How to debug a site move, for a PHP5/MySQL web application

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.

WinCache caching incorrect CakePHP files

I have a bizarre problem with WinCache and it's possible this isn't the best forum. I checked SuperUser but there are 0 results regarding WinCache. Support seems to be weak throughout the web but at least SO has discussed it before.
I have a live and a development site on the same server (CakePHP framework, Windows Server 2008 R2, IIS 7.5, PHP 5.3, FastCGI, WinCache 1.1). Live site is on port 80 and dev on 81. IIS has two web sites, each pointing to a different root folder in Inetpub\wwwroot. Each site is run under a different application pool.
Some time after a change to the dev site the live site started erroring. After some painful debugging I found out that the following (totally lame) chain of events occurs:
Live PHP script loads as normal following GET request
Live PHP script POSTs to itself as normal following user selection
Dev PHP script handles POST request and errors when form parameters are not as expected.
If I inspect the WinCache properties through the web interface under port 80 (live site) I see the document root is Inetpub\wwwroot\Live - as expected. However, if I review the list of cached files under the file cache tab I see some files cached twice. Mouse-over tells me that one is from Inetpub\wwwroot\Dev and the other from Inetpub\wwwroot\Live.
How is this possible? Why is IIS using one in a GET request and another in POST? I know that CakePHP chooses which files to load based on a formatted URL, but the index.php file which handles routing is within Inetpub\wwwroot\Live, so presumably could never request a file in a different doc root. It seems to me that PHP asks IIS for a file, but IIS is losing its marbles when communicating with WinCache.
So far I can't see any way to disable WinCache for one site, but even if I could I probably wouldn't trust it anymore.
Any suggestions on this vexing issue will be much appreciated.
I have no Problems.
Try this:
Use Wincache 1.2 (Beta)
Dont use "." in the AppPool Name.
(Opt.) Create a ProcessUser for each AppPool.
Look for session files called "wincache_session_*" in the our session directory.
Copy the wincache.php from "[AppDir 86]\IIS[Wincache]\wincache.php" in each webdirectory
and open it over http.

Moving PHP site from one server to another

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!

php shared host and mod_security

I'm having difficulty with a php script using copy() on a shared remote host. I've read here the host may simply not allow the use of the copy() function. I started a trouble ticket and the trouble was half fixed and blamed on mod_security. I persisted and now my script is working. A strange last response, after the fix was this:
"Unfortunately as these are shared servers we are unable to make any custom modifications to the server configurations. The most customization you can perform are PHP settings. Any server related settings are unable to be modified."
What could this person be referring to when they say "PHP settings"? Note the site uses cPanel.
And another strange thing is my php CMS app. is now doubling edits (as if I was inserting rather than updating) in the database. This is not the case on my test server. How can a fix in mod_security cause mysql updates to behave differently?
When he refers to PHP settings, he means overriding some directives of the server's php.ini file with your own php.ini.

Categories