problems running local PHP file using Chrome - php

I need to use Chrome to run a local PHP file. I believe I've done all that is required to do this (acc. to multiple web sites, inc. php.net), however, all I get is a blank web page. The things I've done to enable this capability are:
Install MS Visual C++ 2010 x64 Redictributable 10.0.40219
Enable IIS on my Windows 7 Home Premium PC by following instructions at http://php.net/manual/en/install.windows.iis7.php, including executing at the cmd line their "Examples" 2, 3, 4, 5, 6, 9, and the one enabling 64 bit operation
download php-5.4.31-nts-Win32-VC9-x86.zip, then follow instruction re: changing the php.ini file at http://php.net/manual/en/install.windows.manual.php (e.g., copy the php.ini-production into php.ini)
Put my php script into the folder C:\Users\Wade\AppData\Local\Google\Chrome\User Data\Default\User Scripts the script is simple:
<?php $row = "1.jpg";
echo $row;
?>
In Chrome, entered the url http:/localhost/<script-file-name.php>
Please help!

If you want to run PHP on IIS server then you can go with Microsoft Web Platform Installer.It automatically configures IIS server with PHP for you.

I'm not used to chrome, but i doubt this folder is made to run local php script.
Do you have some reason for choosing IIS ?
If not, and if you just want to run php file locally, you'll probably find a lot easier to use some programs such as Xampp to install & configure a little Apache web server for you.
If you choose to go this way, you need to :
disable or uninstall IIS , to prevent conflicts.
download xampp installer for windows : https://www.apachefriends.org/fr/index.html (some other alternatives exists, easyphp, etc.. )
install like any other program, the default settings are probably good enough.
delete all the files in the newly created c:\xampp\htdocs\ folder.
launch c:\xampp\xampp-control.exe (that may not be the exact name, but it's easy to spot in the folder) , and check that the Apache module is marked as started ( if you installed it as a service - which i think is the default - it will launch on windows start )
put your php files in c:\xampp\htdocs\
navigate to http:/localhost/
Hope this helps.

Related

Running PHP on Windows 10 - Server problem?

My computer is a Windows 10 64 bit.
I tried to run my PHP code, steps:
Downloaded php.net.
Set the environment variables path as instructed. Ran the command line like this: https://imgur.com/a/Q9zs9mL
Microsoft Windows [Version 10.0.17134.345]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\Mai Do>php -S localhost:4000
PHP 7.2.10 Development Server started at Mon Oct 22 21:04:32 2018
Listening on http://localhost:4000
Document root is C:\Users\Mai Do
Press Ctrl+C to quit.
Created a PHP file, first with NetBeans
Saved the file in the root directory folder named "php1" (try to be different from my root name)
Typed in browser: localhost:4000/php1/input.php
Object not found 404 page.
Tried multiple times with different php file. same thing.
Switch to Atom. Same thing.
Moved the file to htdocs folder. Same thing
Download Xampp. Turn on the Apache and MySQL. XAMP ver 3.2.2 control panel shows up. Both Button turn to Green. Still not found.
This SO page PHP not working in XAMPP says:
If you're trying to connect via your IP then your router must be
stopping it so you have to sort the settings out. I don't know your
router make/model you better off asking their support forums.
I am thinking there might be a server config problem. Like this one has a similar issue: Apache2 not working with routes PHP
which leads to this:
https://docs.bolt.cm/3.0/howto/making-sure-htaccess-works
"Editing the apache2.conf and setting 'AllowOverride All' on , finally
works." ???
I am not sure if that is the right problem either. Can someone walk me through it? Bless you.
To set up a test environment on your personal computer, follow the steps below:
Remove any installed PHP (Windows: uninstall via "Add/Remove Programs")
Install XAMPP (in your case, it's better to re-install the software suite)
XAMPP is a software suite that contains PHP + MariaDB (a fork from MySQL) + Apache Web Server + Perl. In your case, you are going to use PHP & Apache only.
Configure the DocumentRoot in Apache config file; you should put your website files in this DocumentRoot, thus I recommend you to set the path value to your development path. Read the manual if you're unsure how to do so.
Start/Restart Apache. If everything goes smooth, Apache should be up and running at port 80 (by default).
Launch your favorite browser and navigate to http://localhost
You should see your website written in PHP
If you have any further questions, please ask in the comment box below.
Note:
NetBeans is an IDE, not related to your testing environment
You can actually write your PHP scripts using any text editor

Error installing XAMPP: Windows cannot find -n

I've been trying to install XAMPP for quite some time now, but every time, at the end of the installation, it says:
Windows cannot find "-n"
And after that, it says:
Problem running post-install step. Installation failed (php.exe) Perhaps you have to install Visual C++ 2008 package.
I have Visual C++ 2008 package and it still says this. What do I do now? I have Windows 10 64-bit for anyone wondering.
I installed it in the root of my C: drive and it worked. Strange that previously I could just install it in my program files folder and that everything works...
Had the same problem when I tried to install xampp in a folder with spaces in its name (some folder example)
It was solved after I reinstalled xampp in a folder that has no space in its name, E.g. c:/xampp
Change your registry settings.
Open Registry Editor by pressing Windows + R key combination, type in regedit and press Enter.
If prompted by UAC, click on Yes to continue.
Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
In right-side pane, look for a EnableLUA and set the value to 0 and close Registry Editor.
Restart your computer.
Source: windows10update.com
Then type in XAMPP shell:
setup_xampp.bat
That error could be shown if you already had an older version of XAMPP installed to the default folder (C:\xampp) and you try to install a new version in a specific custom folder.
Just go to the Windows Control Panel, Add or Remove programs and uninstall the old installation of XAMPP.
I can confirm using Windows 10, that the "Windows cannot find -n" message is indeed based on the fact that you are installing XAMPP in a folder which is not c:\xampp.
That is rather a huge oversight for those who distribute XAMPP, they should allow relative paths.
I was trying to set XAMPP in c:\webservers\xampp\ because I'm working with multiple versions of servers for testing and development and well, there goes that idea.
Of course, in the end, I could always just do it myself, and get each bundle I need such as APACHE, mySQL, etc.. And that would mean, not relying on XAMPP.
Anyways, it's a rather stupid flaw, but it is what it is, and it's free, so, you pay for what you get! :)
An alternative to the current answers: I found that installing in a folder with a dash also didn't seem to work for me. E.g. C:\xampp-test\ would still give an error. Changing it to C:\xampptest\ solved the issue.
I ran setup_xamp.bat once (w/o admin rights) and it did some configuration for XAMPP but that did not help. When I executed setup_xamp.bat again with admin rights, it gave a message "nothing to do!".
While looking at the Apache config I realized it is trying to listen on port 80 and I already had IIS listening on that port. Which was causing the problem.
So I changed httpd.conf to use a different port 8765 (change needed at 2 places)
Also changed httpd-ssl.conf to use a different port 8766 (change needed at 3 places)
Then in XAMPP Control panel > Config > Services and Port Settings > specified same port number for Apache.
Once that was done I was able to start Apache without any error.

wamp server \ apache on Windows 7 does not load css and js files in subfolders

I've tried several versions of WAMP: 2.0 2.2 2.4 2.5 32 and 64,
and I've tried Apache stand alone on WINDOWS 7.
Root pages load but css, js and any other included files in sub-folders within a site do not load and Apace logs an access denied error.
It happens if the site is in the wamp/www folder or is an Apace alias.
I've tried gone through each step of the documentation, tried every config setting, install option, folder permissions, every idea found here and in every blog post Google returns in the search and nothing has worked. Allow all, vhosts, all those suggestions have failed.
What is up with WAMP/Apache on Windows 7? It worked fine right out of the box on my old XP machine.
thanks everyone hope someone has found a fix...
best, omcode
If you take a look into the source of the page (in your Browser), you'll quickly see that all your linked assets are using bad, non-resolving, or the wrong: path, domain, host, IP.
Possible walk trough's
check if rewrite_module is loaded if not check it and restart wamp.
Avoid relative path use absolute.
Check if the path & file-name is correct.
One of these will definitely be helpful for you.

No www folder is found in apache 2.2

I want to start learning php, I install apache 2.2 and I want to run my first.php file, I look for www folder in the installation folder of ApacheSoftwareFoundation but I couldn't find it.
here's the files in the apache
I tried to put my php file in htdocs but it doesn't work , can some one help ?
Edit
Doesn't work means when I make http:localhost/first.php , returns Unable to connect
Now the apache is running, when I open htt'://localhost/
returns "it works"
but when I open any php file, it opens as-is ?!
You'll need to check a couple of things...
Make sure the Web Server is running ,either the service
or the program, is running and that you have the correctly configured the Virtual Directories.
If the web server just outputs the
content of the .php file, it could
mean that you don't have mod_php
installed. Meaning the server does
not have the Mime type registered so
it will just try to treat it as a
text file ...
And as your on windows you might consider using something like XAMPP. It gives you a Full Working AMP (Apache Mysql Php) Stack with one install and a easy control manager to start/stop the servers. Other wise do a couple of Google searches on how to install the php module for your Web Server on Windows
Update
To start the server try executing the executable bin/httpd.exe .
Now the apache is running, when I open
http://localhost/ returns "it works"
but when I open any php file, it opens
as-is ?!
A default installation of Apache on windows does not include the necessary modules to run PHP. After installing Apache, you must either:
Install PHP separately and follow the instructions described here to configure Apache to use the installed version of PHP to serve .php files. I've been through this and took me hours to get every thing to work.
Recommended for you: uninstall Apache; install WAMP instead.
if you look in your httpd.conf file you will find the default root directory, it doesnt have to be called www. It is the htdocs by default.
error 500 covers a whole host of things. from compile error, to permissions.
Have you put a simple file of
<?php
echo "test";
?>
As your test php page to rule out other issues?
You need to:
Construct your URI correctly: http://localhost/first.php (with the //)
Ensure that Apache is running
all files in htdocs can be referenced from outside
Just put a basic file named index.php
and visit site http://localhost/
In general type in http://localhost/filename
You say that you get a connection error when you try to go to your webpage. Since it looks like you're using Windows Vista or 7, make sure you're running Apache as an administrator; it can't bind to port 80 otherwise. Also check that other programs like Skype aren't binding to port 80. If you still can't find the problem, check the error log. (logs/error.log by default I think)
The problem is that Apache was installed but not started
If you are using xampp start it and then start apache through control panel
for others look for similar instruction

Configure PHP to work with MySQL and phpMyAdmin

My purpose is to setup a forum in php just locally on my Windows 7 machine to test how it works.
I have installed Apache HTTP Server and PHP v5 successfully. Then I downloaded and extracted the phpbb-forum software and put it in my root folder. Then I realized that I needed some kind of database so I downloaded and installed MySQL. To configure my database I also downloaded and extracted phpMyAdmin but I can't get it to work. When I open my browser and navigate to my phpMyAdmin-folder I simply get this:
Screenshot: http://img836.imageshack.us/img836/5139/captureqb.png
I use my Apache server to preview my website where I'm using some php include functions so I know that I've a "working" PHP installation. The MySQL service is also running on my computer.
However, do you need to configure PHP and/or Apache in order to get phpMyAdmin to work properly? I'm a complete noob on this so I suppose it may be multiple shortcomings.
Thank you.. //Realiserad
The simpler way is to install WAMP server : it bundle Apache, PHP, MySQL and PHPMyAdmin preconficurated for work together.
You need to enable the MySQL extension to use MySQL from PHP.
The MySQL extension may or may not be bundled with your PHP distribution. (look for php_mysql.dll in the ext folder)
Assuming it's installed you can enable it by adding or uncommenting this line in your php.ini:
extension=php_mysql.dll
As other people have said it may be simpler to install WAMP Server
Have a look at: http://www.ricocheting.com/how-to-install-on-windows/mysql - Specifically, the 3rd step. It involves downloading the mySQL PHP Extention (which is a dll), and un-commenting a line of php.ini so that PHP Load's the extension.
While is may be simpler to install XAMPP or WAMP, I think that it's good to know how to fix your own problems - Scientia potentia est :D
not very familiar with windows, but it seems like you miss the php-mysql extension, which you can download from here (i think):
http://mysql2.mirrors-r-us.net/downloads/connector/php/index.html
would be alot easier for you to use a preconfigured wamp install like this one (available for win/mac/etc). google "xampp", i'm not allowed to post more than one link due to stackoverflows spam protection.
Configure PHP to Access MySQL
Open the c:\php\php.ini file with your favorite text editor.
Uncomment the following lines by removing the semicolon:
extension=php_mysqli.dll
extension=php_mbstring.dll
extension=php_mcrypt.dll
save and exit editor
After extracting the archive into phpmyadmin folder, you will have to configure phpmyadmin before you can connect to sql server.
you should create a configuration file. This file can be created manually (simply use a text editor),
During your first session you will see an error message.
To solve this problem you should create folder (C:\project\wwwroot\phpmyadmin\config). After that give full rights for IIS_IUSRS group and IUSR user.granting permission/image
Return to the config window. Visit localhost/phpmyadmin/setup/
To configure the connection settings click on the “New Server” button.
Enter the verbose name of the SQL server, and then the server hostname. If necessary, you can specify other settings.[setting up/image][2]
Save the settings and then the server will redirect us to the previous page. Choose:
the default language – English
the default server – 127.0.0.1
end of the line – Windows (\ r \ n)
Click Save, and then download. The received file (config.inc.php) you should save to the root directory (C:\project\wwwroot\phpmyadmin).
Open the authorization window (//localhost/phpmyadmin/) and login under root account. If you see a starting phpMyAdmin window, you can delete config folder.
For the correct work phpMyAdmin requires a database with the information. The script for creating database is already installed.

Categories