TVs. Consoles. Projectors and accessories. Technologies. Digital TV

How to install local Apache server with Php, MySQL, phpMyAdmin on Windows computer. How to install local Apache server with Php, MySQL, phpMyAdmin on a Windows computer Download PHP for Windows

The Apache project does not provide binary versions software, but only the source code. However, they can be obtained from third party sites:

  • ApacheHaus;
  • Apache Lounge.

Download 32-bit Apache version Windows ( httpd-2.4.20-win32-VC14.zip) or 64-bit version ( httpd-2.4.20-win64-VC14.zip). Check if you have installed 64-bit OS version. To determine this, you can use msinfo32.exe. This tool helps you gather information about your computer, diagnose problems, or can be used to access other tools.

To run it, run the command Run > msinfo32 > press Enter.

Once you find the version you need, download the Zip archive and then extract its contents to the C:Apache24 folder.

Before starting the Apache server, if you need to change the listening port to 8181:

  • Open in text editor file C:Apache24confhttpd.conf ;
  • Find the following line: Listen 80 ;
  • And change it to: Listen 8181.

Save your changes.

Now you can start the Apache Windows 7 server:

Open a command prompt as an administrator and go to the bin subdirectory:

Type httpd.exe and press Enter.

If a dialog box appears on the screen stating that the MSVCR140.dll file is missing, you need to install Visual C++ Redistributable for Visual Studio 2015 (select vc_redist.x64.exe if you have installed Windows 64-bit).

Now open your browser and enter http://localhost:8181 into the address bar to launch the demo site.

Installing PHP 7 on Windows

PHP 7 is an important update to the server-side web development language PHP. Download the VC14 x64 Thread Safe zip archive (2016-Apr-29 00:38:19) . If you have downloaded 32-bit version of Apache, you need to install PHP x86.

Create a folder named " php7", extract the contents of the php-7.0.6-Win32-VC14-x64.zip archive into it, and then place the folder in the root of drive C:

Configuring Apache to Use PHP

Open the installation configuration file Windows Apache C:Apache24confhttpd.conf.

Copy the following lines to the beginning of the file:

  • AddHandler application/x-httpd-php.php;
  • AddType application/x-httpd-php .php .html;
  • LoadModule php7_module "c:/php7/php7apache2_4.dll";
  • PHPIniDir "c:/php7" .

In the section add the line index.php and place it before index.html :

DirectoryIndex index.php index.html

Save the Apache PHP Windows file. Now rename the file C:php7php.ini-development to C:php7php.ini.

Enabling mod_rewrite to rewrite URLs

Open the configuration file Apache C:Apache24confhttpd.conf;
Find the line in it #LoadModule rewrite_module modules/mod_rewrite.so and remove the hash symbol "#";
Find all occurrences of the string " AllowOverride None" and change them to " AllowOverride All".

Setting up PHP with MySQL

Edit php file.ini and uncomment the extensions directory. Remove the symbol "; " at the beginning of the lines:

; Directory in which the loadable extensions (modules) reside. ; http://php.net/extension-dir; extension_dir = "./" ; On windows: extension_dir = "ext"

Activate the following lines, this will allow you to run MySQL modules:

extension=php_mysqli.dll extension=php_pdo_mysql.dll

And also the lines below if you are using Apache PHP MySQL Window s installation in a development environment:

extension=php_curl.dll extension=php_fileinfo.dll extension=php_gd2.dll extension=php_mbstring.dll extension=php_openssl.dll

Uncomment error_log to enable file logging:

; Log errors to specified file. PHP's default behavior is to leave this value ; empty. ; http://php.net/error-log ; Example: error_log = c:php7php_errors.log

Save your changes.

IMPORTANT! Set Windows PATH to find PHP

  • Right click on the shortcut My Computer - Properties - Advanced - Environment Variables;
  • In the section " System Variables"Find the item "Path", click on it and select "Change";
  • Add the path to the php folder at the end ( must be after the semicolon ";"). For example: ";C:php7 ";
  • Click "OK".

How to check if PHP is installed

Create a file at C:Apache24htdocsphpinfo.php and add the following code to it:

Restart Apache Windows and then in your browser navigate to http://localhost:8181/phpinfo.php. This page should display information about installed version PHHP.

And describes only distinctive points, which relate to installing Apache24 and PHP7 on Windows. The description of installing the MySQL DBMS remains the same and is not repeated in this instruction.

Before you continue reading, pay attention to whether you really need to install and configure all this under Windows? Maybe you should pay attention and not waste your time and nerves setting up the same thing directly in Windows? In any case, read the article about. Perhaps it will save you not only time, but also health.

This manual is intended for developers with basic knowledge Apache and PHP. This manual will describe only difference in installing Apache and PHP with basic instructions for installing PHP 5.6. If you do not know what a WEB server, http protocol and PHP interpreter are, then you can always learn about it in more detail by reading the documentation.

I will not answer in the comments questions the answer to which is in this or the main instructions, a link to the main instructions is indicated in the first paragraph, as well as questions that relate to understanding Apache works and PHP, and even more so for questions about errors in development. For this, there are appropriate resources, literature, forums, and courses. However, you can always ask any question you are interested in. Perhaps someone from the community can help you.

So, let's go!

Installing Apache 2.4 VC14

  1. Loading Apache 2.4 binaries VC14 for your system via the link http://www.apachelounge.com/download/ Download the 64-bit version of the server. At the time of writing these lines, the file was called like this: httpd-2.4.17-win64-VC14.zip
  2. If you need any additional modules, you can download them there (not necessary for the basic installation)
  3. Download and install Visual C++ Redistributable for Visual Studio 2015 updates from the Microsoft website.
  4. Unzip the contents of the folder Apache24 from the downloaded archive to D:\USR\apache. Please note that in D:\USR\apache you need to put not the Apache24 folder from the archive, but its contents. There is no need to install anything.
  5. Change the value in the file ServerRoot on "d:/USR/apache" (line 37) and value DocumentRoot(And Direcroty) on "d:/USR/www" (lines 243 and 244). You should also uncomment line 219 and change it to: ServerName localhost:80
  6. We change the log storage parameters in the same file (find the parameters and change): ErrorLog "D:/USR/log/apache-error.log" CustomLog "D:/USR/log/apache-access.log" common
  7. Install the Apache service. Open the command line on behalf of the Administrator and insert the following line there: D:\USR\apache\bin\httpd.exe -k install
  8. We monitor error messages during service installation. If everything is done correctly, there should be no errors. If, after executing the line, the command line does not appear again, then you did something wrong. Simply use the copy and paste functions to avoid typing errors.
  9. Create a shortcut on the desktop for D:\USR\apache\bin\ApacheMonitor.exe and/or put it in startup (to open the startup window in WIN8..10 you need to press WIN+R, then enter shell:Startup and click OK)
  10. Launch ApacheMonitor. A shortcut will appear in the system tray. Left-click on it and select Apache24 -> Start.
  11. In the browser go to http://localhost/ - you should see It works!
  12. If you don’t see such an inscription, we figure out what went wrong (we read the logs, google, try to figure out the problem ourselves, since we decided to understand the intricacies of the web server)

Installing PHP 7

  1. Loading latest version VC14 x64Thread Safe via the link http://windows.php.net/download/. Please note that you need VC14 and exactly Thread Safe. The file you need will most likely be named something like: php-7.0.0-Win32-VC14-x64.zip
  2. Extracting the contents of the archive into D:\USR\php. As with Apache, there is no need to install anything.
  3. To file D:\USR\apache\conf\httpd.conf add the lines: LoadModule php7_module "d:/USR/php/php7apache2_4.dll" AddHandler application/x-httpd-php .php # Path to the php.ini file PHPIniDir "D:/USR/php"
  4. And we change meaning parameter DirectoryIndex on index.html index.php (line 278)
  5. Using ApacheMonitor restart Apache (Apache24 -> Restart)
  6. We go to the browser http://localhost/index.php and make sure that PHP is working (the browser will display PhpInfo output).
  7. Making a copy of the configuration file template D:\USR\php\php.ini-development with name D:\USR\php\php.ini- This is a configuration file for PHP.
  8. Editing the configuration file D:\USR\php\php.ini. Using the search, we find inside the file, uncomment it and change the parameters. Note that the extension parameter specifies a set of PHP extensions. Uncomment the extensions that you need. In the example, the extensions that I needed. Specify your time zone, not mine: extension_dir = "D:/USR/php/ext" sys_temp_dir = "D:/USR/tmp" extension=php_curl.dll extension=php_gd2.dll extension=php_gettext.dll extension=php_mbstring. dll extension=php_mysqli.dll extension=php_openssl.dll date.timezone = Europe/Zaporozhye

    If you have problems running curl, please refer to these instructions.

  9. Performed in command line php -m to view the list of connected extensions.
  10. Restarting Apache using ApacheMonitor

The installation and configuration of everything else has not changed. Please refer to the PHP 5.6 Installation Guide for details.

To download the PHP 7 Windows distribution, visit the download section binary files official website of RNR. Each release comes with four options:

  • x86 Non Thread Safe- 32-bit CGI version of the distribution;
  • x86 Thread Safe- 32-bit version for installation as a Web server module;
  • x64 Non Thread Safe- 64-bit CGI version of the distribution;
  • x64 Thread Safe- 64-bit version for installation as a Web server module.

Option Thread Safe designed to safely execute PHP 7 in parallel threads within one system process, for example, if PHP is installed as an Apache Web server module. Since we are going to use the built-in server, it doesn't matter which distribution is chosen, it is best to use the option Non Thread Safe. The latter option is also used when connecting PHP as an external FastCGI application, which is launched for each external request.

Before the name of the distribution, one of the abbreviations VC11, VC14 can be placed, meaning the versions of Visual Studio (2012 and 2015, respectively), with which the distribution was compiled. In order to successfully run the project, you should download the appropriate Visual C++ Redistributable Package for Visual Studio, which contains the necessary dynamic libraries:

Attention!

Libraries from the English version of Visual Studio are required; the Russian version of the package will not work.

After downloading the zip archive, you should unpack it into some folder, for example C:\php.

You can make sure that PHP 7 is available by running the command line, and then go to the C:\php folder using the command

>cd C:\php

By running the php command on the command line with the -v parameter, you can find out the current version of PHP:

> php -v PHP 7.0.0 (cli) (built: Dec 3 2015 09:31:54) (NTS) Copyright (c) 1997-2015 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies

To ensure that the PHP command is available anywhere file system, the path to the PHP interpreter should be specified in the path environment variable.

To access environment variables, you need to open the Control Panel, go to the section System. Most quick way to get to this point is to right-click on the button Start and select item System from the context menu. IN operating systems pre-Windows 8 should be selected from the menu Start paragraph Computer and in context menu select item Properties. In the Control Panel window that opens with the active section System click on the link on the left Additional options systems. Then in the System Properties window, on the Advanced tab, click the button Environment Variables. In the dialog box that opens, in the section System Variables you should look for the path environment variable and add it to the path to the C:\php directory. Separate paths in the value of the path variable are separated by semicolons (a semicolon is not required at the end of the entire line). After this, the php command will be available in any folder on your computer.

Php is a popular web programming and website development language. With each new version the language became more and more interesting, it all started with a simple functionally oriented programming language suitable only for creating web pages, and finally Php 5 is now positioned as a full-featured objective-oriented scripting language. php 7 brings many interesting improvements and fixes such as total performance optimization and the addition of multi-threading, but that’s not what we’re talking about today; you can find reviews of php 7 features on the internet.

This instruction will describe installing php 7 on Linux; it is intended primarily for Ubuntu users but is also suitable for other distributions. We'll look at installing from a PPA on Ubuntu and building from source.

PPA repositories allow third-party developers to distribute their software packages, bypassing the official Ubuntu repositories. Usually you can get the newest or even beta versions of programs from a PPA. After the official release of php 7, a PPA was made for Ubuntu. Let's add it to the system:

$ sudo add-apt-repository ppa:ondrej/php-7.0

sudo apt-get update

And you can install:

sudo apt-get install php7.0

To support mysql you need to install the library:

sudo apt-get install php7.0-mysql

To install php as an fpm module, run:

sudo apt-get install php7.0-fpm

Building php 7 from source

First, let's install the tools and libraries we need:

sudo apt-get install git autoconf bison libxml2 libxml2-dev opessllibcurl4-openssl-dev libbz2-dev libjpeg-dev libpng-dev libxpm-dev libfreetype6-dev libgmp-dev libmcrypt-dev libmysqld-dev libpspell-dev librecode-dev

Let's create a working folder:

Let's synchronize php sources from the git repository:

git clone https://git.php.net/repository/php-src.git

We proceed directly to the assembly and installation, the program will be installed in the current folder - ~/tmp:

cd php-src
$ sudo ./buildconf
$sudo./configure\
--enable-mbstring\
--enable-zip\
--enable-bcmath\
--enable-pcntl\
--enable-ftp\
--enable-exif \
--enable-calendar\
--enable-sysvmsg\
--enable-sysvsem\
--enable-sysvshm\
--enable-wddx\
--with-curl\
--with-mcrypt\
--with-iconv\
--with-gmp\
--with-pspell\
--with-gd\
--with-jpeg-dir=/usr\
--with-png-dir=/usr\
--with-zlib-dir=/usr\
--with-xpm-dir=/usr\
--with-freetype-dir=/usr\
--with-t1lib=/usr\
--enable-gd-native-ttf\
--enable-gd-jis-conv\
--with-openssl\
--with-mysql=/usr \
--with-pdo-mysql=/usr \
--with-gettext=/usr\
--with-zlib=/usr\
--with-bz2=/usr\
--with-recode=/usr\
--with-mysqli=/usr/bin/mysql_config
$make

Create a folder for the configuration file:

mkdir $HOME/tmp/usr/etc

Create a php configuration file with the following content:

nano $HOME/tmp/usr/etc/php.ini

max_execution_time=600
memory_limit=128M
error_reporting=0
display_errors=0
log_errors=0
user_ini.filename=
realpath_cache_size=2M
cgi.check_shebang_line=0
zend_extension=opcache.so
opcache.enable_cli=1
opcache.save_comments=0
opcache.fast_shutdown=1
opcache.validate_timestamps=1
opcache.revalidate_freq=60
opcache.use_cwd=1
opcache.max_accelerated_files=100000
opcache.max_wasted_percentage=5
opcache.memory_consumption=128
opcache.consistency_checks=0

Save, and php 7 is installed and configured, you can proceed to testing.

In this article, I will describe the process of installing PHP 7 on Ubuntu from a PPA repository. This note will be written in the format of a small manual, so I will try to briefly outline the technical side of the process. Additionally, in my previous posts you can read how to install PHP 7 in and . There is also a description of the process from source code in Debian; this option is more labor-intensive, but has obvious advantages in terms of optimization.

Installing PHP 7 on Ubuntu

At the moment, PHP 7 is not officially available for installation on Ubuntu. But we can install PHP 7 on Ubuntu using a PPA - apt personal repository hosted on the Launchpad website. With PPAs, third-party developers are able to create and distribute packages for Ubuntu outside of official channels.

Using the command below, add the PHP 7 repository to Ubuntu:

Add-apt-repository ppa:ondrej/php

After installing the PPA, update your local package cache:

Apt-get update

Now we have access to the new packages, we can install PHP 7 on Ubuntu. In this article I will describe the process of setting up PHP 7 for use in conjunction with the Nginx web server. To do this we will need to install PHP-FPM:

Apt-get install php7.0-fpm

If your scripts use MySQL during operation, run the command:

Apt-get install php7.0-mysql

Setting up PHP 7 to work with Nginx

PHP 7 and Nginx processes communicate with each other using a unix socket. By default in PHP 7 the unix socket has the following location:

/var/run/php/php7.0-fpm.sock

Open the default configuration file in the nano text editor:

Nano /etc/nginx/sites-enabled/default

Completely delete all contents of the default file, and then copy the lines from the example below:

Server ( listen 80 default_server; root /var/www/html; index index.php index.html; server_name _; location / ( try_files $uri $uri/ /index.php?q=$uri&$args; ) location ~ \ .php$ ( try_files $uri = 404; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; ) )

Close the file and save your changes. To use the new settings you need to restart Nginx:

Nginx -t service nginx restart

Checking the operation of PHP 7

To check the correct installation and configuration of PHP 7 in Ubuntu, create a file in the final directory of the site:

Nano /var/www/html/info.php

The following content:

Open the file in your browser:

Http://server_ip/info.php

If you have correctly installed and configured PHP 7 on Ubuntu, you should see a page containing its configuration information.



Related publications