Install Apache, PHP, MySQL. Installing PHP on a local computer

This description is suitable for any edition of Windows 7/8 / 8.1.

Install Apache Web Server

First of all, download the Apache distribution from the website: http://www.apachelounge.com/download/. In the list of distributions Apache 2.4 binaries VC11, we need to download "httpd-2.4.7-win64-VC11.zip".

After downloading, open the archive httpd-2.4.7-win64-VC11.zip

We extract the Apache24 folder from it to the C: \\ drive partition

Now we need to fix the config a bit before installing Apache. We open the httpd.conf file (located here: C: \\ Apache24 \\ conf), preferably through a convenient editor, for example notepad ++. Find the line (217) ServerName www.example.com:80 and change it to ServerName localhost: 80

Here we need to specify the full path to the httpd.exe file, which is located in the Apache folder. In our case, this is C: \\ Apache24 \\ bin \\ httpd.exe. We type the command C: \\ Apache24 \\ bin \\ httpd.exe -k install and press Enter.

If you encounter the following error while running the program: failed to open the winnt service manager perhaps you forgot to log in as administrator, go to the following folder: C: \\ Users \\ Here_your_user_name \\ AppData \\ Roaming \\ Microsoft \\ Windows \\ Start Menu \\ Programs \\ System Tools, run the command line as administrator

And repeat the installation command.

Installation completed. Open the bin directory (full path: C: \\ Apache24 \\ bin \\) and run the file: ApacheMonitor.exe. The Apache icon will appear in the system tray, with which you can quickly start / stop the Apache service, click start (start):

Now check the performance. We open the browser, and in the address bar we write http: // localhost / (you can just localhost). If the installation was successful, a page with the inscription It works!

PHP installation (manual)

Do we need Apache without PHP? Of course not, this is nonsense! Therefore, further we will consider manual (without using the installer) installation of PHP.

Download PHP (Zip archive) from the site: http://windows.php.net/download/. We need a version: VC11 x64 Thread Safe.

Unpack the contents of the archive into the directory C: \\ PHP (we create the PHP folder ourselves). Next, in the C: \\ PHP folder, we find two php.ini-development and php.ini-production files. These files contain basic settings. The first file is optimized for developers, the second for production systems. The main difference in the settings: for developers, error display is allowed, while for working systems, error output is prohibited for security reasons.

We will do something before proceeding with the installation of PHP. Open the Control Panel → design and personalization → folder settings → the View tab, find the line “Hide extensions for registered file types”, and if there is a checkmark, remove it and click “Apply”.

We continue the installation. And so, select the file you need (I chose php.ini-development). The selected file will just need to be renamed a little. Right click on the file → Rename → delete “-development”, leaving only php.ini

Now open php.ini, we need to make a few changes (be careful when making changes, if there is a semicolon at the beginning of the line, it will need to be removed):

  1. Find the extension_dir option (line 721) and change the path to the ext folder in accordance with the PHP installation path. It looks like this for me:
      extension_dir \u003d "C: \\ PHP \\ ext"
  2. Find the upload_tmp_dir option (line 791). Here you need to specify the path to the temporary folder. I chose c: \\ windows \\ temp. Together:
      upload_tmp_dir \u003d "C: \\ Windows \\ Temp"
  3. Find the session.save_path option (line 1369). Here you also need to specify the path to the temporary folder:
      session.save_path \u003d "C: \\ Windows \\ Temp"
  4. In the Dynamic Extensions section, you need to uncomment several lines (remove the semicolon at the beginning) that correspond to the PHP modules that may be needed for work: 866, 873, 874, 876, 886, 895, 900

Save changes and close.

Now back to the Apache settings. We will have to edit the Apache config a little. We go into the folder C: \\ Apache24 \\ conf and open the httpd.conf file.

Go to the end of the file and add the following lines at the very bottom:

   # Charset AddDefaultCharset utf-8 # PHP LoadModule php5_module "C: /PHP/php5apache2_4.dll" PHPIniDir "C: / PHP" AddType application / x-httpd-php .php

The path to the php folder is indicated by the one that you selected during the installation process (if you installed in a different directory).

In the same file we find the following lines (lines approximately 274-276):

   DirectoryIndex index.html

Before index.html, append index.php with a space. The result is:

DirectoryIndex index.php index.html

For the changes to take effect, restart the Apache service (the tray icon is Apache monitor). If the service restarts, this is a good sign. If not (an error pops up) - look for errors in the configuration files. Check all paths especially carefully.

To make sure that PHP is working, open the folder C: \\ Apache24 \\ htdocs (this contains the default website files). Create an index.php file in this folder with the following contents:

Now open in your browser http: // localhost / (or just localhost). If everything went fine, you will see a similar page:

If instead of a page with information about php you have a page with the inscription "It works!" Opened, then just click refresh the page.

MySQL installation

Open the distribution download page: http://dev.mysql.com/downloads/installer/5.6.html and download Windows (x86, 32-bit), MSI Installer 5.6.16 250.8M. After clicking on the Download button, you will see a registration form, you can skip it by clicking on the link below (»No thanks, just start my download!).

We launch the installer, after a small load we see the following window:

Click Install MySQL Products, the following window appears, in which we accept the license agreement (put a tick) and click Next\u003e

The next window offers us to check if there is a newer version of MySQL, check Skip ... (skip) and click Next\u003e

In the next window, we are prompted to select the type of installation, select Custom and click Next\u003e:

In the next window, we are given the opportunity to select the necessary components: uncheck the MySQL Connectors checkbox, uncheck the MySQL Workbench CE 6.0.8 and MySQL Notifier 1.1.5 application, uncheck the Development Components and Client C API library in MySQL Server 5.6.16 ( shared) and click Next\u003e

The next window tells us what will be installed, just click Execute

After a successful installation, click Next\u003e

In the next window, we are informed that further we will configure our server a little, click Next\u003e

In the first window, set the checkbox Show Advanced Options, leave the rest as is and click Next\u003e

In the next window, we are prompted to set the administrator password (root). This password is best not to lose! Set a password and click Next\u003e

In the next window, erase 56 in the input field, leave the rest as it is and click Next\u003e

Click Next\u003e

Click Next\u003e

It remains to verify whether the installation was successful. (win 8): Go to the start menu → go to applications (arrow down) → find MySQL5.6 Command Line Client (terminal for working with MySQL in the command line) → open it. Next, enter the administrator password (root). If the password is correct, you will be taken to the command line (mysql\u003e). Enter the command: show databases; (semicolon at the end is required). As a result, you should see a list of databases (at least two - information_schema and mysql). This means that the server is working correctly. Close the command line by executing the exit command.

Add the line: 127.0.0.1 localhost to the file C: \\ Windows \\ System32 \\ drivers \\ etc \\ hosts In the same file, delete or comment out (put the # sign at the beginning of the line) the line :: 1 localhost (if it is initially commented out, then there is nothing to do with it).

Installation and basic setup phpMyAdmin

We open the download page http://www.phpmyadmin.net/home_page/downloads.php and select for downloading an archive ending in * all-languages.7z or * all-languages.zip (at the time of writing, the latest version was phpMyAdmin 4.1.9 ) We create the phpmyadmin folder in C: \\ Apache24 \\ htdocs and extract the downloaded archive files there.

Let's check how it works. Open the browser and go to the address http: // localhost / phpmyadmin /. This window should open:

Now we need to create a configuration file for MySQL. We go into the phpmyadmin folder and create the config folder there. Open the following address in the browser: http: // localhost / phpmyadmin / setup /

Now, to configure the settings for connecting to MySQL, click on the “New Server” button, a new window opens, in the column “Server Host” localhost needs to be replaced with 127.0.0.1:

Save the settings (click Apply) and we will automatically be returned to the previous page. Choose the default language - Russian, the default server - 127.0.0.1, the end of the line - Windows. At the bottom, click Save and then Download.

The resulting file (config.inc.php) is saved to the root of the phpMyAdmin installation (C: \\ Apache24 \\ htdocs \\ phpmyadmin). We close the page, we will no longer need it.

That's all. We return to the page http: // localhost / phpmyadmin /. Now you can log in to the system as root (enter the password that was specified when configuring MySQL for the root user). Testing the connection to MySQL. If everything went well (you were able to enter phpMyAdmin), delete the config folder from the phpmyadmin folder.

In htmlAcademy and I work as a mentor on it. As part of the intensive work, students will have to raise their working environment and this note aims to simplify this difficult task for a beginner. There are different ways to raise a full LAMP stack, but we will go the classic way. We will configure all the components separately (without the use of ready-made combines) and start with PHP (there will certainly be a note with an overview of the finished LAMP assemblies). Since I plan to work with mentors on PHP intensives, I’m going to write similar instructions for repetition in other OSs (Linux, macOS). As they say, it’s better to sweat once, but then it will become easier for everyone. So, let's get started.

Downloading PHP for Windows

We go to the official website and download the current version of PHP. At the time of writing, this is - 7.1.4 . There are several distribution options available on the page. I have Windows 7 x64, respectively, I select a zip archive with VC14 x64 Thread Safe.

Please note that there are two distribution options available for download: Thread-Safe (TS)   and Non-Thread-Safe (NTS). The choice depends on how you plan to use the interpreter. TS is recommended for a single web services process (for example, configuring through the mod_php module for Apache). NTS is recommended for using IIS (Internet Information Service) and alternative FastCGI web server (for example, Apache with FastCGI module) and command line.

Installing PHP 7.1

Let's start preparing PHP for comfortable work from the command line. In the previous step, you downloaded the archive with the PHP distribution. Unlike most programs, PHP comes in a simple archive, and not as an installation package. Therefore, you will have to independently extract the files to any directory convenient for you. I prefer to store such things in the root of the system drive. Create a directory in the root of the “C:” drive (or any other place) "Php"   and extract the contents of the downloaded archive into it.

A lot of files will appear in the directory, but we are most interested in:

  • go-pear.bat   - script to install PEAR. Details about PEAR can be found in the official documentation.
  • php.exe   - allows you to execute PHP scripts from the console;
  • php-win.exe   - allows you to execute PHP scripts without using the console;
  • php-cgi.exe   - required to execute PHP code in FastCGI mode;
  • php7apache2_4.dll   - module for integration with the Apache 2.4.X web server;
  • phpdbg.exe   - debugger;
  • php.ini-development   - an example PHP configuration file for a development environment
  • php.ini-production - an example PHP configuration file for a production environment

We include a configuration file

We have the unpacked distribution kit, we will include the configuration file for it. We are going to experiment, so we’ll take php.ini-development. Make a copy of this file in the php directory ( C: \\ php) With name php.ini. IMPORTANT!   Make a copy, not a simple rename. During development, you may need to modify the configuration file and there is every chance of making a mistake that will be difficult to detect.

In such cases, there is nothing better than returning to the reference settings. In our case, it will be enough to repeat copying the file php.ini-development   at php.ini. So, at the end of the gestures, the php.ini file should appear in the directory with php. In further notes, we will definitely talk about its contents in more detail.

Testing PHP from the command line

At this step, the so-called “installation” is completed. Open the console ( cmd.exe, the shortcut is available in the "Standard" menu) and enter the command:

C: \\ php \\ php.exe --version

The result will be something like this:

PHP 7.1.4 (cli) (built: Apr 11 2017 19:54:37) (ZTS MSVC14 (Visual C ++ 2015) x64) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998 2017 Zend Technologies

The result confirms that PHP is working. For example, try creating a new script file (I created the file “test.php” right in the root of the “C:” drive) and put the text in it:

Now try executing this file and see the result:

C: \\ php \\ php.exe –f test.php

Function phpinfo ()   Displays PHP configuration information in a convenient way. We will talk more about this feature.

We simplify the call to php.exe

PHP is ready to work, but you must admit, driving the path to the php interpreter in the console every time is rather inconvenient. To make our life easier, we’ll make small changes to the environment variables. Run the applet in the control panel "System"   (or just press the hot key "Windows + Pause Break". Then click on the button "Change Settings". In the window that appears "System properties"go to the bookmark "Additionally". Find and click on the button "Environment Variables".

Find the variable in the list "PATH"   and press the button "Change", a variable editing window will appear. In the field "Variable Value" we need to add the path to the directory with PHP. Go to the very end of the line and through the semicolon specify the path to the directory with PHP: C: \\ php;

All click Ok. Now reboot the system (alas, have to). After restarting Windows, it will be possible to access PHP simply: php. For example, to display the version name, just write:

Php –version

And to interpret the test.php file located in the root of the “C:” drive:

Php –f C: \\ test.php

Or even launch the built-in web server:

Php -t C: \\ -S 127.0.0.1:8888 Listening on http://127.0.0.1:8888 Document root is C: \\ Press Ctrl-C to quit.

For testing, open a web browser, try contacting http://127.0.0.1:8888/test.php. Please note after parameter –T   we indicate the path to the directory, which will become the root directory of the web server. All scripts located in this folder will be available for request from the client. I have one file on the “C:” drive 1.php   and that’s what I am asking for.

Assoc .php \u003d phpfile ftype phpfile \u003d "C: \\ php \\ php.ee" -f "% 1" -% ~ 2

A little more about environment variables

Now let's talk about how PHP will look for the configuration settings file (remember, about php.ini) The documentation provides a complete search chain. To avoid unnecessary difficulties, I recommend immediately adding a new one to the environment variables - PHPRC   and as the value specify the path to the directory with the configuration file. My config is located in the same directory as the main php files, therefore I specify as the value of the variable -

"C: \\ php". After making the change, a reboot is required.

That’s all for me. The first part of the manual for beginners is ready.

Last update: 12.16.2017

There are different ways to install all the necessary software. We can install the components separately, but we can use ready-made assemblies similar to Denwer or EasyPHP. In such assemblies, the components already have initial configuration and are ready to create sites. However, sooner or later, developers still have to resort to installing and configuring individual components, connecting other modules. Therefore, we will install all the components separately. As the operating system will be used Windows.

What does installing PHP mean? First, we need a PHP interpreter. Secondly, we need a web server, for example, Apache, with which we can access the resources of the site we create. Thirdly, since we will use databases, we will also need to install some kind of database management system. As such, MySQL was chosen as the most popular in conjunction with PHP.

To install PHP, we’ll go to the offsite of developers http://php.net/. On the download page we can find various distributions for the Linux operating system. If our operating system is Windows, then we need to download one of the packages from the page http://windows.php.net/download/.

Download the zip package of the latest PHP release:

Typically, the latest release of PHP has two versions: Non Thread Safe and Thread Safe. We need to choose the thread safe version. For this version, options for 32-bit and 64-bit systems are available.

Unzip the downloaded archive into a folder called php. Let this folder be located at the root of drive C.

Now we need to do a minimal PHP configuration. To do this, go to the c: \\ php directory and find the file there php.ini-development. This is the initial configuration file for the interpreter. Rename this file to php.ini and then open it in a text editor.

Find the line in the file:

   ; extension_dir \u003d "ext"

This line points to the directory with plug-in extensions for PHP. Uncomment it (removing the semicolon):

Extension_dir \u003d "ext"

Since all extensions are in the ext directory.

Since we will use MySQL databases, we need to specify the extension in php.ini. By default, it already exists in the file, only it is commented out:

   ; extension \u003d mysqli

Uncomment it by removing the semicolon:

Extension \u003d mysqli

Now, by default, this library will be used when working with the database. We can also uncomment other extensions if necessary. But for starters, one is enough for us.

The rest of the contents of the file will remain unchanged.

Now install the web server.


Direct link:   php-5.3.10-Win32-VC9-x86.zip
  At the same time, download immediately and the documentation in Russian in the .chm format, you will need it when studying and working: php_enhanced_ru.chm

Unzip the archive into the desired directory (“C: \\ php” is initially suggested). Open the configuration file containing the recommended settings - “php.ini-development” (located in the root of the distribution), rename it to php.ini and make the following changes.

Revision php.ini:

  1. Find the line:
      post_max_size \u003d 8M
      Increase the maximum size of data received by the POST method to 16 MB, changing it to:
      post_max_size \u003d 16M
  2. Find the line:
      ; include_path \u003d ".; c: \\ php \\ includes"
      Uncomment it by removing the semicolon character before the line.
      (Warning exception! Backslashes when specifying a path):
      include_path \u003d ".; c: \\ php \\ includes"
      Create an empty directory "C: \\ php \\ includes" to store the connected classes.
  3. Find the line:
      extension_dir \u003d "./"
      Set the value of this directive to the path to the folder with the extensions:
      extension_dir \u003d "C: / php / ext"
  4. Find the line:
      ; upload_tmp_dir \u003d
      Uncomment it and specify the following path in the value:
      upload_tmp_dir \u003d "C: / php / upload"
      Create an empty folder “C: \\ php \\ upload” to store temporary files downloaded via HTTP.
  5. Find the line:
      upload_max_filesize \u003d 2M
      Increase the maximum size of uploaded files to 16 MB:
      upload_max_filesize \u003d 16M
  6. Connect, uncommenting, the data of the extension library:
      extension \u003d php_bz2.dll
      extension \u003d php_curl.dll
      extension \u003d php_gd2.dll
      extension \u003d php_mbstring.dll
      extension \u003d php_mysql.dll
      extension \u003d php_mysqli.dll
  7. Find the line:
      ; date.timezone \u003d
      Uncomment and set the time zone of your location (the list of time zones can be found in the documentation):
      date.timezone \u003d "Europe / Moscow"
  8. Find the line:
      ; session.save_path \u003d "/ tmp"
      Uncomment and set the value of this directive to this path:
      session.save_path \u003d "C: / php / tmp"
      Create an empty folder “C: \\ php \\ tmp” to store temporary session files.

Save the changes and close the php.ini file.

Next, you need to add the directory with the installed PHP interpreter in the PATH of the operating system. Why go along the path “Start” -\u003e “Control Panel” -\u003e “System”, open the “Advanced” tab, click the “ Environment Variables ”, in the“ System Variables ”section, double-click on the“ Path ”line, add“ Variable Value ”to the field, to what is already there exists, the path to the directory with PHP installed, for example, "C: \\ php" (without quotes). Note that the semicolon character separates the paths. For the changes to take effect, reboot the operating system.

Example Path line:
  % SystemRoot% \\ system32;% SystemRoot%;% SystemRoot% \\ System32 \\ Wbem; C: \\ php; C: \\ Program Files \\ MySQL \\ MySQL Server 5.5 \\ bin

Installation and configuration of the PHP interpreter is completed.

Description of the connected libraries:

php_bz2.dll - With this extension, PHP will be able to create and unzip archives in bzip2 format.

php_curl.dll   - A very important and necessary library that allows you to connect and work with servers using a huge number of Internet protocols.

php_gd2.dll   - Another indispensable library that allows you to work with graphics. You thought in PHP you can only generate HTML pages? And no! With PHP, you can almost everything, including drawing.

php_mbstring.dll   - The library contains functions for working with multi-byte encodings, which include encodings of oriental languages \u200b\u200b(Japanese, Chinese, Korean), Unicode (UTF-8) and others.

php_mysql.dll   - The name of the library speaks for itself - it is necessary for working with the MySQL server.

php_mysqli.dll   - This library is an extension of the previous one and contains additional PHP functions for working with the MySQL server version 4.1.3 and higher.

These libraries should be enough for the full work of PHP. Over time, if such a need arises, you can connect additional libraries, but you should not connect them all at once with the thought that you won’t ruin the porridge with oil, in this case an excessive number of connected libraries can significantly slow down PHP.

Original article: http://php-myadmin.ru/learning/instrument-php.html

We continue to collect the local WAMP server on the local machine (personal computer). In this article, we install the PHP interpreter, it is also the letter [P] in the acronym WAMP.

In past articles, I talked about how to install the Apache HTTP web server. We collect the local server running Windows 7. It's time to install PHP.

We will install PHP in the php folder created on the system drive: C: \\ Program Files \\ PHP.

Where to get PHP

We take the latest php version only on the official website, here is the link: http://php.net/downloads.php. another one: http://windows.php.net/download#php-7.0. We will not take the latest version of php7.0, we will take not such "revolutionary" PHP 5.6 (5.6.20). I take the assembly for the 32-bit architecture of Windows 7 with the built-in Windows installer.

Installing PHP with the installer (MSI)

The latest PHP with the installer and most importantly with the Apache 2.2 module. this is php-5.3.10-nts-win32-vc9-x86.msi. Take it here: http://windows.php.net/downloads/releases/archives/ and put it.

Note: We select with the Apache 2.2. Module, since we build WAMP on Apache 2.2, which we already installed in the article: here.

Installing PHP using the installer (MSI) is simple, in several windows:

1. Run the downloaded php-5.3.10-nts-Win32-VC9-x86.msi file. The first installation window php-5.3.10 2. We get acquainted with the license and agree with it, go ahead by clicking the "Next" button.

3. On this page, specify the folder in which we put PHP. Let it be a directory:

  4. On the next page, select the web server used. In our assembly, this is Apache2.

  5. On this page you need to select the PHP modules that we will need. For safety we choose everything.

6. Click "Install"
  Click Install to install php-5.3.10
  We see the process of the php-5.3.10 installation window

All! Installing PHP on the local computer is complete.

Do you like the article? To share with friends: