Technical Discussion
  >> Web Design / HTML / Web hosting Forum


Register (or login) on our website and you will not see this ad.


These posts have been archived and can no longer be replied to or modified.
Pages in this thread: 1 | 2 | (show all)   Print Thread
Standard User camieabz
(legend) Tue 23-Nov-10 10:46:05
Print Post

Recommend an Apache server for Windows


[link to this post]
 
For local testing of .php files. Nothing fancy or complicated if you please. smile

Standard User micksharpe
(eat-sleep-adslguide) Tue 23-Nov-10 11:08:08
Print Post

Re: Recommend an Apache server for Windows


[re: camieabz] [link to this post]
 
I use WebFaction - multiple domains and websites on a single account - ideal for testing but can be slow at times.

P.S. Just realised - you seem to be asking for Windows hosting. Why don't you install Apache on your PC? XAMPP will install Apache, MySQL and PHP on Windows dead easy.

__________________________________________________________________________________________
"Windows Vista Sir?"
"No thanks, I'd rather shove wasps up my nostrils!" .
Mick's Blog | Greasemonkey scripts

Edited by micksharpe (Tue 23-Nov-10 11:12:17)

Standard User ian72
(knowledge is power) Tue 23-Nov-10 11:09:47
Print Post

Re: Recommend an Apache server for Windows


[re: camieabz] [link to this post]
 
Do you mean a host or a package for installing locally or the spec of hardware to run it on?


Register (or login) on our website and you will not see this ad.

Standard User camieabz
(legend) Tue 23-Nov-10 11:12:39
Print Post

Re: Recommend an Apache server for Windows


[re: ian72] [link to this post]
 
I mean a program that can be installed locally jsut to test php files locally, rather than upload them to a remote server to see if they work.

Free software btw. smile

Standard User micksharpe
(eat-sleep-adslguide) Tue 23-Nov-10 11:14:40
Print Post

Re: Recommend an Apache server for Windows


[re: camieabz] [link to this post]
 
Download and install XAMPP - job done.

__________________________________________________________________________________________
"Windows Vista Sir?"
"No thanks, I'd rather shove wasps up my nostrils!" .
Mick's Blog | Greasemonkey scripts
Standard User camieabz
(legend) Tue 23-Nov-10 13:20:24
Print Post

Re: Recommend an Apache server for Windows


[re: micksharpe] [link to this post]
 
Ta for that.

A little chunky at 51MB download and 230 Meg installed, but it does do the job. What's more, my php files work! grin

Standard User camieabz
(legend) Tue 23-Nov-10 14:43:19
Print Post

Re: Recommend an Apache server for Windows


[re: micksharpe] [link to this post]
 
Slight problem with the .php files calling on other files.

I have index.php, header.php and footer.php in the main folder, then have the css in a folder called 'css' and the images in a folder called 'img'.

Now the page works fine using relative paths (e.g. the header calls on "css/main.css"). However, if I create another .php file and put it in a new folder (e.g. test), I would call on the header and footer via:

<?php include '../header.php'; ?>

This works, but for some reason the css and images that the header calls don't work. It's as if they aren't being correctly 'pathed'.

My options seem to be:

Create a css and img folder for each sub folder which hold .php files, which defeats the whole point.

Keep all my .php files in the root folder.

Use absolute referencing (not keen on that, as it adds to file size, and makes changes more in depth).


Or am I doing something wrong?


One other thought.

Once I get the files created, I'll almost certainly want to have the title and meta tags within the head section different for each page. What's the best way to do this, given that my current global header calls from the Doctype declaration down to the first heading in the main body?

Standard User deleted
(deleted) Tue 23-Nov-10 15:30:34
Print Post

Re: Recommend an Apache server for Windows


[re: camieabz] [link to this post]
 
When you use the include command, it calls the file and adds it to the php script that is being run, so the relative paths in the header and footer files will be interpreted as if they are from the test file.

So for example, on my web server the header and footer files are in the parent folder of the web root folder. The relative links however are written as though they are in the web root folder. This works because of how php interprets them.

Basically you need to place all the php files that use the same CSS and image files in the same folder.

As to changing aspects this can be done easily by asigning a variable and then calling the header.

eg
Text
1
23
4
<?php
$page = test;include '../header.php';
?>


Then you can reference this within the header file for all the attributes you wish to change.

It would be best to do so with a switch statement.
Standard User deleted
(deleted) Wed 24-Nov-10 11:08:43
Print Post

Re: Recommend an Apache server for Windows


[re: camieabz] [link to this post]
 
you could call the css using the following code:

<link href="/css/style.css" rel="stylesheet" type="text/css" />

The leading / makes it start from the web root so it works regardless of what directory the php fileis in.

Edited by deleted (Wed 24-Nov-10 11:09:14)

Standard User camieabz
(legend) Wed 24-Nov-10 12:55:47
Print Post

Re: Recommend an Apache server for Windows


[re: deleted] [link to this post]
 
Ahh, spot on!

I had dumped all the files into a sub-folder, so needed to have as /subfolder/css/main.css, rather than /css/main.css

I forget about the 'root' folder aspect of things. Too used to windows.

Ta very much!

Standard User camieabz
(legend) Wed 24-Nov-10 15:42:59
Print Post

Re: Recommend an Apache server for Windows


[re: deleted] [link to this post]
 
Still getting problems due to some files being on different levels to the index.php (thus the calling of the header, and thus the css is wrong).

It occurred to me that all of my pages will use 'header.php'. Equally, I only plan to have one stylesheet, so I'm wondering if it would be easier all round if I include the css code in the head section of header.php

In that sense, there would be no stylesheet, and one less http request. The argument for a stylesheet is that the called for file gets cached. I assume the header.php with the style code would get cached too?

Standard User camieabz
(legend) Wed 24-Nov-10 16:30:08
Print Post

Re: Recommend an Apache server for Windows


[re: deleted] [link to this post]
 
Right. Tis fixed.

The Apache server created a folder called xampp within htdocs. I had dumped all my design pages into this folder, so was not operating from the root folder.

Since moving all to root, all I had to do was add some ../ code to each image line to ensure all relative links moved to root before progressing down their path.

Still not sure whether it's a good idea to keep the css in the header.php or not. One could argue that if header.php were to fail, then I'd lose navigation and styling. That's the only drawback as far as I can see.

Standard User deleted
(deleted) Wed 24-Nov-10 20:24:29
Print Post

Re: Recommend an Apache server for Windows


[re: camieabz] [link to this post]
 
There is a way to do this with php using:

Text
1
$_SERVER["DOCUMENT_ROOT"];


I can check this out at home (I have used it on another website), but basically (I think) it sets the path that your html is in so you can easilly go back and forth using relative links...
Standard User camieabz
(legend) Wed 24-Nov-10 22:44:52
Print Post

Re: Recommend an Apache server for Windows


[re: deleted] [link to this post]
 
Yes, I spotted that in my php googling, but have never used, so was a little unsure of it.

I might look into it later on. Now that my paths are working, I'm keen to move onto other aspects for now. It's definitely one to ponder on before going live.

Standard User deleted
(deleted) Thu 25-Nov-10 11:05:08
Print Post

Re: Recommend an Apache server for Windows


[re: camieabz] [link to this post]
 
There are endless possibilities on how you can organise your code and I am unsure how you are doing yours. When I look back at the coding I did when I first started learning php I am somewhat horrified. Even in the beginning I used templates but I used to cram all sorts into it and still ended up duplicating code (and that defeats the point of templates!).

I still only code php for my own interest really but now I have torn to pieces part of a site I was working on a while ago and use that now as a basis for my coding and I also use smarty which is a template engine that seperates your php and html code.

Nowadays some of my php pages are tiny:

Text
1
23
45
67
89
10
<?php
 include_once("include_files.php");
 //load templates
$smarty->display(TEMPLATE_SITE_LAYOUT);$smarty->display(TEMPLATE_INDEX);
$smarty->display(TEMPLATE_SITE_FOOTER); 
?>


Each page calls include_files.php which defines where everything is and in turn includes many other files. By the time a page has displayed my script will have easily accessed over 20 php files and 3 template files smile

If my 'header' files failed then the whole site would fail but I can't think why it would just fail and losing css is generally an irrelevance to whatever else stops working smile
Standard User camieabz
(legend) Thu 25-Nov-10 14:11:31
Print Post

Re: Recommend an Apache server for Windows


[re: deleted] [link to this post]
 
Do you find that increased requests decrease response times at all?

Standard User deleted
(deleted) Thu 25-Nov-10 14:29:58
Print Post

Re: Recommend an Apache server for Windows


[re: camieabz] [link to this post]
 
No, well certainly nothing perceivable. If you were to look at any CMS (joomla, drupal etc.) or something like phpbb you will see that they all use millions of files all over the place. My setup is very similar to phpbb - i do wonder if someone stripped that down for the site I worked on... and I then took it and stripped it down further! So, I imagine that many people who are more knowledgable than me and create professional products seem to think it has no effect on performance but can lead to much more efficent coding (as long as you remember where everything is! tongue ).

Edited by deleted (Thu 25-Nov-10 14:30:38)

Pages in this thread: 1 | 2 | (show all)   Print Thread

Jump to