676
edits
Tag: 2017 source edit |
mNo edit summary Tag: 2017 source edit |
||
| Line 263: | Line 263: | ||
This command tests the validity of your <code>httpd.conf</code> file and should return the line where the error is encountered. | This command tests the validity of your <code>httpd.conf</code> file and should return the line where the error is encountered. | ||
In addition to common syntax errors due to carelessness, one of the most common errors is the absence of the file <code>C:\php\php7apache2_4.dll</code>. This file is indeed missing if you have downloaded the wrong version of PHP ('''<u>No</u>''' '''Thread Safe''') instead of the '''Thread Safe''' version. In this case, download the good archive ('''Thread Safe''') and perform the [[ | In addition to common syntax errors due to carelessness, one of the most common errors is the absence of the file <code>C:\php\php7apache2_4.dll</code>. This file is indeed missing if you have downloaded the wrong version of PHP ('''<u>No</u>''' '''Thread Safe''') instead of the '''Thread Safe''' version. In this case, download the good archive ('''Thread Safe''') and perform the [[Manual_Installation_On_Windows#Extract_the_archive_for_PHP_installation]] part again. | ||
Another problem that can be encountered is the impossibility to start '''Apache2''' because the port '''80''' is already used by another program. See the appendix [[ | Another problem that can be encountered is the impossibility to start '''Apache2''' because the port '''80''' is already used by another program. See the appendix [[Manual_Installation_On_Windows#What are "Listening Ports" and how to know if a program already occupies a specific port? |What are "Listening Ports" and how to know if a program already occupies a specific port?]] for instructions on how to proceed. | ||
Once you have corrected any errors, try again to start the '''Apache2.4''' Service with the command mentioned above. | Once you have corrected any errors, try again to start the '''Apache2.4''' Service with the command mentioned above. | ||
| Line 296: | Line 296: | ||
You can now close the software '''MySQL Client (MariaDB 10.4 (x64)'''. | You can now close the software '''MySQL Client (MariaDB 10.4 (x64)'''. | ||
===Check if Apache2 works properly==== | |||
*Start your favorite Web Browser (Firefox, Google Chrome, Opera, Brave, Vivaldi, Internet Explorer, Edge, etc.) and enter the address <code>http://localhost</code> in the address bar then validate with '''Enter'''. | |||
If you have correctly installed '''Apache2''', the "Web Server" should answer you a nice <code>It works!</code>. | |||
[[File:It works! Apache2.png|none|frame|The Web Server default page '''Apache2''.|link=Special:FilePath/It_works!_Apache2.png]] | |||
This concludes our '''Apache2''' test. | |||
We were indeed able to get a response from the Web Server '''Apache2''' (in this case <code>It works!</code>) which proves that it was correctly installed and started. | |||
You can now close your Web Browser. | |||
<br /> | |||
===Check if PHP works properly== | |||
Concerning the PHP part, we have two things to check. | |||
#The files <code>index.php</code> are correctly recognized when accessing a directory. | |||
#The files <code>*.php</code> are correctly interpreted by PHP and return HTML. | |||
*With the Windows '''File Explorer''', go to the '''Local Disk (C:)''' then in the directory '''Apache24'''. Finally, go to the '''htdocs''' directory (<code>C:\Apache24\htdocs</code>). | |||
You will find in this folder a file <code>index.html</code>. This is the famous file which contains <code><nowiki><html><body><h1>It works!</h1></nowiki><nowiki></body></nowiki><nowiki></html></nowiki></code> is the HTML answer which was sent back to us '''Apache2''' when we accessed the server by typing the address <code>http://localhost</code>. | |||
*In the folder '''htdocs''' (<code>C:\Apache24\htdocs</code>), create a new folder <code> test</code> (right click, '''New''' > '''Folder'''). | |||
*Double-click on the new folder <code>test</code> to enter it. | |||
*Create a new file <code>index.php</code> (right click, '''New''' > '''Text Document'''). | |||
*Open the document with the Windows '''Notepad''' (right click, '''Open with''' > '''Notepad'''; if '''Notepad''' is not proposed, click on '''Choose another software''', then on '''More software''' and select '''Notepad''' in the list before validating with '''OK'''). | |||
*Enter the following '''PHP''' code in the file :<syntaxhighlight lang="PHP"> | |||
<?php | |||
phpinfo(); | |||
</syntaxhighlight> | |||
*Save the file <code>index.php</code> ('''File''' > '''Save''' or <kbd>Ctrl</kbd> + <kbd>S</kbd>) and close it. | |||
When PHP processes a file, it looks for the opening and closing tags ('''<code>?php</code>''' and '''<code>?</code>''') that delimit the code it must interpret. <code>?php</code> thus allows to indicate that we are going to write '''PHP''' code. | |||
The function <code>[https://www.php.net/manual/en/function.phpinfo.php phpinfo]</code> displays a lot of information about the configuration of '''PHP''', which will allow us to check that '''PHP''' works and that we have activated the right extensions. | |||
*Start your favorite Web Browser (Firefox, Google Chrome, Opera, Brave, Vivaldi, Internet Explorer, Edge, etc.) and this time enter the address <code>http://localhost/test</code> in the address bar then validate with '''Enter'''. | |||
'''Apache2''' should return a page generated by '''PHP''' containing all the configuration information. If you scroll this page, you '''<u>should</u>''' see sections related to the extensions we loaded previously (including <code>curl</code>, <code>gd2</code>, <code>intl</code> and <code>mysqli</code>). If one of these sections is not displayed, it means that the extension is not loaded (so you forgot to remove a semicolon in front of an extension name when editing the <code>C:\php\php.ini</code> or you forgot to copy one of the files mentioned in [[Manual installation On Windows#Copy the files needed for the PHP extensions intl and curl to the bin/ directory of Apache2|Copy the files needed for the PHP extensions <code>intl</code> and <code>curl</code> to the <code>bin/</code> directory of Apache2]]. Check and correct if necessary your omissions and then restart the Service '''Apache2.4''' so that your changes are taken into account (see appendix [[Manual installation on Windows#How to manage Windows "Services" ?|How to manage Windows "Services" ?]] to know how to restart an existing Service). | |||
[[File:Phpinfo().png|border|none|thumb|750x750px|''Apache2'' returns the page with the configuration information generated by ''PHP''.] | |||
<This concludes our test of ''PHP''. | |||
We were indeed able to verify that '''PHP''' works correctly because it returns the information related to its current configuration. | |||
Moreover, the files '''PHP''' <code>index.php</code> are well interpreted as index files because our file was well executed by typing <code>http://localhost/test</code> (we did not need to type <code>[http://localhost/test http://localhost/test/index.php]</code> ). | |||
*With the Windows '''File Explorer''', go to the '''Local Disk (C:)''' then to the '''Apache24''' directory. Finally, go to the '''htdocs''' directory (<code>C:\Apache24\htdocs</code>). | |||
*Delete the folder <code> test</code> that we previously created. | |||
You can now close the Windows File Explorer and your Web Browser. | |||
<br /> | |||
* | |||
# | |||
edits