Praktikum 3: Difference between revisions

From TÜ Narva Kolledži Wiki
Jump to navigation Jump to search
Content deleted Content added
No edit summary
No edit summary
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:


Install IIS with PHP Support (Windows Server)
'''Install IIS with PHP Support (Windows Server)'''


This practical guide outlines the steps to install IIS (Internet Information Services) with PHP support on a Windows Server. Follow the instructions carefully and ensure all configurations are completed as described.
This practical guide outlines the steps to install IIS (Internet Information Services) with PHP support on a Windows Server. Follow the instructions carefully and ensure all configurations are completed as described.


⚫
Install Required Programs


⚫
1. Install Required Programs
Install Visual C++ Redistributable:


Download the latest version of the Visual C++ Redistributable for Visual Studio from
Install Visual C++ Redistributable:


https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170
Download the latest version of the Visual C++ Redistributable for Visual Studio from [https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170]


Ensure you download the x64 version.
Ensure you download the x64 version.
Line 18: Line 17:
Download PHP:
Download PHP:


Visit http://windows.php.net/download/
Visit [http://windows.php.net/download/]


Download the latest stable release of PHP (Non-Thread Safe, x64 version).
Download the latest stable release of PHP (Non-Thread Safe, x64 version).
Line 29: Line 28:


In the "Application Development" section, enable the CGI module.
In the "Application Development" section, enable the CGI module.

[[File:Iis01.png|400px]]


Complete the installation and restart IIS or the entire server to apply changes.
Complete the installation and restart IIS or the entire server to apply changes.



Configure PHP
2. Configure PHP


Locate and Prepare the PHP Configuration File:In C:\PHP, find the file php.ini-production.
Locate and Prepare the PHP Configuration File:In C:\PHP, find the file php.ini-production.


We will now copy the php.ini-production configuration to the “working” copy “php.ini” (rename
We will now copy the php.ini-production configuration to the “working” copy “php.ini” (rename the php.ini-production) and then make some adjustments, using the Command Prompt run the following command:


⚫
<pre>copy C:\PHP\php.ini-production C:\PHP\php.ini</pre>
the php.ini-production) and then make some adjustments, using the Command Prompt run the

following command:

⚫
copy C:\PHP\php.ini-production C:\PHP\php.ini


Edit php.ini File:
Edit php.ini File:
Line 50: Line 48:
Set the timezone:
Set the timezone:


date.timezone = Europe/Tallinn
<pre>date.timezone = Europe/Tallinn</pre>


Set the extensions directory:
Set the extensions directory:


extension_dir = "ext"
<pre>extension_dir = "ext"</pre>


Update CGI settings for IIS:
Update CGI settings for IIS:


cgi.force_redirect = 0
<pre>cgi.force_redirect = 0


cgi.fix_pathinfo = 0
cgi.fix_pathinfo = 0


fastcgi.impersonate = 1
fastcgi.impersonate = 1
</pre>


Save the changes.
Save the changes.



Add PHP to IIS:
3. Add PHP to IIS:


Open IIS Manager.
Open IIS Manager.


Navigate to the server's name in the left-hand panel and double-click Handler Mappings.Click Add Module Mapping:
Navigate to the server's name in the left-hand panel and double-click Handler Mappings.

[[File:Iis02.png|400px]]


Click Add Module Mapping:

[[File:Iis03.png|400px]]



Set the following:
Set the following:


[[File:Iis04.png|400px]]
Request path: *.phpModule: FastCGIModule


<pre>
Request path: *.php
Module: FastCGIModule
Executable: C:\PHP\php-cgi.exe
Executable: C:\PHP\php-cgi.exe

Name: PHP
Name: PHP
</pre>


IMPORTANT: Click Request Restrictions > Check "Invoke handler only if request is mapped to a
'''IMPORTANT:''' Click Request Restrictions > Check "Invoke handler only if request is mapped to a file."

[[File:Iis05.png|400px]]


file."


Confirm all changes.
Confirm all changes.


⚫
Set Default Document:


⚫
4. Set Default Document:
⚫
In IIS Manager, navigate to the server's name and double-click Default Document.Click Add at the right section and enter index.php. Save the changes.

⚫
In IIS Manager, navigate to the server's name and double-click Default Document.

[[File:Iis06.png|400px]]


Click Add at the right section and enter index.php.

[[File:Iis07.png|400px]]


Save the changes.


Test the Configuration
Test the Configuration


Create the index.php File:
Create the index.php file:


Navigate to C:\inetpub\wwwroot.
Navigate to C:\inetpub\wwwroot.


Create a new file named index.php and insert the following content:
Create a new file named index.php and insert the following content:
<pre>

<?php phpinfo();?>
<?php phpinfo();?>
</pre>

Save the file.
Save the file.


Line 106: Line 129:
Open a browser and navigate to http://localhost/index.php.
Open a browser and navigate to http://localhost/index.php.


Ensure that the PHP info page is displayed, confirming that PHP is installed and configured
Ensure that the PHP info page is displayed, confirming that PHP is installed and configured correctly.

correctly.


Show it to the teacher!
Show it to the teacher!



⚫
Optional!

⚫
'''Optional!'''


Install an FTP Server
Install an FTP Server
Line 138: Line 161:




[http://blog.bobbyallen.me/2016/05/02/installing-php7-on-windows-server-2012-r2-and-iis-8/ Source]


⚫
[https://neoserver.site/help/setting-ftp-server-windows-server-2016 Source]



Installida IIS PHP toetusega ([https://windows.php.net/download/ PHP 8x64 Non Thread Safe]), kasutades järgmist [http://blog.bobbyallen.me/2016/05/02/installing-php7-on-windows-server-2012-r2-and-iis-8/ juhendit] and VC++ alla laadida [https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170 siit]

⚫
Soovi korral - Installida FTP server [https://neoserver.site/help/setting-ftp-server-windows-server-2016]

Latest revision as of 14:47, 25 December 2024

Install IIS with PHP Support (Windows Server)

This practical guide outlines the steps to install IIS (Internet Information Services) with PHP support on a Windows Server. Follow the instructions carefully and ensure all configurations are completed as described.


1. Install Required Programs

Install Visual C++ Redistributable:

Download the latest version of the Visual C++ Redistributable for Visual Studio from [1]

Ensure you download the x64 version.

Install the runtime and restart the server.

Download PHP:

Visit [2]

Download the latest stable release of PHP (Non-Thread Safe, x64 version).

Extract the downloaded ZIP file to C:\PHP.

Install IIS and Enable CGI Module:

Open Server Manager > Add Roles and Features.

In the "Application Development" section, enable the CGI module.

Complete the installation and restart IIS or the entire server to apply changes.


2. Configure PHP

Locate and Prepare the PHP Configuration File:In C:\PHP, find the file php.ini-production.

We will now copy the php.ini-production configuration to the “working” copy “php.ini” (rename the php.ini-production) and then make some adjustments, using the Command Prompt run the following command:

copy C:\PHP\php.ini-production C:\PHP\php.ini

Edit php.ini File:

Open the php.ini file in a text editor and make the following changes:

Set the timezone:

date.timezone = Europe/Tallinn

Set the extensions directory:

extension_dir = "ext"

Update CGI settings for IIS:

cgi.force_redirect = 0

cgi.fix_pathinfo = 0

fastcgi.impersonate = 1

Save the changes.


3. Add PHP to IIS:

Open IIS Manager.

Navigate to the server's name in the left-hand panel and double-click Handler Mappings.


Click Add Module Mapping:


Set the following:

Request path: *.php
Module: FastCGIModule
Executable: C:\PHP\php-cgi.exe
Name: PHP

IMPORTANT: Click Request Restrictions > Check "Invoke handler only if request is mapped to a file."


Confirm all changes.


4. Set Default Document:

In IIS Manager, navigate to the server's name and double-click Default Document.


Click Add at the right section and enter index.php.


Save the changes.

Test the Configuration

Create the index.php file:

Navigate to C:\inetpub\wwwroot.

Create a new file named index.php and insert the following content:

<?php phpinfo();?>

Save the file.

Verify the Installation:

Open a browser and navigate to http://localhost/index.php.

Ensure that the PHP info page is displayed, confirming that PHP is installed and configured correctly.

Show it to the teacher!


Optional!

Install an FTP Server

Install and Configure FTP:

Install an FTP server through IIS (optional).

Follow the IIS FTP setup documentation if required.

Create Shared Folder:

Create a folder named after your name (e.g., C:\shared\yourname) to store your files for this

practicum.

Completion Steps

Clean Up:

Ensure all files and configurations are correct.

Verify functionality by demonstrating the index.php file output to the teacher.


Source

Source