Компьютерный справочник
0 просмотров
Рейтинг статьи
1 звезда2 звезды3 звезды4 звезды5 звезд

How to install php

The Complete Guide on How to Install PHP

So you got to know a bit about PHP and want to start putting your knowledge to practice. The first step you should take now is finding out how to install PHP on your computer.

As PHP is a free and open-sourced programming language, installing it on your computer is no challenge. You can install PHP on Windows, Linux, Mac OS, or any other operating system. It is also possible to install and run PHP in various cloud environments.

Technically it’s not necessary to install PHP: most web hosts and servers already have a built-in PHP support. However, installing PHP might be more convenient for you as a developer, especially in the beginning.


How to Install PHP: Main Tips

  • To install PHP on your computer for free, you can use downloadable files and a manual provided by PHP.net
  • You will also need access to a web server and a database management system to use PHP properly.
  • Keep in mind that PHP is widespread, a lot of web hosts have a built-in PHP support already.

Different Ways to Install PHP7

  • One of the options to immediately install PHP Windows used to be downloading WebMatrix. However, it was discontinued in 2017 after Microsoft dropped it in favor of Visual Studio Code source-code editor. You can use it for most programming languages, including but not limited to PHP.
  • If you wish to waste no time and start running PHP as soon as possible, you should look for a web host that has strong support of PHP and MySQL. To get started, you may create an index.php file and upload it via FTP access.
  • You may also consider installing a web server on your computer. Basically, a server is open-source software that will provide your website with the necessary functionalities. A good example of that could be XAMMP, which works on Windows, Linux and Mac OS.
Theory is great, but we recommend digging deeper!

Learn PHP Online: PHP Basics Explained in an Interactive and Fun Manner

BitDegree Foundation VSI ©

PHP Install or a Web Host?

Most web hosts support PHP, as it’s free and widely-used. When you find one that does, you don’t need to manually install PHP on your computer or look for any extra tools.

As you create files with the .php suffix, place them in your directory. The server will do the job for you. Sit back, relax, and think of all the codes you will write.

Installing PHP7 on Personal Computers

Most computers don’t support PHP by default. However, it’s free and not time-consuming to install PHP on Windows, Mac OS, Ubuntu, or any other operating system. How to install PHP on your computer? First, you will need the following:

Install PHP on Windows

Obtaining PHP

  • Download latest version of PHP from http://www.php.net/downloads.php.
  • You can also download the .msi package i.e. windows installer of PHP from sourceforge.net

Prerequisite and running on your Windows system, else you will not be able to run PHP Scripts.

Alternatively, you can install wamp server to install PHP, MySQL, and Apache Web Server on your Windows machine.

Options for installing PHP on Windows

  • You can install php on windows manually.
  • You can run the .msi package, i.e. windows installer for php to install php.
  • Besides full installation, you can install php extensions on an existing installation of PHP.
  • You can upgrade to a higher version of PHP from an existing version.

Install PHP on Windows manually

You have to download zipped binary version of PHP from http://www.php.net/downloads.php.

Extract the downloaded file to php folder which must be created at the root of any of your windows drives (e.g. c:php or d:php).

Enter php folder and rename the file php.ini-recommonded to php.ini.

Open the file php.ini with any text editor and find extension_dir within the file.

Change the extension directory, i.e. if you have installed php in php folder of D drive, setting will be extension_dir=D:php.

Now you open Environment Variables (MyComputer -> System Properties -> Environment Variables), under system variables, select Path and click Edit,
in the Variable value, go to the end of the list and put a semicolon, then add D:php;D:phpext assuming D:php is the location of your php installation.

Then Click on New under system variable and add PHPRC against Variable name and D:php against Variable value.

Restart your system.

Install PHP on Windows using Windows installer

Simply run the .msi Windows installer file and follow the installation wizard.

Testing if PHP is installed properly

Create a php file containing code and save it as test.php.
Run this file on your web server and if you get an output like this:

then you have installed PHP properly.

Install PHP extensions on Windows

What is a PHP extension?

A PHP extension is a piece of code which is not part of the core PHP and you need it to explore certain functionalities of PHP (e.g. for using mysql you need mysql extension of PHP).

Many extensions are available out of the box in the PHP installer downloaded from php.net or in the .msi package. But many need to be obtained separately from php.net.

In Windows, extensions come in the form of a .dll file which you can download from php.net.

How do you configure an extension on Windows?

You need to change the setting of extension dir in php.ini file. For example, If you are using PHP 5.0.3, and you have installed php in c:php, then you have to set extension_dir = C:phpext in your php.ini file.

After downloading the files needed, you have to open php.ini and enable a line pointing to an extension in question.

Читать еще:  Проверка на запятые онлайн исправление ошибок

For enabling extensions, you have to uncomment a line in your php.ini file. For example, for enabling mysql extension, you have to change; extension = php_mysql.dll to extension = php_mysql.dll in your php.ini file.

You also need to restart your web server and php in order to complete the installation of a specific extension.

Sample php.ini

Previous: PHP Home
Next: Install php on Linux

How to install PHP on windows?

Understanding PHP is a part of the web development journey and installing PHP on your machine can be considered as the first step in this journey. In this article, we will take a look at various methods available to install PHP on your machine running Windows.

Install PHP using packages

Before getting started with any of these steps first note down the operating system version and your CPU architecture. This can be done by simply right-clicking the ‘ThisPC’ icon and selecting ‘Properties’. Here you can check the version of the operating system (eg. Windows 7, Windows 10). Here, we can also find the type of CPU architecture (eg. x32, x64).

In my case, I have a 64-bit operating system and Windows 10.

Once we know the system specifications we can start with the installation process. There are several packages that are available to download and can help in installing Apache spark, MySQL, and PHP without breaking a sweat. WampServer and XAMPP are the packages available to download.

Manually installing PHP on Windows

Installing PHP on a Windows 10 machine is no at all difficult. Fist of all let’s understand the steps involved and after that, we will go through each step in detail.

First, we will do the latest PHP package from the PHP website .

Once we have the zip file we will create a PHP7 folder in the C drive and extract the contents of the zip file in this folder.

Make some changes in the PHP.ini file.

Change the path environment variable.

Now, let’s go through each step in detail. The first 2 steps are pretty straightforward hence we will start with step 3.

Once we create the folder ‘PHP7’ in the C drive, we need to extract the zip file that we had downloaded from the PHP website and place all its components in the ‘PHP7’ folder. After that, we need to find a file named ‘php.ini-development’ and make a copy of this file and rename it as ‘php.ini’.

Once we have made a copy we need to open ‘php.ini’ with the help of notepad or notepad++ to make some changes. First, we need to find ‘extension_dir’ and remove the semicolon besides ‘extension_dir = “ext”’.

After that, we need to enable some important extensions, this can be done by simply scrolling down a bit and you’ll fund the list of all the extensions available. Here, you can enable the extensions based on your needs.

Note – the order of my list may differ from yours.

I’ve enabled all the essential extensions which are used while performing the majority of the functions. Once the extensions are enabled, save the ‘php.ini’ file and now we will move towards the step 4.

Open control panel and search for ‘variable’. After that click on ‘Edit the system environment variables’. After that click on ‘Environment Variables…’ after that select ‘Path’ from system variables, after selecting ‘Path’ click on ‘Edit…’, Now we need to add a path hence we click on ‘New’ and then add ‘C:PHP7’.

Once you’ve added the path you are done with the installation process. You might need to restart for all the changes to take place. Now open the command prompt and type ‘ php -v ’ you will see the version and other details related to the PHP version which you’ve installed on your system.

Now with this, we have come to the end of the “how to install PHP” blog. I hope you guys enjoyed this article and ready to headstart with PHP. You can refer to this PHP Tutorial, to no longer stay a newbie to the scripting language.

If you found this PHP Tutorial blog relevant, check out the PHP Certification Training by Edureka, a trusted online learning company with a network of more than 250,000 satisfied learners spread across the globe.

Got a question for us? Please mention it in the comments section of ”How to install PHP” and I will get back to you.

Установка в системах Windows


Установка PHP в современных операционных системах Microsoft Windows и рекомендуемая конфигурация под распространенные веб-серверы.


Если вы ищете информацию о старых версиях операционных систем: Windows XP, 2003, 98 или Apache 1.x, обратитесь к разделу руководства Установка на старых версиях ОС Windows.

Официальные релизы PHP для Windows рекомендованы для использования в промышленной эксплуатации. Однако, вы также можете собрать PHP из исходных кодов. Вам потребуется окружение Visual Studio. Обратитесь к разделу » Пошаговое руководство по сборке для получения более полной информации.

Установка PHP на Azure App Services (он же Microsoft Azure, Windows Azure, или (Windows) Azure Web Apps).

User Contributed Notes 12 notes

If you make changes to your PHP.ini file, consider the following.

(I’m running IIS5 on W2K server. I don’t know about 2K3)

PHP will not «take» the changes until the webserver is restarted, and that doesn’t mean through the MMC. Usually folks just reboot. But you can also use the following commands, for a much faster «turnaround». At a command line prompt, type:

and that will stop the webserver service. Then type:

net start w3svc

and that will start the webserver service again. MUCH faster than a reboot, and you can check your changes faster as a result with the old:

in your page somewhere.

I wish I could remember where I read this tip; it isn’t anything I came up with.

Читать еще:  Как проверить память телефона на ошибки

You can have multiple versions of PHP running on the same Apache server. I have seen many different solutions pointing at achieving this, but most of them required installing additional instances of Apache, redirecting ports/hosts, etc., which was not satisfying for me.
Finally, I have come up with the simplest solution I’ve seen so far, limited to reconfiguring Apache’s httpd.conf.

My goal is to have PHP5 as the default scripting language for .php files in my DocumentRoot (which is in my case d:/htdocs), and PHP4 for specified DocumentRoot subdirectories.

Here it is (Apache’s httpd.conf contents):

# replace with your PHP4 directory
ScriptAlias /php4/ «c:/usr/php4/»
# replace with your PHP5 directory
ScriptAlias /php5/ «c:/usr/php5/»

AddType application/x-httpd-php .php
Action application/x-httpd-php «/php5/php-cgi.exe»

# populate this for every directory with PHP4 code

Action application/x-httpd-php «/php4/php.exe»
# directory where your PHP4 php.ini file is located at
SetEnv PHPRC «c:/usr/php4»

# remember to put this section below the above

# directory where your PHP5 php.ini file is located at
SetEnv PHPRC «c:/usr/php5»


This solution is not limited to having only two parallel versions of PHP. You can play with httpd.conf contents to have as many PHP versions configured as you want.
You can also use multiple php.ini configuration files for the same PHP version (but for different DocumentRoot subfolders), which might be useful in some cases.

Remember to put your php.ini files in directories specified in lines «SetEnv PHPRC. «, and make sure that there’s no php.ini files in other directories (such as c:windows in Windows).

And finally, as you can see, I run PHP in CGI mode. This has its advantages and limitations. If you have to run PHP as Apache module, then. sorry — you have to use other solution (the best advice as always is: Google it!).

Hope this helps someone.

I installed by Microsoft Installer, manually, whatever I always received de same error from IIS7.

HTTP Error 404.3 — Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

The IIS7 interface is quite diferent and are not all together like IIS6

The 5.3 version have not any of those files: php5stdll, php5isapi.dll. etc.

The installer puts others files in handlers and I decided to use them as substitutes. Nothing done!

After that, I discovered that installer do not install these files within the sites, but in the root default site configuration of IIS7.

So, I copied the root configuration to my site and them it worked (all others procedures were done e.g. copy php.ini to windows folder)

Still Can’t Run PHP Code?

After installing php-5.2.5-win32-installer.msi on my Windows XP2. with IIS5.1 it still didn’t run PHP files.

I eventually found the fix*:

1. Goto Control Panel>System>Advanced>Environmental Variables
2. Add a New System Variable «PHRC» and set its path as «C:Program FilesPHP»
3. Restart

PHP Install on XP Pro IIS 5.1 — phpinfo( ) results incorrect

Testing Date: 05.15.09

For several days now I, as a newbie, have been unsure if I had installed PHP correctly, or not. No matter what I did phpinfo( ) reported «Configuratin File Path» as: “C:WINDOWS”. I was left to wonder what was wrong.

To help resolve the phpinfo() “issue”, I conducted a series of tests using two scripts:

The first is “test-php-ini-loaded.php”; it is stored in c:inetpubwwwroot, and has the following code:

The second script is simply calls phpinfo( ). It is named test.php, is stored in “c:inetpubwwroot”, and has the following code:

My Dev Environment:
1. Windows XP Pro SP3
2. IIS 5.1 / MMC 3.0
3. PHP – phpMyAdmin not yet installed
4. (plus MySQL 5.1, etc.)
5. Install location is on my local E: drive

How To Install a PHP 7.2 on macOS 10.15 Catalina Using Homebrew and PECL

Part two of an updated two-part series to set up an Apache/PHP development environment on macOS Catalina

This piece is for web developers who want Apache and PHP installed as part of their development environment setup on their Mac.

Make sure to check out Part One, How To Install Apache on macOS 10.15 Catalina Using Homebrew, which is a pre-requisite for this piece.

In the past, I used to rely on the version of Apache and PHP that came pre-loaded with the OS on my MacBook Pro. I would then install the PHP extensions I needed (Xdebug, Redis, etc.) from Homebrew.

As of April 1, 2018, Homebrew deprecated the Homebrew/php tap in favor of a new Homebrew/core approach. In addition, although some critical extensions are still supported (e.g., MySQLi), most PHP extensions are no longer distributed through Homebrew at all ( php72-xdebug , php72-redis , etc.) and require installation through PECL (PHP Extension Community Library).

With the ever-changing security rules in macOS, along with the complications of using the macOS pre-installed PHP version along with PECL, I’ve decided to change my whole approach and instead use a setup entirely from Homebrew. This new approach allows for a more simple installation, more flexibility for versioning, and will continue to work across all macOS versions.

These instructions work with prior versions of macOS. Also, you don’t have to start with a fresh OS install to use this piece, but these instructions start at the beginning with the assumption you have nothing installed because that’s just the easiest way to go.

Let’s get started.


Install Homebrew

If you haven’t done this already, then you’ll need to:

Note: The following command is a single line that has wrapped due to page width constraints in Medium. Make sure to copy the entire line.

Create PHP log file directories

PHP comes pre-configured with its own log directories, but we’re going to create our own /usr/local/log/ folder so they’re easy to find when we need to. Follow these steps to create the appropriate directories and set their permissions. Disregard any already exists messages you might get.

Читать еще:  Голосовой поиск ошибка сервера

Install and configure PHP

Up until the end of March 2018, all PHP related brews were handled by Homebrew/php tap, but that has been deprecated. So now we use what’s available in the Homebrew/core package. This should be better maintained but is a much less complete set of packages.

It should be noted that to install other versions of PHP, you can simply change the version number (e.g., php@7.1 ). You also have the ability to have multiple versions of PHP installed at the same time and switch between them. However, this document is specifically designed for installing and configuring PHP 7.2.

Your new php.ini file is located in the following directory:

Enable the necessary Apache module

Now we need to configure Apache to use the newly installed PHP module. To do this, we’ll need to edit the httpd.conf file we installed in Part One of this series:

Scroll to the bottom of the LoadModule entries and add the following line after the mod_rewrite module line:

Note: The following command is a single line that has wrapped due to page width constraints in Medium. Make sure to copy the entire line.

Set directory index and file handlers

You also need to set the directory indexes for PHP explicitly, so search for the following block of text:

… and then select and replace it with the following lines:

Save and exit the text editor.

To start the PHP service and make sure it starts upon reboot, enter the following command in Terminal:

Validate PHP install

To test if PHP is installed and running as expected, create a file called index.php in the Sites folder you created in Part One of this series:

Now do a hard refresh on your browser (or close and exit your browser and start it back up again). Then browse to your localhost, and you should see a PHP info page similar to the one below:

If you see a similar PHP info page, then congratulations! You now have Apache and PHP running successfully.

If you have a problem and it doesn’t appear that PHP is loading properly, it’s possible your browser session is preventing it from refreshing. Try shutting down and quitting your browser completely. Run the Apache reset again, and open your browser and try navigating to your localhost. It should work.

Install PECL extensions

As of March 2018, Homebrew no longer distributes most PHP extensions and they must be installed using PECL. This includes the Xdebug, igbinary, and Redis extensions.

The good news is that PECL is included in your PHP install, and all you need to do is add its bin location to your system PATH to make it start working from your command line.

Note: Before running the command below, it would be wise to cd into your /usr/local/Cellar/php@7.2/ folder and verify the version number that’s listed in the command (e.g., 7.2.23); it could be something different.

This will add your PHP directory to your system path and restart bash. You should be good to go!

Open Terminal and enter the command below. You should see a list of options instead of command not found. If you see a list of options, you’re good to go.

This will add a line to the top of your php.ini file that we will fix after we install the remaining extensions.

Install Xdebug

This will install Xdebug v2.7.2, which is the current stable release (as of this writing) that supports PHP 7.2.

There are other versions of Xdebug. Just substitute the version number you desire.

Install igbinary

This will install igbinary v3.0.1, which is the current stable release (as of this writing) and supports PHP 7.2.

There are other versions of igbinary. Just substitute the version number you desire.

Note: You must install the igbinary extension before you install Redis.

This will add a line to the top of your php.ini file that we will fix after we install Redis and its extension.

Install Redis

First, install the Redis server component for our dev environment.

Once that’s complete, start Redis and set it to restart on reboot.

Install the Redis PHP extension

This will install Redis v5.0.2, which is the current stable release (as of this writing) and supports PHP 7.2.

There are other versions of Redis. Just substitute the version number you desire.

Note: You must install the igbinary extension before you install Redis.

You will be asked some questions during install. Answer them as follows:

  • enable igbinary serializer support? [no]: yes
  • enable lzf compression support? [no]: no

Edit PHP configuration settings

Now that we’ve got all the necessary extensions installed, we can make some final entries to the php.ini file for our development environment.

Find and remove these three lines that were added to the very top of the php.ini file in the prior steps. We’ll re-add them in a bit:

Scroll to the bottom of the php.ini file and paste the following lines in:

Save and exit the text editor.

Open your browser and navigate to your http://localhost. You should see your PHP info page. Scroll down through and you should see all the necessary PHP extension information displayed for igbinary, Redis, and Xdebug with the proper version numbers you installed in the prior steps.

Congratulations! You now have Apache and PHP with associated extensions running on your Mac development environment.

Ссылка на основную публикацию
ВсеИнструменты 220 Вольт