Jump to content
xisto Community
snlildude87

Test Your Php Pages W/o Upload/internet complete *working* guide on how to test your php pages

Recommended Posts

In this tutorial, I'm going to show you how to test your PHP pages without the Internet or uploading the files to your Xisto server. This tutorial is similar to doom's, but the links he provided does not work, so I decided to make my own tutorial with working links. The program that I will be using for this tutorial is called XAMPP. XAMPP is a modification of the popular Apache server, and I'm using XAMPP because of its simplicity to install as well as maintain. The current version of XAMPP is 1.4.13 and it has the following bundled in the download:

Apache HTTPD 2.0.53, MySQL 4.1.11, PHP 5.0.4 + 4.3.11 + PEAR + Switch, MiniPerl 5.8.3, Openssl 0.9.7f, PHPMyAdmin 2.6.1 pl3, XAMPP Control Panel 1.0, eAccelerator 0.9.2a, Webalizer 2.01-10, Mercury Mail Transport System für Win32 und NetWare Systems v4.01a, FileZilla FTP Server 0.9.6a, SQLite 2.8.15, ADODB 4.60, Zend Optimizer 2.5.7, XAMPP Security

The Blurb

Every web site on the internet, including your website at Xisto, is hosted on some sort of server. What is a server you ask? A server is basically a central processing unit (CPU), similar to the one you have next to you, that has a program installed, usually Apache or its variants. The main job of the server is to serve up web pages for you to enjoy.

 

How do I get a XAMPP?

Simple. The following are direct links to download XAMPP from various servers:

 

* https://sourceforge.net/publish/

* http://forums.xisto.com/no_longer_exists/

* https://sourceforge.net/publish/

* http://forums.xisto.com/no_longer_exists/

* https://sourceforge.net/publish/

* http://forums.xisto.com/no_longer_exists/

* http://forums.xisto.com/no_longer_exists/

* http://forums.xisto.com/no_longer_exists/

* http://forums.xisto.com/no_longer_exists/

* http://forums.xisto.com/no_longer_exists/

* https://sourceforge.net/publish/

* http://forums.xisto.com/no_longer_exists/

* http://forums.xisto.com/no_longer_exists/

 

If one doesn't work, try the others. :D

 

Once you have downloaded XAMPP (25 MB), run the installer and install it in c:\apachefriends. Whatever name you choose, you have to keep in mind that XAMPP has to be in an upper directory, so c:\program files\apachefriends will not work.

 

Congratulations! You now have your very own non-working server on your computer.

 

Make it Work - The Harder Way

Go to My Computer -> C: -> apachefriends -> xampp if you chose to install it in the apachefriends directory. You should see several files and folders in the xampp folder. The first thing to remember is not to get intimidated because the file names are very descriptive, so they're easy to understand.

 

To start your server, find the file name called "php-switch.bat" and double click on it. Type "5" (without quotes), so the window should look somewhat like this:

CONSOLE

#----------------------------------------------------------------------#

 

# Copyright © 2002-2004 Apachefriends #

 

#----------------------------------------------------------------------#

 

# Authors: Kay Vogelgesang <kvo@apachefriends.org> #

 

# Oswald Kai Seidler <oswald@apachefriends.org> #

 

########################################################################

 

 

 

The working version in XAMPP is => PHP 5 <=

The verwendete Version in XAMPP ist => PHP 5 <=

 

 

Type number or 'x' (exit) for selecting your choice!

Gebe nun Nummer oder 'x' (exit) zum auswaehlen ein!

 

4) Switching to PHP 4 (zu PHP 4 wechseln)

x) Exit (Beenden)

5_

You now have PHP running on your computer! :D Now, press any key to exit that window.

 

To get Apache running on your computer, find the file called "apache_start.bat". You now have Apache running on your computer. Congratulations! :D The most important part is running or testing PHP scripts on your computer.

 

Making it Work - The Easier Way

Go to your My Computer -> C: -> apachefriends -> XAMPP -> Double click on xampp-control.exe (should be the last file in that directory) -> Click the first two "Start" buttons (the last two are optional) -> Click on the X on the top right hand corner of the application.

 

Congratulations! You have just started Apache with PHP and MySQL on your computer in less than 5 minutes, and best of all, the big black console/DOS screen is not there. :D

 

Running PHP Scripts on your Computer

Go to your xampp folder which should already by opened. Find the folder called "htdocs" and double click on that. Right click inside that folder -> New -> Text Document ( Posted Image)-> Rename the new file to "testphp.php" (without quotes) -> Click Yes -> Double click on testphp.php -> Type:
<?php echo "Whee, PHP!"; ?>
Save the file (Ctrl + S).

 

Open your favorite browser and type in "LOCALHOST/testphp.php" in the address bar. If you see "Whee, PHP!", then you did everything right! If not, then either I screwed up or you did not follow my instructions. Post whatever problems you have and I'll try to fix it.

 

You can also allow friends to see your PHP script. Simply find your IP address, and give them this URL: http://youripaddress/testphp.php. If your friend complains that it's taking forever, chances are you have a slow internet connection. The faster your internet connection -> the faster your friends will be able to view the pages hosted on your computer. Now you know why most servers demand a fast internet connection such as T1. :D

 

Closing Apache

Go back to the xampp folder and find a file called "apache_stop.bat" and click on it. Apache is now turned off on your computer!

 

Frequently Asked Questions

Q: Will .htaccess work?

A: Yes! Open a new file in Notepad and save it as a ".htaccess" file. Now, go to your File Manager in your cPanel. Go into the public_html folder and find a file named .htaccess. Click on it. On the right pane, you will see a list of things you can do with that file. Click on Edit File and a window should pop up. Copy everything in that box and paste it in the opened Notepad. Save Notepad (Ctrl + S).

 

Q: Why is .htaccess important?

A: No, but you can do some pretty cool stuff with it. For example, you can make custom 404 pages or, my favorite, you can make your server treat a file name of your choice to parse as PHP, so a file ending in .html will be parsed as a PHP script. This is really cool because it gives members the impression that your site is edited by hand.

 

Q: How do I make my server parse .html files as a .php file?

A: Make a .htaccess file as shown in the first question in this FAQ. Append this line to your .htaccess file:

AddType application/x-httpd-php .html .htm
In fact, ".html .htm" in the code above can be anything your heart desires. You can go all out and replace ".html .htm" with ".yourname", so pages ending in ".yourname" will be parsed as if it were a PHP script. :o You can also make your server parse files with no extensions as a PHP script. Just append this line to your .htaccess file:
DefaultType application/x-httpd-php
I like this, too, because it looks as if you store EVERY page in different folders. :D

 

Q: Can't I just exit out of Apache without clicking on apache_stop.bat?

A: NO! For some reason, this is very bad and will cause problems. apache_stop.bat has to run in order to shut down Apache correctly.

[hr=noshade][/hr]

That's all for now! Remember, if you have any questions about this tutorial, feel free to post it, and I'll do my best to answer it. :D

 

Edit: Added "Making it Work - The Easier Way" :D

Edited by snlildude87 (see edit history)

Share this post


Link to post
Share on other sites

Great tut snlildude! I tried it and all works well!

I thought I might add something to this tut though.

If you wanted to run a web server from your computer to serve your website to the internet with a web address not an IP, you could follow the next steps:

1) After you have installed the server as described by snlildude, go to DynDNS.org and sign up for a dynamic DNS account.

3) Log into your DynDNS account and on the left hand menu you should see a link to "Dynamic DNS" Click on it. Choose your domain name(something like: mywebsite.dyndns.org), input your IP address (to find your IP address in windows go to Start>Run> then type "ipconfig" or some ver. of windows "winipcfg" no quotes) then click Add Host.

All Done!

Now any time sombody types in the new web address you got, DynDNS.org will direct the request to your web server.

You may need to update your IP address with them occasionally because even though you are using Dynamic DNS (means it detects your new IP every time you get a new one) sometimes manually updating your IP makes things update faster on the DynDNS site.

Hope this will help some of you. And sorry snlildude for adding to your tut, I just think taking it this one step further might help some people. :o

Share this post


Link to post
Share on other sites

And sorry snlildude for adding to your tut

130715[/snapback]

That's all right :D If this tutorial becomes popular, and people start adding their own little snippets like you, then I'll add those to the end of my tutorial to make one big tutorial :o

Share this post


Link to post
Share on other sites

Sorry I just noticed that in the addition I made to snlildudes tutorial, I put step 1, then step 3. That was just a typo. There is no third step. It should be step 2.OOPS! :o

Share this post


Link to post
Share on other sites

he he he me smart and figure out a back wayopen the cpanel that comes with it and click start for all of them then hit the X not exit and its on ur system tray.Now I have a question how do I get rid of that start page they give u so I can try to do something for a friend and that way they cant acces the mysql

Share this post


Link to post
Share on other sites

he he he me smart and figure out a back way

open the cpanel that comes with it and click start for all of them then hit the X not exit and its on ur system tray.

 

Now I have a question how do I get rid of that start page they give u so I can try to do something for a friend and that way they cant acces the mysql

130832[/snapback]

Nice!! I'm going to edit my original post to include your method :D

 

Go to My Computer -> C:\ -> apachefriends -> xampp -> htdocs. See the index.html file? Kill it. Delete it. Rename it. Edit it. Eat it. You get the idea - do whatever you want to that index.html file so that the code inside it will not execute:

<html><head><meta name="author" content="Kai Oswald Seidler, Kay Vogelgesang"><meta http-equiv="refresh" content="0;url=/xampp/splash.php"></head><body bgcolor=#ffffff></body></html>
As you can see from the code above, the index.html file will take you to the splash.php file as soon as it's opened, so you have to delete index.html and make your very own index.php file. Then, when you go to http://youripaddress/, your very own index page will show. :D

 

I hope that made sense :o

Share this post


Link to post
Share on other sites

ok my problem is the txt document this is what i get testphp.php.txt what am i doing wrong

Share this post


Link to post
Share on other sites

When I start Apache, it runs in a new window that just sits there. Is it possible to make it run in the background or system tray?

130780[/snapback]


GO to the folder where you have installed XAMPP.

open the 'apache' folder and click on 'installapacheservice' .bat file.

then open the 'mysql' folder and click on the 'installmysqlservice' file.

 

Then restart the PC and there you go...

Your Xampp is on, but without the nagging window!

 

To test it, just open your browser and type LOCALHOST/ and click enter. You will see your homepage!

 

Good luck...

Googlue

Share this post


Link to post
Share on other sites

This is gotta be the best tutorial on this subject ever :lol: ive tried it and it works fine,thanks man for the tut its helped me alot, does MySql work on it ? or do i have to install somthing else :)

Share this post


Link to post
Share on other sites

Yeah, it did help me a lot. Instead of uploading every time, I can now test my site offline then upload to my Trap 17 Site. This is really good, even though I dunno if it works with mySQL. Like, how could you try some phpBB, IPB, or PHP Nuke offline? If anybody knows, please tell me, that could really help me out.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.