Enable PHP to run PHP driven websites
From OpenFSG
Contents |
Requirements
- A dynamic DNS account
- A MySQL database (and basic understanding of setting up a database)
- A Folder mapped by the FSG
- PHP Software
- Configured HTTP Service
Setting up PHP
- PHP websites can only be parsed either through a dynamic DNS service (like no-ip.com / dyndns.org etc.) OR a generic name (see below). Read the HowTo Host a Web Site for the appropriate details on setting up a dynamic dns account. In this topic the example mywebsite.dyndns.org is used.
- PHP is typically used with a MySQL database. It can also parse HTML code, in fact, you CAN rename all your exisiting .html files to .php and they will still work. However, to fully unleash the possibilities of PHP you will have need of an interactive database. From the configuration menu on the FSG, goto Services --> SQL Server, making sure the SQL Server is set to run and open to the outside. Apply and return to setup a database and user permissions through the SQL Administration page (set Account Administrator first).
- From the configuration menu on the FSG, goto Folders and create a folder, e.g. 'public_html'.
- Upload all the PHP files to that folder, either through a Filemanager (like Windows Explorer) or FTP.
- From the configuration menu on the FSG, goto Services --> HTTP Server and start a new configuration:
- Name: any name e.g. 'public_access'
- DNS name: public.mywebsite.dyndns.org
- Port: 80 (you can use any, but beware of special ports)
- Folder: from the drop down list use 'public_html' (or whatever folder you created)
- Enable PHP: box should be checked
Now apply
Using a generic name instead of a DDNS name
So what if your FSG is not connected to the internet or you do not want it to have a DDNS name?
NOTE: Best is to create real DDNS names for as many sites as you want and create entries to them in the website setup.
If you do not want, or can't setup DDNS names for real, try the following:
Lets look at an example: You have installed a phpBB forum on the FSG. Your DDNS name would be:
DNS name: forum.something.fsg
If you type in "forum.something.fsg" this would actually bring you to the FSG (as a proper setup DDNS name should) then you will see your page with PHP enabled.
Off course in the case you are not connected to the internet it won't, since forum.bla.bla doesn't go anywhere. There are several tricks to solve this.
Single front page
- Start with using SSL for your config pages. Switch on SSL encryption in the main services/http section. Be aware! Your config pages can now only be reached through httpS://ip_of_FSG
You take this step because the next step will divert all incoming requests to your FSG front page. If you forget this step all incomming traffic will still be diverted to the normal config and users pages and your new PHP page will not show. The config pages have higher precedence. - Go to the website creation and use the following:
Name: some_name DNS name: * Port: 80 Folder: path_to_phpbb2 Enable PHP 4 yes please
The "*" DNS name will tell apache to direct ALL incomming request no matter what name or IP to your front page.
NOTE: Be careful, phpBB takes a part of the website name from the settings in apache. That means your request for the admin page may be redirected through phpBB to http://*/admin_something which off course just brings up an error since no IP address is linked to *. Make sure that during the install of phpBB the website has a proper name, such as the IP address of the FSG, instead of "*". You may have to go into phpmyadmin and do a search for "*" or server name or something on the phpbb database and change it there. There is a script available on the phpBB forums that does something similar, but I don't know where it is anymore.
This last step will care for it that your phpBB is only reachable from the network that can "see" the IP address you have redirected phpbb to and no longer from both LAN and WAN.
Second and further pages
Using this method it is difficult to add many pages, since the "*" catches them all and you need some type of tag to show apache which page you want. You can try naming the sites (DDNS name in webpage config) with the IP address of the interface you want the page to be available on, such as 10.0.0.100 for WAN for page1 and 192.168.1.1 for LAN for page2. Not sure if this works, haven't tried it myself.
Easier is a little extra step. In the main folder, under the main site, create an index page with links to all the websites you have. Then create aliases, like
alias1 folder /path_to_folder_with_website alias /folder alias2 folder /path_to_folder_with_website2 alias /folder2 http://FSG_IP/folder will now point to website1 http://FSG_IP/folder2 will now point to website2
Accessing your PHP driven website
Make sure the index.php is in the 'root' of your newly created folder (e.g. 'public_html'). Now you can either start the installation of the software or run it and upload the database if you already had one.
will useually start the installation. You need the following information to complete the installation/create database:
- database name: as setup through Services --> SQL Server --> SQL administration Page
- database user: as setup through Services --> SQL Server --> SQL administrator
- database host: usually 'localhost'
- database password: as setup through Services --> SQL Server --> SQL administrator
- database type: (MySQL 4)
- database prefix: (optional)
Related
See How To Password Protect A Web Page See How To Host a Web Site See How To Make Use of an Alias
