View Full Version : Useing a Mac as a webserver...
MacEffects
May 11, 2005, 05:14 AM
I am trying to set up my Mac (iMac 700/512/60) that is a spare Mac that I need to try to figure out how to use that as a Backend for my site, where it can handle Apache web server, and MySQL database server, and others... The site is being hosted from GeoCites, that does NOT Support Backend (CGI/PHP/SQL/ETC) and they are just horrible with things like that... My goal is to make a login system for the site, and some other things like that... I can also offer some $$$ for someone who can set that login stuff up.... I really need to get this thing done ASAP so please let me know if you can help or offer any help.
Thanks!
whocares
May 11, 2005, 06:20 AM
Your biggest problem will be not having a static IP... but there are ways around that, someone else can help you out with that. Your other problem will be bandwidth and upload speeds ; if you're expecting heavy traffic, it's going to be slooooow.
Apache is preinstalled with OS X (I'm assuming you're running OS X) and just needs to be started (via the Sharing panel in System Preferences). The default folder for your website is "Sites" in your home folder. To access the site from your machine:
http://127.0.0.1/~username/
And to access from a distant computer:
http://your_IP_#/~username/
PHP is also preinstalled with OS X but a bit more tricky to get working (involves use of the Terminal). MySQL is not installed so you need to download a package for it. Marc Liyanage's site (http://www.entropy.ch/software/macosx/) is a good source for that and includes some installation tips (you should also find a package for installing and starting PHP which I recommend you use). I also recommend CocoaMySQL (http://cocoamysql.sourceforge.net/) for administration your database(s) ; it's a free, opensource GUI for MySQL (others might recommend PHPMyAdmin).
Hope this helps you getting starting...
I can also help with the loggin stuff ;)
--------
It may be easier if you get some cheap hosting that includes PHP/MySQL. Other members here will be able to recommend good hosting that fit your needs. Just a thought.
Mitthrawnuruodo
May 11, 2005, 06:43 AM
To enable php on localhost with minimal use of Terminal:
1) Open Terminal ( :rolleyes: ) and type open /etc/httpd
2) Drag httpd.conf to Desktop (or wherever), it should be copied over, and not moved by default.
3) Make a copy of the httpd.conf file for backup purposes.
4) Open the httpd.conf file using a text-only editor (my favorite is TextWrangler, but SubEthaEdit is another nice, free one). Apple's TextEdit will also work, but make sure it's not in rtf mode.
5) Find the line (about line 240):
# LoadModule php4_module libexec/httpd/libphp4.so
and remove the '#'
6) Find the line (about line 284):
# AddModule mod_php4.c
and remove the '# '
7) Save the file and quit the text editor
8) Drag'n'drop the httpd.conf file back into the /etc/httpd folder (in the open Finder window)
9) Authenticate with admin password when asked
10) Agree to replace the existing file
11) Restart apache by stopping and starting the Personal Web Sharing option in System Preferences -> Sharing -> Services
Now, php should work when accessing your Sites folder using http://localhost/~user/ (or http://computername/~user/ or http://computername.local/~user/ or http://127.0.0.1/~user/ or http://ipaddress/~user/ ;)) in your browsers...
MacEffects
May 11, 2005, 06:43 AM
WhoCares: Okay, well after looking at the details on that I think you are right, to be honest I do NOTHING about that sort of work, I know NO PHP,SQL,CGI etc, I thought I could get away with just copying free codes, but it turns out this may be quite a pain, however I have been trying to get some sort of login for my site, but since I no nothing about it I have no idea what do...
I am all for a hosting service but I have paid for those before with people saying they could help me set it up and sure enough the would only help for like $250-400 (Money I really can't afford right now)... However I can pay 100 at most, and I have plenty of Macs for trade or trade any money, if you or someone else could sort of 'do all the work' :) as I have no idea what I am doing, but like I said I can get a host service but as soon as I see a CPanel I have no idea what ANYTHING is or does... When it comes to things like this I wish there was an easy way out but the longer I wait the more I need one...
Please do let me know if there is any way I could pay you to set it up after I pay for the hosting thing, and get it to where I need it. I did want a PHP Search but right now I just need a BASIC Login 'System' please do let me know.
MacEffects
May 11, 2005, 07:00 AM
I did not find
"# LoadModule php4_module libexec/httpd/libphp4.so" in the code, but I did all the other steps, I think it may work, w/o that, but since there is no site on my Mac (it is on GeoCites) the testing may be a bit, well that and I have no idea what am doing
:eek: :D .... But I will try every way I can until somthing works
(also, let me know if by not having that code I will have some sort of deserter on my computer like Kernel Panic, :rolleyes: )
whocares
May 11, 2005, 07:10 AM
To find out if it's working, create a file called 'test.php' with a text editor containing :
<?php
phpinfo();
?>
Put it in your Sites folder, open a browserwindow and type
http://127.0.0.1/~username/test.php
If PHP is working, you should get a page with general information on your PHP config/installation. If PHP is not working, you'll just see the code...
If it doesn't work, check out Marc's packages to install/start PHP (see my previous post for link.
---
What kind of login do you need? Multiple users or just one user?
macmaniacttt
May 11, 2005, 08:00 AM
Once you've got the webserver up, email me at macmaniacttt@gmail.com and I'll give you some code for a simple PHP/MySQL login scheme...
-david
MacEffects
May 11, 2005, 08:46 AM
Well, I think I broke something because Personal Web Sharing will not turn back on, I did find the line, and deleted the # symbol... When I try to turn it on it says "Web Sharing Starting up..." and just stays like that... Any ideas how to get that to work, or should I just pay for service?
Mitthrawnuruodo
May 11, 2005, 08:48 AM
It might have something to do with the fact that you only altered one of the two php-lines mentioned above in the httpd-conf file...
And there's a chance that permissions may play a part. Try repairing them (httpd.conf should be mentioned in the once in need of repair).
MacEffects
May 11, 2005, 09:33 AM
Okay, i used the backed up one to replace the whole file and i worked, so i don't know what to do... The file did have a different icon then the other in that folder and the original.. I used one of the editors mentioned above, so I am unsure what to do, but I will look ok Google to find another editor to see if that works.
feakbeak
May 11, 2005, 09:51 AM
Perhaps you saved the file in a different format, such as RTF? That would good explain why the web service did not start. If the icon changed, this is a likely reason for the problem.
Having someone else set up your simple login might be fine for now since you are not familiar with any of these technologies. However, I would strongly recommend reading some tutorials, picking up a few books or even taking a course or two related to these topics. The reason is that even if someone else gets you up and running it will be very difficult to maintain without the knowledge of how it works. You can always pay people to fix it whenever you have a problem, but that gets expensive and you seem to be on a budget.
I'm not saying you shouldn't pay someone to help you out now, but I would also start investing in becoming more knowledgable about running dynamic websites so that you can save yourself time, money and effort in the future.
Good luck!
MacEffects
May 11, 2005, 11:06 AM
Success after about an hour of work I got the PHP info to show up and the PHP has a LOT of INFO on that page... What do I do now? And is the next step simple :D .
Please let me know.
csubear
May 11, 2005, 11:18 AM
How much bandwidth do you need for your site? Will your home cable or dsl modem handle it?
If so, host it your self. You can get dynamic-dns from www.no-ip.com, for real cheap.
MacEffects
May 11, 2005, 11:27 AM
Well there will be a small amount of people about (500-1000 per month). And I have the iMac hooked to a DSL line, so the speed should be alright. I would like to use my computer if possible to save money... But if you think I should do otherwise please let me know.
MacEffects
May 11, 2005, 11:57 PM
Okay, I am still having problems, I got Navicat and CocaMySQL and it show stuff about ports, and all kinds of stuff that I have no idea about. I think I need step by step help on this. Again if some one could help me 'do all the work' (probably simple for some of you ) I would always pay for that, it is just set up that needs done, just the basics.
What I am trying to do:
Have Basic Login it does not have to be ultra secure or anything, I will pay for a service if needed or I can use my iMac. Thing is there will only be under 10 or so user names and passwords, just to view a certain section on the site (sounds simple enough) :rolleyes: .... But any more help would be great and much appreciated.
whocares
May 12, 2005, 06:13 AM
If it's only for a few users who aren't expected to change passwords very often, I think the best solution might be limited access directories. This is server level so you need to configure the Apache server on your iMac.
The first step is to create a file containing a liste of usernames and passwords. This file needs to be placed somewhere that can't be accessed by HTTP, ie typically outside of the 'Sites' folder. To create it type in Terminal:
htpasswd -cb /Users/your_username/Desktop/access username password
This will create the file on your Desktop (you should move it later, but not to Sites folder!) and add the first user (username and password). To add subsequent users, type the following command:
htpasswd -b /Users/your_username/Desktop/access username2 paswword2
That was the easy part :) Now we need to modify your Apache configuration file httpd.conf. First make a backup of it:
sudo cp /etc/httpd/httpd.conf /etc/httpd/httpd.conf.bak
This will prompt you for your root password. Now open the httpd.conf in pico text editor:
sudo pico /etc/httpd/httpd.conf
Scroll down to the bottom of the file (arrows or Control + V). Once your at the bottom, add the following:
<Directory /Users/your_username/Sites/protected_folder/>
AuthType Basic
AuthName "Password Required For This Area"
AuthUserFile absolute_path_to_access_file
Require user username username1
</directory>
Don't forget to set your username where appropriate, set the absolute path to your access file (starting with a slash /). List all usernames that have access to the folder seperated by a space. Now save the file (control + O, then hit enter) and quite (control + X). Restart webserver and test.
You may of course do this for several directories, just copy, paste and change the directory name. This protects the directory and all sub-directories.
You can also create usergroups which can make it simpler to grant access. I'll post that later, it's time for lunch.
Hope this helps, works and seems clear enough to follow :) Post if you need more help or I messed up.
whocares
May 12, 2005, 06:29 AM
Okay, I am still having problems, I got Navicat and CocaMySQL and it show stuff about ports, and all kinds of stuff that I have no idea about. I think I need step by step help on this. Again if some one could help me 'do all the work' (probably simple for some of you ) I would always pay for that, it is just set up that needs done, just the basics.
CocoaMySQL is asking for the parameters to connect to the MySQL database server. Of course, if you haven't installed MySQL, CocoaMySQL will be pretty useless :o
Simple MySQL installation (clicking and copy/pasting commands into Terminal) is available here (http://www.entropy.ch/software/macosx/mysql/).
MacEffects
May 12, 2005, 06:35 AM
Wow, that is sure a lot of work :rolleyes: I will get started trying to do that, how ever another problem my Router (D-Link DI-604) something else must be blocking out side users (out side my local network) because when I tested from a local library and had send people the link (http://xx.xxx.x.xx/~xxxxx) it said not found, and it worked in my network, so I should try to fix that too other wise this will not work... I did talk to about 4 hosting sites and they ALL told me I should NOT Buy any services for that (and thats odd form companies :rolleyes: :D ) so I think you are right my best bet is to my iMac that coincidentally is always on.
And ideas about the router?
MacEffects
May 12, 2005, 06:46 AM
Okay I messed up on the simple part :(... On Terminal I put
"htpasswd -cb /Users/ihateyou/Desktop/access testuser1 mypassword" in and it says "Adding password for user testuser1" what dose that mean, I did not see any folder? Also may be since the iMac has two user account "ihateyou" (a bad day on the computer was the cause for that name:) ) and "somethingelse", so that is why I put "/Users/ihateyou/Desktop/" so it would work, unless that is wrong, as I have no idea... What should I be looking for?
whocares
May 12, 2005, 07:01 AM
Okay I messed up on the simple part :(... On Terminal I put
"htpasswd -cb /Users/ihateyou/Desktop/access testuser1 mypassword" in and it says "Adding password for user testuser1" what dose that mean
Means that it should be good. Check your desktop for any new files called access ;)
whocares
May 12, 2005, 07:05 AM
And ideas about the router?
The router needs to know where to route the HTTP request to, ie which computer on your home network should answer the 'internet' requests.
This is done on the router setup page (usually accessed with http://192.168.1.1); some documenttation should come with your router. I guess you're using DHCP (dynamic) IP leases, so each time you restart your computer, it's IP might change and the routing tables messed up. Someone else needs to help you out on this one...
MacEffects
May 12, 2005, 07:30 AM
Okay, now I am stuck on the Hard part:)... I found the access it was on my desktop (I have way to much on there it got lost)... I am unsure what I should do with the codes below, I put them in terminal but I do not know, it gets more and more confusing :rolleyes: .
sudo cp /etc/httpd/httpd.conf /etc/httpd/httpd.conf.bak
This will prompt you for your root password. Now open the httpd.conf in pico text editor:
sudo pico /etc/httpd/httpd.conf
Scroll down to the bottom of the file (arrows or Control + V). Once your at the bottom, add the following:
<Directory /Users/your_username/Sites/protected_folder/>
AuthType Basic
AuthName "Password Required For This Area"
AuthUserFile absolute_path_to_access_file
Require user username username1
</directory>
whocares
May 12, 2005, 08:59 AM
Basically, you're modifiying httpd.conf with is Apache configuration file (a bit like Preference Panel for OS X, but no GUI ;) ). The first command is just a back up. Copy, paste into terminal and hit return. Easy.
The second command opens httpd.conf in the pico text editor (a command line editor - like Woed, minus the GUI). It looks ugly but is quite easy to use. Copy and paste the command into Terminal. Once you hit return, it will open the file. Press Control+V until you reach the bottom of the file (should be obvious when you reach it).
The cursor is a grey rectangle, make sure its on a new line (use arrows to go to the last line, and return to add a new line). Now copy the last bit of code and paste it in on the last line of your httpdf.conf file.
You now need to save the changes (Control+O, then return), and exite (Control+X). You're now done with Terminal and can close it. Restart Webserver in System Preference.
Mechcozmo
May 12, 2005, 10:07 AM
Here is a linkety (http://www.no-ip.com) to a place to help out with your IP woes...
feakbeak
May 12, 2005, 10:19 AM
Well you now have a link to help you with DDNS to get your domain linked to your home IP address.
You will still need to configure your router correctly though. Here is a link (http://www.portforward.com/dlink/di-624+.htm) that talks about port forwarding and how to set it up on a DLink router. I recall you telling me you had DLink, but don't recall the model. You will also want to make sure that your iMac gets a static IP on your LAN so that the port-forwarding rule will always work properly.
MacEffects
May 12, 2005, 10:41 AM
Okay, lots of work for me :) :rolleyes: ... I have been working way to hard on this I have been up more then 20+ hours (with other projects too, plus my main PB G4 Died - long day) and my mind is gone, so I will get some sleep (just so you all know I still need a great deal more of help and did not thing I am ignoring this post) and try all of the things above, and let you all know how they go. About the No-IP site why dose everyone tell me I need this, and what is its purpose?
MacEffects
May 14, 2005, 09:18 PM
Okay, Sorry about the delay my iMac (only good internet Mac here) needed a New OS... Mean while I took the time to go to login at no-ip.com and have an account there (I don't know what good it will do me), and have reset up the code the New OS messed up... So what do I do now? Yet again I am lost :rolleyes: :confused: .
jared_kipe
May 15, 2005, 12:54 AM
How can you make it so instaead of typing in xxx.xxx.xxx.xxx/~usrname/ you can just type in the ip address and it forwards to the ~usrname folder by default?
MacEffects
May 15, 2005, 02:35 AM
How can you make it so instaead of typing in xxx.xxx.xxx.xxx/~usrname/ you can just type in the ip address and it forwards to the ~usrname folder by default?
Good Question, I had been wondering that upon many other things, this all seems hard, but I have motovation to do it, so hopefully soon... Also Nice Tar!
That reminds me, if some one else has a service an login system set up, may be we could 'share it' for a good price :D ... I need to get a basic one done ASAP... And help would be GREAT!
Also with the No-IP.com they gave me an IP of 4.62.75.227, what does this mean, and what do I do with that and the service?
Please let me know.
Thanks All!
jestershinra
May 15, 2005, 02:57 AM
How can you make it so instaead of typing in xxx.xxx.xxx.xxx/~usrname/ you can just type in the ip address and it forwards to the ~usrname folder by default?
Put your website in your /Library/Webserver/Documents folder, not ~/Sites.
jestershinra
May 15, 2005, 03:00 AM
That reminds me, if some one else has a service an login system set up, may be we could 'share it' for a good price :D ... I need to get a basic one done ASAP... And help would be GREAT!
Try this one: http://www.evolt.org/article/PHP_Login_System_with_Admin_Features/17/60384/
Also with the No-IP.com they gave me an IP of 4.62.75.227, what does this mean, and what do I do with that and the service?
Install their client. You may need to download it from their site. Once you've installed it, input your no-ip account name and password, and set it as a startup item. Then, you can forget about it.
Mitthrawnuruodo
May 15, 2005, 09:16 AM
How can you make it so instaead of typing in xxx.xxx.xxx.xxx/~usrname/ you can just type in the ip address and it forwards to the ~usrname folder by default?Edit the /etc/httpd/httpd.conf file. Find:#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/Library/WebServer/Documents" and #
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/Library/WebServer/Documents"> and change it to your users Sites folder...
MacEffects
May 15, 2005, 11:12 AM
Okay, so where is the spot I put the Login system code? does no-ip automatically goto it, or how does that work? Please let me know.
Try this one: http://www.evolt.org/article/PHP_Login_System_with_Admin_Features/17/60384/
Install their client. You may need to download it from their site. Once you've installed it, input your no-ip account name and password, and set it as a startup item. Then, you can forget about it.
MacEffects
May 15, 2005, 11:18 AM
Also when I go to the IP that (should?) go to my computer, it just sits there when I type it in on Safari? What is that about, did I do something wrong?
Please let me know.
MacEffects
May 15, 2005, 12:15 PM
More Info I found out... Someone just told me not to use PHP, or anything like that and I could do a simple Java/JavaScript code to allow a few usernames (1-9) and a few passwords (1-9) and just to view a page a login is all I need, please do let me know, at this point (I have tried much w/ no success) I am lookin for the easy way out :rolleyes: :D .
jestershinra
May 15, 2005, 01:47 PM
Also when I go to the IP that (should?) go to my computer, it just sits there when I type it in on Safari? What is that about, did I do something wrong?
Please let me know.
You'll need to forward port 80 to your computer. That's done in your router's configuration. While you're there, forward 16080 as well.
More Info I found out... Someone just told me not to use PHP, or anything like that and I could do a simple Java/JavaScript code to allow a few usernames (1-9) and a few passwords (1-9) and just to view a page a login is all I need, please do let me know, at this point (I have tried much w/ no success) I am lookin for the easy way out.
...If you want the very easy way out, use .htaccess (HTTP authentication). You'll be up and running in a few minutes. Of course, it's not the most secure, and you don't have a ton of control.
jestershinra
May 15, 2005, 01:53 PM
Okay, so where is the spot I put the Login system code? does no-ip automatically goto it, or how does that work? Please let me know.
AARGH- i just had this long thing written out, and I just lost it. Dammit!
Essentialy- put the files in their own directory. If you want that to be the only site, put them in the root (/Library/Webserver/Documents). Then, create a new MySQL database, and a new user to go along. Remeber the db name and username. Next, open includes/constant.php and edit the first four variables, according to the settings you just specified for mysql.
Now, try going to http://127.0.0.1/main.php and see what happens.
edit: If you want me to help you configure this, I can. Drop me a PM- I actually just set one of these up yesterday, so I'm willing to set this up for you.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.