How can I implement a website using HTML and CSS without functionality?

187 replies · 16K views · last reply
Klaas van Aarsen said:
I think we cannot test php on w3schools. :unsure:
We may need our own server that executes our php code. 🤔
Then again, there may be online php test locations.

Do I have to download something? Or how does this work? 🧐
 
evinda said:
Do I have to download something? Or how does this work?

I've found a php compiler on w3schools now.
However, it doesn't seem to give us the option to create an html form and submit from there. :unsure:

If we want our own local web server, we can install apache. 🤔
 
I have Apache installed on my system and I was able to create a search box so that the submit button runs a php script in cgi-bin:

Firefox browser window showing localhost/test_php.html with a form containing an Input text field holding the word Test and a Submit button below it.


Firefox browser window showing the address localhost/cgi-bin/test_php.php with the page text "input: Test" below the toolbar and bookmarks bar.

:cool:
 
Klaas van Aarsen said:
I have Apache installed on my system and I was able to create a search box so that the submit button runs a php script in cgi-bin:

View attachment 11045

https://www.physicsforums.com/attachments/11046
:cool:
Downloading Apache we get a file Apache -> httpd-2.4.35 -> httpd-2.4.35-o102p-x64-vc14 (and one httpd-2.4.35-o102p-x86-vc14 ) -> Apache24. In the last one there are several files. Do we save the php file that we write in the file "cgi-bin"? And where do we save the html file? Also there? 🧐
 
evinda said:
Downloading Apache we get a file Apache -> httpd-2.4.35 -> httpd-2.4.35-o102p-x64-vc14 (and one httpd-2.4.35-o102p-x86-vc14 ) -> Apache24. In the last one there are several files. Do we save the php file that we write in the file "cgi-bin"? And where do we save the html file? Also there?
The html file should go to something like a /www/html/ directory, where there should already be an index.html file. 🤔
 
Klaas van Aarsen said:
The html file should go to something like a /www/html/ directory, where there should already be an index.html file. 🤔

In the Apache24 file there is "htdocs" which includes an index.html file. Do you mean to save my html file there? :unsure:
 
evinda said:
In the Apache24 file there is "htdocs" which includes an index.html file. Do you mean to save my html file there?
Yep. (Nod)
 
Klaas van Aarsen said:
Yep. (Nod)

It doesn't work (Sweating)

I get:
Browser error page in German showing a sad document icon, the heading "Zugriff auf die Datei nicht möglich", the message "Eventuell wurde sie verschoben, bearbeitet oder gelöscht." and the code ERR_FILE_NOT_FOUND.
I saved the two files like this:

Windows Explorer file list in Greek showing the htdocs folder of an Apache24 install, containing apachehaus (image), example (HTML file, 1 KB) and index (HTML file, 41 KB).


Windows Explorer window showing the Apache24 cgi-bin folder with two files: action.php (PHP file, 1 KB) and printenv.pl (PL file, 1 KB), with Greek interface labels.


Is this wrong? 🧐
 
evinda said:
It doesn't work
I saved the two files like this:

Is this wrong?
That is correct. (Nod)

What do you get if you open http://localhost or http://localhost/index.html in your browser? 🤔
If Apache is working you should get a standard apache html page that shows 'It works!'
If that works, what do you get if you open http://localhost/example.html? 🤔
 
Klaas van Aarsen said:
What do you get if you open http://localhost or http://localhost/index.html in your browser? 🤔
If Apache is working you should get a standard apache html page that shows 'It works!'
If that works, what do you get if you open http://localhost/example.html? 🤔

It doesn't work... I get:

Browser screenshot of localhost/index.html showing the German error page 'Die Website ist nicht erreichbar' with error code ERR_CONNECTION_REFUSED, plus Neu laden and Details buttons.
 
Last edited:
evinda said:
It doesn't wotk. I get:
Then you're not running apache yet.
Can you open the apache application?

Apparently one way to do it on Windows, is to open a command prompt, and type:
Code:
cd ...\Apache24\bin
httpd.exe
where ... should be replaced by the location where you have Apache.
It's explained in the readme_first.html file that is in the top directory. 🤔
 
Last edited:
Klaas van Aarsen said:
Then you're not running apache yet.
Can you open the apache application?

Apparently one way to do it on Windows, is to open a command prompt, and type:
Code:
cd ...\Apache24\bin
httpd.exe
where ... should be replaced by the location where you have Apache.
It's explained in the readme_first.html file that is in the top directory. 🤔

Which of the following files do we use? 🤔

Two Windows folder icons listed by name: httpd-2.4.35-o102p-x64-vc14 and httpd-2.4.35-o102p-x86-vc14.
 
evinda said:
Which of the following files do we use?
Those look the same. :unsure:
Perhaps one of them is a .zip file and the other is the unzipped version.
In that case we need the one that is unzipped.
Either way, we'll find out if we open a command prompt. 🤔

If I do it on my Windows I get:
Windows Command Prompt showing a directory listing in Downloads with a folder httpd-2.4.46-o111k-x86-vc15 and a zip file of the same name, followed by a cd into its Apache24\bin folder and the command httpd typed.
 
evinda said:
Which of the following files do we use?
Oh wait. (Wait)
I see now that one is for x64 and the other is for x86.
The first would be a 64-bit version and the other is a 32-bit version.
Either should work. 🤔
 
Klaas van Aarsen said:
Those look the same. :unsure:
Perhaps one of them is a .zip file and the other is the unzipped version.
In that case we need the one that is unzipped.
Either way, we'll find out if we open a command prompt. 🤔

If I do it on my Windows I get:
View attachment 11052

I get:

httpd: Syntax error on line 39 of C:/Users/evinda/Desktop/Apache/httpd-2.4.35/httpd-2.4.35-o102p-x86-vc14/Apache24/conf/httpd.conf: ServerRoot must be a valid directory

🧐
 
evinda said:
I get:

httpd: Syntax error on line 39 of C:/Users/evinda/Desktop/Apache/httpd-2.4.35/httpd-2.4.35-o102p-x86-vc14/Apache24/conf/httpd.conf: ServerRoot must be a valid directory
We have to edit that httpd.conf file.
It contains
Code:
Define SRVROOT "/Apache24"

I've changed mine to:
Code:
Define SRVROOT "C:\Users\vanaarse\Downloads\httpd-2.4.46-o111k-x86-vc15\Apache24"
and it works now. 🤔
 
Klaas van Aarsen said:
I've changed mine to:
Code:
Define SRVROOT "C:\Users\vanaarse\Downloads\httpd-2.4.46-o111k-x86-vc15\Apache24"
and it works now. 🤔

So we just write "C:\Users\evinda\Desktop\Apache\httpd-2.4.35\httpd-2.4.35-o102p-x86-vc14\Apache24>"... We don't have to edit something else, do we? 🧐

When we get no error, it means that it works, right? 🤔

What do we do next? 🧐
 
evinda said:
So we just write "C:\Users\evinda\Desktop\Apache\httpd-2.4.35\httpd-2.4.35-o102p-x86-vc14\Apache24>"... We don't have to edit something else, do we?

When we get no error, it means that it works, right?

What do we do next?
Open http://localhost in your browser and see if an apache web page shows up.
And if you have your example.html in the correct htdocs directory, we can also try http://localhost/example.html. 🤔

Btw, there should not be a '>' at the end of the path. :eek:
 
Klaas van Aarsen said:
Open http://localhost in your browser and see if an apache web page shows up.
And if you have your example.html in the correct htdocs directory, we can also try http://localhost/example.html. 🤔

I open http://localhost and I get:

Browser error page for localhost in German reading Die Website ist nicht erreichbar, with error code ERR_CONNECTION_REFUSED and a Neu laden button.


So it still doesn't work, right? (Sweating)

Klaas van Aarsen said:
Btw, there should not be a '>' at the end of the path. :eek:
I wrote:

cd C:\Users\evinda\Desktop\Apache\httpd-2.4.35\httpd-2.4.35-o102p-x86-vc14\Apache24

and I got:

C:\Users\evinda\Desktop\Apache\httpd-2.4.35\httpd-2.4.35-o102p-x86-vc14\Apache24> 🧐
 
evinda said:
I open http://localhost and I get:

So it still doesn't work, right?

I wrote:
cd C:\Users\evinda\Desktop\Apache\httpd-2.4.35\httpd-2.4.35-o102p-x86-vc14\Apache24
and I got:
C:\Users\evinda\Desktop\Apache\httpd-2.4.35\httpd-2.4.35-o102p-x86-vc14\Apache24>
Yes, but the '>' is not part of the path and must not be in the httpd.conf file.
It seems likely that is the reason that it does not work yet. 🤔

Furthermore, in the Apache24 directory there is a 'logs' directory that contains the file 'error.log'.
It will contain a line at the end that clarifies why apache does not work yet. 🤔
 
Klaas van Aarsen said:
Yes, but the '>' is not part of the path and must not be in the httpd.conf file.
It seems likely that is the reason that it does not work yet. 🤔

Furthermore, in the Apache24 directory there is a 'logs' directory that contains the file 'error.log'.
It will contain a line at the end that clarifies why apache does not work yet. 🤔

In Apache directory I have:

Windows Explorer file listing of an Apache server install folder, showing subfolders bin, cgi-bin, conf, error, htdocs, icons, include, lib, logs and modules, followed by files ABOUT_APACHE, CHANGES, INSTALL, LICENSE, NOTICE, OPENSSL-NEWS, OPENSSL-README and README.


In the log directory I have:

Windows File Explorer showing the logs folder under Apache24, containing a single file named install, modified 19/9/2018 at 5:15 am, with Greek column headers.


There is also a error directory which contains:

Windows File Explorer listing the Apache24 error folder with an include subfolder, contact.html, HTTP error pages such as HTTP_NOT_FOUND.html and HTTP_FORBIDDEN.html, and a README file.


🧐 🧐 🧐
 
evinda said:
In Apache directory I have:

In the log directory I have:

There is also a error directory which contains:
Ah, the error.log is not there yet because the path is wrong, so Apache can't write error.log to its proper location yet.
If we fix the path and run httpd.exe again, then the error.log file will appear in the 'logs' directory. 🤔
 
Klaas van Aarsen said:
Ah, the error.log is not there yet because the path is wrong, so Apache can't write error.log to its proper location yet.
If we fix the path and run httpd.exe again, then the error.log file will appear in the 'logs' directory. 🤔

I wrote now:

C:\Users\evinda\Desktop\Apache\httpd-2.4.35\httpd-2.4.35-o102p-x86-vc14\Apache24\conf>httpd.conf

and then I got:

Screenshot of the commented header of an Apache HTTP server httpd.conf file, with lines explaining ServerRoot, logfile paths, and the Define SRVROOT "/Apache24" setting.


Text excerpt from an Apache httpd.conf file showing the Mutex, Listen and DSO LoadModule directives, with the Listen 80 line active and many LoadModule lines commented out with #.


Excerpt from an Apache httpd.conf file listing LoadModule directives, most lines with a leading # to comment them out, such as autoindex_module, cgi_module, env_module and proxy_module.


Excerpt of an Apache httpd.conf file showing a list of commented-out and active LoadModule directives, followed by an IfModule unixd_module block with comments about the User and Group settings.


Screenshot of the commented main server section of an Apache httpd.conf file, showing User daemon, Group daemon, ServerAdmin admin@example.com, ServerName localhost:80 and a Directory block denying all access by default.


Excerpt from an Apache httpd.conf file showing the DocumentRoot and Directory settings for the htdocs folder, Options and AllowOverride directives, DirectoryIndex index.html, and rules denying access to .ht* files.


Excerpt of an Apache httpd.conf file showing commented ErrorLog and LogLevel warn directives, a log_config_module block with LogFormat lines, and a commented CustomLog directive.


Excerpt of an Apache httpd.conf file showing commented IfModule blocks for alias_module and cgid_module, with ScriptAlias /cgi-bin/ and a Directory section for the cgi-bin path.

Excerpt of an Apache httpd.conf file showing an IfModule mime_module block with TypesConfig conf/mime.types, commented AddType, AddEncoding and AddHandler directives, and AddType lines for x-compress and x-gzip.


Excerpt of an Apache httpd.conf configuration file showing commented-out directives for MIMEMagicFile, ErrorDocument, MaxRanges, EnableMMAP, EnableSendfile, AcceptFilter and Include conf/extra/httpd-mpm.conf.


Excerpt from an Apache httpd.conf file showing commented and active Include directives for extra configuration files, including SSL and HTTP/2 module settings.


So Apache is working now, or not? 🧐
 
evinda said:
I wrote now:
C:\Users\evinda\Desktop\Apache\httpd-2.4.35\httpd-2.4.35-o102p-x86-vc14\Apache24\conf>httpd.conf
and then I got:
So Apache is working now, or not?
I'm afraid not. :oops:

Let's go through it step by step.
  1. We start with the command prompt that you have.
    It shows C:\Users\evinda\Desktop\Apache\httpd-2.4.35\httpd-2.4.35-o102p-x86-vc14\Apache24\conf>.
  2. Type C:\Users\evinda\Desktop\Apache\httpd-2.4.35\httpd-2.4.35-o102p-x86-vc14\Apache24\conf> notepad httpd.conf, which will open the configuration file in notepad.
  3. Near the top, which is also in your first screenshot, there is a line that reads Define SRVROOT "/Apache24".
    Change that line to Define SRVROOT "C:\Users\evinda\Desktop\Apache\httpd-2.4.35\httpd-2.4.35-o102p-x86-vc14\Apache24"
  4. Save the file and close notepad.
  5. Type C:\Users\evinda\Desktop\Apache\httpd-2.4.35\httpd-2.4.35-o102p-x86-vc14\Apache24\conf> cd ..\bin.
  6. Type C:\Users\evinda\Desktop\Apache\httpd-2.4.35\httpd-2.4.35-o102p-x86-vc14\Apache24\bin> httpd.exe, which should start apache.
    The prompt will not return.
    Later on, if we want to, we can stop apache by pressing Ctrl+C, after which the prompt will return.
  7. Check if we can open http://localhost in the browser.
(Sweating)
 
Klaas van Aarsen said:
I'm afraid not. :oops:

Let's go through it step by step.
  1. We start with the command prompt that you have.
    It shows C:\Users\evinda\Desktop\Apache\httpd-2.4.35\httpd-2.4.35-o102p-x86-vc14\Apache24\conf>.
  2. Type C:\Users\evinda\Desktop\Apache\httpd-2.4.35\httpd-2.4.35-o102p-x86-vc14\Apache24\conf> notepad httpd.conf, which will open the configuration file in notepad.
  3. Near the top, which is also in your first screenshot, there is a line that reads Define SRVROOT "/Apache24".
    Change that line to Define SRVROOT "C:\Users\evinda\Desktop\Apache\httpd-2.4.35\httpd-2.4.35-o102p-x86-vc14\Apache24"
  4. Save the file and close notepad.
  5. Type C:\Users\evinda\Desktop\Apache\httpd-2.4.35\httpd-2.4.35-o102p-x86-vc14\Apache24\conf> cd ..\bin.
  6. Type C:\Users\evinda\Desktop\Apache\httpd-2.4.35\httpd-2.4.35-o102p-x86-vc14\Apache24\bin> httpd.exe, which should start apache.
    The prompt will not return.
    Later on, if we want to, we can stop apache by pressing Ctrl+C, after which the prompt will return.
  7. Check if we can open http://localhost in the browser.
(Sweating)

It works now! (Clapping)

So to run the program I save the html file in the "htdocs" directory and the php in the "cgi-bin" directory, right? 🧐

Windows Explorer folder listing of an Apache web server installation, with folders bin, cgi-bin, conf, error, htdocs, icons, include, lib, logs and modules, followed by text files ABOUT_APACHE, CHANGES, INSTALL, LICENSE, NOTICE, OPENSSL-NEWS, OPENSSL-README and README, with dates and sizes in Greek.
 
evinda said:
It works now!
Nice. (Sun)

evinda said:
So to run the program I save the html file in the "htdocs" directory and the php in the "cgi-bin" directory, right?
Yep. (Nod)
 
Klaas van Aarsen said:
Yep. (Nod)

I open http://localhost/example.html and after giving the input I get:
Browser error page with a sad document icon, reading in German: Zugriff auf die Datei nicht möglich, Eventuell wurde sie verschoben, bearbeitet oder gelöscht, ERR_FILE_NOT_FOUND.
I saved the two files as follows in the directory we said in the previous post:
File Explorer window in Greek showing the cgi-bin folder under Apache24, containing two files: action (PHP file, 1 KB) and printenv.pl (PL file, 1 KB).


Windows File Explorer showing the Apache htdocs folder with three files: apacheshaus (image, 5 KB), example (HTML, 1 KB) and index (HTML, 41 KB).


At the logs directory there is now a file with the name "error":
Windows File Explorer showing the Apache24 logs folder with five files: access, error, httpd.pid, install and ssl_request, all dated 4/4/2021 except install, dated 19/9/2018.


And in this file I get:

[Sun Apr 04 01:51:22.887386 2021] [ssl:warn] [pid 17024:tid 540] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sun Apr 04 01:51:23.427353 2021] [ssl:warn] [pid 17024:tid 540] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sun Apr 04 01:51:23.428355 2021] [mpm_winnt:notice] [pid 17024:tid 540] AH00455: Apache/2.4.35 (Win32) OpenSSL/1.0.2p configured -- resuming normal operations
[Sun Apr 04 01:51:23.428355 2021] [mpm_winnt:notice] [pid 17024:tid 540] AH00456: Server built: Sep 17 2018 21:34:44
[Sun Apr 04 01:51:23.428355 2021] [core:notice] [pid 17024:tid 540] AH00094: Command line: 'httpd.exe -d C:/Users/evinda/Desktop/Apache/httpd-2.4.35/httpd-2.4.35-o102p-x86-vc14/Apache24'
[Sun Apr 04 01:51:23.541351 2021] [mpm_winnt:notice] [pid 17024:tid 540] AH00418: Parent: Created child process 15708
[Sun Apr 04 01:51:26.324483 2021] [ssl:warn] [pid 15708:tid 584] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sun Apr 04 01:51:26.496066 2021] [ssl:warn] [pid 15708:tid 584] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sun Apr 04 01:51:26.501077 2021] [mpm_winnt:notice] [pid 15708:tid 584] AH00354: Child: Starting 64 worker threads. (Sweating)(Sweating)(Sweating)
 
evinda said:
I open http://localhost/example.html and after giving the input I get:
I saved the two files as follows in the directory we said in the previous post:
At the logs directory there is now a file with the name "error":
And in this file I get:

It seems there is nothing relevant in the error.log file at this time. :confused:

What is the address in your browser after you submit the input?
Perhaps it does not match the location of the .php file?
It should be http://localhost/cgi-bin/action.php. 🤔
 
Klaas van Aarsen said:
It seems there is nothing relevant in the error.log file at this time. :confused:

What is the address in your browser after you submit the input?
Perhaps it does not match the location of the .php file?
It should be http://localhost/cgi-bin/action.php. 🤔

No, it is http://localhost/action.php 🧐
 
evinda said:
No, it is http://localhost/action.php
It is correct then that it cannot find it. 🧐

We need to modify example.html so that it says action="cgi-bin/action.php". (Sweating)