|
-
Sep 25th, 2009, 06:04 AM
#1
[RESOLVED] My web server address?
Hi,
I'm not sure where to put this since I have been given an example of a face-book application as part of my php class. Although I have the code I am unsure what to put as my web server, where do I get the address from? I am trying the test the php code that is in the "www" directory of phpdev.
Thanks
Nightwalker
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 25th, 2009, 08:37 AM
#2
Re: My web server address?
Maybe I'm misunderstanding you, but if you're running off your local machine it should be 127.0.0.1.
If you're running off a host, you should have that information.
-
Sep 25th, 2009, 08:40 AM
#3
Re: My web server address?
127.0.0.1 or localhost should work.
-tg
-
Sep 25th, 2009, 07:28 PM
#4
Re: My web server address?
 Originally Posted by kfcSmitty
Maybe I'm misunderstanding you, but if you're running off your local machine it should be 127.0.0.1.
If you're running off a host, you should have that information.
Oops, what I'm trying to find out is how the outside world would access the websites in the "www" directory? I know I have to change the address in /etc/httpd/conf/http.conf but I don't know what else needs to be done.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 25th, 2009, 09:06 PM
#5
Re: My web server address?
You'll need your external IP address... and if necessary, set up port forwarding to your PC....
-tg
-
Sep 25th, 2009, 09:27 PM
#6
Re: My web server address?
 Originally Posted by techgnome
You'll need your external IP address... and if necessary, set up port forwarding to your PC....
-tg
How do I do that?
Edit:
The pdf that we were given says:
Upload the content of C:\wamp\www\facebook-platform folder to your web
server. Make sure to keep the directory structure as it is.
Which, implies a web server account is needed. However, I am still curious how I wold setup a server if it were on my pc. While searching for a web server host I came across this.
Home server: usually a single machine placed in a private residence can be used to host one or more web sites from a usually consumer-grade broadband connection. These can be purpose-built machines or more commonly old PCs. Some ISPs actively attempt to block home servers by disallowing incoming requests to TCP port 80 of the user's connection and by refusing to provide static IP addresses. A common way to attain a reliable DNS hostname is by creating an account with a dynamic DNS service. A dynamic DNS service will automatically change the IP address that a URL points to when the IP address changes.
Last edited by Nightwalker83; Sep 25th, 2009 at 09:49 PM.
Reason: Adding more
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 26th, 2009, 01:22 AM
#7
Re: My web server address?
you already have a web server on your computer; apache is a web server.
you can find your external IP address by going to this website if you want. to set up port forwarding, you'll need to configure your router to map all incoming connections on port 80 (or whatever port you'd like, some use 8080, for example, if they don't want random people visiting -- this also needs to be the port that apache is listening on [default = 80 or 8080 depending on how it was installed]) to your computer, and then make sure your firewall (assuming you have one) is allowing traffic to come in on that port.
if you don't have a static IP address (your ISP can tell you whether you have one or not, but chances are that you don't unless you're giving them an extra $1-5 per month for one), then you'll need to use a dynamic DNS service, like dynDNS. this will map a domain to your dynamic address so that you won't need to worry about what your IP address is.
-
Sep 26th, 2009, 02:58 AM
#8
Re: My web server address?
 Originally Posted by kows
you already have a web server on your computer; apache is a web server.
Yeah, I have been using apache as part of my php class, one of which I had to create a security certificate for a website. Last year I started this thread about setting up a web server, I chose phpdev as the better option on which to try setting up a web server.
you can find your external IP address by going to this website if you want. to set up port forwarding, you'll need to configure your router to map all incoming connections on port 80 (or whatever port you'd like, some use 8080, for example, if they don't want random people visiting -- this also needs to be the port that apache is listening on [default = 80 or 8080 depending on how it was installed]) to your computer, and then make sure your firewall (assuming you have one) is allowing traffic to come in on that port.
if you don't have a static IP address (your ISP can tell you whether you have one or not, but chances are that you don't unless you're giving them an extra $1-5 per month for one), then you'll need to use a dynamic DNS service, like dynDNS. this will map a domain to your dynamic address so that you won't need to worry about what your IP address is.
Thanks! I'll have a look and see what (if anything) I can sort out.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Sep 26th, 2009, 05:16 PM
#9
Re: My web server address?
I received a email back from a classmate about a web-host! She said our lecturer suggested this web host. I'm still looking into options where I can host my websites for as little money as possible. At the moment I have two webs accounts which are the basic type and do not offer php, etc without you paying extra for it. However, the above site seems to have everything I need (at least for now) for free.
Last edited by Nightwalker83; Sep 26th, 2009 at 05:46 PM.
Reason: Fixing spelling!
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Oct 21st, 2009, 10:43 PM
#10
Re: My web server address?
What is the preferred method of storing the connection details? In a separate *.php and use the include/run once to access the connection data?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Oct 21st, 2009, 11:21 PM
#11
Re: My web server address?
this is completely unrelated to the thread you're posting in, so that's a good sign that you may want to make a new thread for it. just saying for future reference.
anyway, since you weren't specific even in the least, I'll just assume you're talking about databases.
the absolute best practice is to store your database connection in a file that is ABOVE your "/www/" or equivalent directory. take these two paths (unix/windows), for example, as being where your site's content is (basically, where your domain points to):
unix:
/home/myusername/www/
windows:
C:/web/myusername/www/
in both of these cases, anything in /www/ is "live." so, you create a file that holds your database connection and store it above that directory;
unix:
/home/myusername/
windows:
C:/web/myusername/
this means that your database connection file is technically offline. at least, no one can actually run it unless they're directly connected to the server your content is hosted on. even though PHP files are executed by PHP (meaning no one could see your code if they ran that file in /www/, either), it's just a little added security. for example, if PHP is uninstalled for some reason, or stops working, then all of your PHP files would be displayed as text files to anyone browsing. this could potentially be a huge security risk, as unlikely as it may be. it's the only thing I could really think of. anyway, to access this file, you can then call the require_once() function from any file in /www/ using this code:
require_once("../database-connection.php");
we use require_once() because if the file doesn't exist, your script will not even attempt to run. also, if you run into a situation where you are including a file into a "main script" but that file can also be ran by itself, require_once() will ensure that the PHP file you're including is ONLY ever ran once. otherwise, your database connection would be overwritten, along with anything else you might store there.
the next best thing is to just have a database connection file in your /www/ directory (only assuming you can't do the above), and to include it into anything that requires a database connection. we do this because it makes our scripts modular; changing hosts, changing database servers, or changing your database user's password is all just a quick edit of one file rather than an edit of multiple files. it's silly to have a call to mysql_connect() hard coded into each and every file on a big website. even on a small website it would be annoying, though.
I also tend to store any of my "global variables/constants" within this file, or useful functions. this ensures that all of my scripts have these variables/constants in their scope and that I have all of the functions I might need whenever I might need them, without needing to specicially include them for just one script.
this is an example of a database connection file that I have on a website [a few comments added, sensitive things stripped]:
PHP Code:
<?php /* start compression */ ob_start("ob_gzhandler");
/* mysql connection */ @mysql_pconnect("host", "user", "password") or die(mysql_error()); @mysql_select_db("database"); $mysql = array(); $mysql_safe = array();
/* site tables */ $mysql['users'] = "users"; $mysql['approve'] = "approve"; $mysql['companies'] = "feedback_companies"; $mysql['comments'] = "feedback_comments"; $mysql['groups'] = "groups"; $mysql['site'] = "site";
/* forum tables */ $mysql['forum_titles'] = "forum_titles"; $mysql['forum_threads'] = "forum_threads"; $mysql['forum_posts'] = "forum_posts"; $mysql['forum_threads_read'] = "forum_threads_read";
/* some variables */ $states = array("AL" => "Alabama", "AK" => "Alaska", "AZ" => "Arizona", "AR" => "Arkansas", "CA" => "California", "CO" => "Colorado", "CT" => "Connecticut", "DE" => "Delaware", "DC" => "District of Columbia", "FL" => "Florida", "GA" => "Georgia", "HI" => "Hawaii", "ID" => "Idaho", "IL" => "Illinois", "IN" => "Indiana", "IA" => "Iowa", "KS" => "Kansas", "KY" => "Kentucky","LA" => "Louisiana", "ME" => "Maine", "MD" => "Maryland", "MA" => "Massachusetts", "MI" => "Michigan", "MN" => "Minnesota", "MS" => "Mississippi", "MO" => "Missouri", "MT" => "Montana", "NE" => "Nebraska", "NV" => "Nevada", "NH" => "New Hampshire", "NJ" => "New Jersey", "NM" => "New Mexico", "NY" => "New York", "NC" => "North Carolina","ND" => "North Dakota", "OH" => "Ohio", "OK" => "Oklahoma", "OR" => "Oregon", "PA" => "Pennsylvania", "RI" => "Rhode Island", "SC" => "South Carolina", "SD" => "South Dakota", "TN" => "Tennessee", "TX" => "Texas", "UT" => "Utah", "VT" => "Vermont", "VA" => "Virginia", "WA" => "Washington", "WV" => "West Virginia", "WI" => "Wisconsin", "WY" => "Wyoming");
/* query the database for usergroup names/colors */ $query = mysql_query("SELECT id as group_id, title as group_title, color as group_color FROM {$mysql['groups']}"); while($g = mysql_fetch_assoc($query)){ extract($g); $group['title'][$group_id] = $group_title; $group['color'][$group_id] = $group_color; }
/* date constants */ define("FORUM_DATE_FORMAT", 'g:i a T \o\n M jS, Y'); define("APPROVAL_DATE_FORMAT", 'M jS Y');
/* functions */ //function to process forum names //$g = user groups //$d = delimiter, decides if there are multiple names function name_process(&$name, $g, $d = ''){ global $group; if($d){ $names = explode($d, $name); $groups = explode($d, $g); foreach($names as $k => $n) $names[$k] = '<span style="color: #' . $group['color'][$groups[$k]] . '">' . $n . '</span>'; $name = implode($d, $names); }else $name = '<span style="color: #' . $group['color'][$g] . '">' . $name . '</span>'; }
//function to process forum posts function post_process(&$post){ $post = htmlentities($post); //line breaks $post = preg_replace("/\\r\\n/", "<br /> ", $post); //html $post = preg_replace("/\[b\](.*?)\[\/b\]/", "<strong>$1</strong>", $post); $post = preg_replace("/\[i\](.*?)\[\/i\]/", "<em>$1</em>", $post); $post = preg_replace("/\[u\](.*?)\[\/u\]/", "<u>$1</u>", $post); $post = preg_replace("/\[strike\](.*?)\[\/strike\]/", "<strike>$1</strike>", $post); $post = preg_replace("/\[quote=(.*?),(.*?)\](.*?)\[\/quote\]/", '<div class="quote"><span>Quote: <strong>$1</strong> at $2</span>$3</div>', $post); } ?>
excuse the mess ;) I've yet to fully adopt OOP in PHP.
Last edited by kows; Oct 21st, 2009 at 11:46 PM.
-
Oct 21st, 2009, 11:58 PM
#12
Re: My web server address?
 Originally Posted by kows
this is completely unrelated to the thread you're posting in, so that's a good sign that you may want to make a new thread for it. just saying for future reference.
Oops, I thought it had something to do with the server since that was what I want to connect to.
Anyway, this what I mean, is it better to have:
PHP Code:
<?php
# FileName="conn_db.php"
$hostname= "localhost";
$database = "custdb";
$user = "user";
$pass = "password";
$mysql_link= mysql_connect($hostname,$user,$pass) or die(
"Unable to connect to the server");
mysql_select_db($database) or die( "Unable to select the
database");
?>
In a separate file and use:
PHP Code:
//connect to server and select database
require_once('conn_db.php');
to connect to it? So I only have to put the host address once rather than have:
PHP Code:
// Database connection variables
$dbDatabase = "BazaarCeramics";
//connect to server or exit
if (!($conn = mysql_connect("localhost", "root", "") )){
echo 'result=connection+failed';
exit;
}
in all the php files?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Oct 22nd, 2009, 12:35 AM
#13
Re: My web server address?
uh.. did you happen to read my post? because it doesn't sound like you did :/
it's pretty lengthy and explains everything you were asking pretty nicely, I thought.
-
Oct 22nd, 2009, 12:50 AM
#14
Re: My web server address?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|