Good Evening Everyone,
I've been learning PHP and I'm using the built in server to learn the syntax and running simple scripts and web pages. I've been going at it for a better part of 3 weeks now but suddenly this evening. When I try to load my php webpage(s) it would load one page (or hang) then when I'd go to another page I wrote it would either hang or not load at all (Chrome is continuously "waiting on host"). I've been running Windows Server 2016 64 bit (very clean box here). I haven't had any problems with playing with the built in server until today. We are talking about very SIMPLE hello, world scrips with a couple of html tags here or there. I'm using version 7.2.0 64 bit Development Server. I ever tried x86 for giggles and it demonstrates the same behavior.
my command: php -S localhost:8000 (or any open port) I even used my IP to no avail. Suddenly my development sever just stopped working. I've made no changes to my PC.
I'm not receiving any errors or anything when I try to load my pages. What gives? I've made no changes to the ini file. I can attach if needed. Thank You guys so much!
I figured it out there was a command I was running within one of my php scripts that was causing it to hang! It's working now.
Related
Introduction
Before getting started with the actual question, I’d like to make a notice of being an extreme beginner to the world of web sockets using PHP. As a matter of fact, I’m still trying to grasp the very basics of it. I do however have lots of experience with sockets overall, from languages such as Java.
Upon doing my research, I stumbled upon the tutorial from PHP builder, whereas I think myself to having learned how to set socket connections up using this simple library.
Problem
Unto the problem we go. For a development server, I have chosen to go with XAMPP—it’ss sort of stayed with me from my Windows days, many years ago. At this very moment, I am using the terminal UI for XAMPP in Ubuntu—meaning, I launch the XAMPP server and then do a killall should I ever wish to close it.
In the tutorial mentioned above, you enter this information into your PHP document where you keep your server socket:
$server = new Server('192.168.0.8', '8000');
The Server class being a class extended by the WebSocketServer provided in the aforementioned library. You’re then supposed to run the PHP server socket using (with the dollar sign symbolizing terminal input):
$ php -q serversocket.php
It was suggested somewhere else on Stackoverflow that you run the server socket with the -f flag instead, but both of them—instead of starting the server socket—prints out the file contents in the terminal.
The PHP I’m using (to attempt running the server socket) is the one you get from running (on Ubuntu):
$ sudo apt-get install php
I’d assume this to be the regular version of PHP.
I’m honestly probably just being a huge moron, but truly do need help to solve this problem. Have I missed something?
The problem that was occurring at the time was the PHP code being displayed as raw data in the terminal whenever run. I was using short opening tags at the time <? and did have them enabled in the configuration.
I did however, resolve the issue, by rewriting the code to use the full opening PHP tags <?php. Perhaps there was more things to configure, maybe the version of PHP I was using was broken. Who knows?
I'm trying to update a site that's using php. I built the site and tested it on this machine. But today, the Php won't run on my local machine.
To test, I went back to the most basic php page I have:
<?php
phpinfo();
?>
When I navigate to this file, in Firefox (28), the result is a blank page. (The page source shows just my code.) In IE 11, I'm asking whether I want to open or save the file.
Searching for my original problem (which was that my php code was showing up rather than running), it was suggested that php wasn't installed. I don't know how it would have gotten uninstalled, but I went ahead and installed it again (from http://www.microsoft.com/web/platform/phponwindows.aspx) and still no joy.
Windows 7 SP1
Updates in response to suggestions:
Pardon the beginning stuff, but I'm not primarily a web developer. (I do databases.) This is stuff I'm doing for an organization I'm involved in. I don't actually remember having installed/configured a web server in the first place, nor do I remember having installed php before yesterday (though maybe my son did that for me).
After seeing the replies here, I followed the instructions on this page: http://webmasterjuice.com/how-to-activate-built-in-web-server-windows, but I'm still seeing the same thing.
Update:
I've confirmed that IIS is running and the php was installed. I've followed instructions I found online for getting php working in Windows 7 with IIS. However, it still doesn't make sense to me to have to do this. I'm sure I didn't do any of this when I started working with php. I'm not trying to use my computer as a web server. No interest in working through localhost.
I'm creating the file in a simple web-oriented editor (Crimson Editor). Until recently, I could use the editor's preview function on a file, whether HTML or PHP, and it would run correctly. I'm baffled as to why this stopped working.
A few things to look for:
It's php running besides been installed? (obvious, but maybe it got killed by some reason)
Have you included the phpinfo() call inside a html document?
Obviously you named the file with a .php extension and saved it within the document root of the server..?
I have a PHP 5.3.22 windows server running PHP in fastCGI. It's a Windows Server 2012 but I have also tried this on a Windows Server 2003 box so it does not seem IIS version specific.
If I have a basic PHP page:
<?php
echo 'test';
?>
Why does this take 1 second to load? This overhead seems to stack with further AJAX requests to PHP so this 1 second seems to be adding up.
Basic HTML pages just containing a word "test" from the same server is near instantaneously.
Surly it can’t just be that it takes servers a second to realise this is a PHP file and to prepare PHP for code execution.
I have tried setting the application pool to have more worker processes and to have it’s start mode as “AlwaysRunning” instead of “OnDemand” but alas this seems to have no impact.
Unfortunately changing the PHP version is not an option at this time (would take too long testing, etc).
If it's a clean start, then you shouldn't be experiencing delays anything like that. Perhaps check if you have any plugins or similar running. Xdebug slows down executions, for example.
This is strange, in Drupal 4.7 (a new install) I can get it to come up with a page that says "Unable to connect to database server" when I have not put in the DB connect information. This comes up in the browser just fine.
So I go in an put in the correct connect info (which works fine with my Drupal 6 sites) and I suddenly get a white screen. If I run cron.php I see the same HTML spit out that created the DB error before this.
Any idea what is going on?
UPDATE: I made a mistake, my webserver is actually using PHP 5.2. This is due to the fact that I am running this on my Macbook Pro which comes with PHP and Apache, but I am using Zend Server CE for my local web dev environment.
Sys info:
Drupal 4.7.11
PHP 5.3.4
MySQL 5.1.54
Any thoughts or ideas are welcome. I am really not sure where to go with this and I need to be able to get Drupal 4 working on my system to do a content migration from some older sites. (Yep, I wasn't using Drupal 4.7 to punish myself. I have a good reason).
I managed to figure it out awhile ago. Unfortunately I don't remember what I did, but I got it to work at least to the extent that I could bootstrap Drupal and then load the nodes and export them.
I am going to set this as solved. I apologize for not having the answer in here. It may have been LDAP, which comes with XAMPP but not Zend. I know that was a major problem on the Drupal6 version of this site.
Do I need a special library to run PHP on Windows environment Vista?
I can write simple message like echo "hello" but whenever I try to run any these scripts no error nothing display on the page http://php.net/manual/en/function.crypt.php.
I'm new to PHP please help
When in doubt...
<?php echo phpinfo(); ?>
If that code outputs information regarding your PHP version and settings, PHP is installed correctly.
There would be errors in your code if nothing is displaying. Post the code you are having trouble with and we can help you out.
Have you actually set up a local server? You'll need this to run PHP scripts. For a newbie I'd recommend WampServer since it's really easy and handles all the complexity of installing a server. Once installed and running, try http://localhost/ in your web browser.
Based on your comment though, I think the problem is that the sample code on the page you posted won't work on their own, you'd need to combine them with other things. For example the first one references a variable $user_input which you'd replace with a variable taken from user input (eg a form) on your site.
I suggest finding some tutorials online (or buy a book) and walk through various proper examples to familiarise yourself with PHP.
Do you have PHP / Apache installed at the moment? If you don't, try XAMPP. It comes with an easy and convenient installer.
Like most languages your computer must have the language/compiler installed in order develop and run scripts/applications. PHP was originally designed for web development so you won't usually find it installed on PCs by default.
The easiest way to develop PHP is to upload the scripts to a web server that has PHP installed and then test in your browser in the same fashion that you'd test an HTML page.
Otherwise to do it locally on your computer you can install a web development environment which acts like a web server. Essentially eliminating the upload step.
I believe the most popular for Windows is Wamp Server