Install Apache on Windows 10 x64. Installing Apache Web Server

03/19/17 5.9K.

Apache project does not provide binary versions software, but only the source code. Nevertheless, they can be obtained on third-party sites:

  • Apachehaus;
  • Apache Lounge.

Download the 32-bit version of Apache 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 version. To determine this, you can use msinfo32.exe. This tool helps in collecting computer information, in diagnosing problems or it can be used to access other tools.

To run it, execute the command Run\u003e MSINFO32\u003e Press ENTER.

After you find the desired version, download the ZIP archive, and then remove its contents to the C: Apache24 folder.

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

  • Open B. text editor File C: Apache24Confhttpd.conf;
  • Find the following line: listen 80;
  • And change it on: listen 8181.

Save the changes.

Now you can run the APACHE Windows 7 server:

Open command line On behalf of the administrator and go to the BIN subdirector:

Enter httpd.exe and press ENTER.

If a dialog box appears on the screen with the missing MSVCR140.DLL file, you must install Visual C ++ Redistributable for Visual Studio 2015 (select vc_redist.x64.exe if you have installed 64-bit windows version ).

Now open the browser and enter the HTTP: // Localhost: 8181 to start the demonstration site.

Installing PHP 7 in Windows

PHP 7 is an important update for PHP web development server. Download Zip-archive VC14 X64 Thread Safe (2016-APR-29 00:38:19). If you are uploaded 32-bit version of ApacheYou must install PHP x86.

Create a folder named " php7.", Remove the contents of the archive php-7.0.6-win32-vc14-x64.zip in it, and then place the folder in the root of the disk C:

Adjust Apache to use PHP

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

Copy the following rows 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 chapter Add an index.php string and place it in front of index.html:

DirectoryIndex index.php index.html

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

Enabling Mod_rewrite to overwrite URLs

Open the configuration file Apache C: Apache24ConfHttpd.conf;
Find a string in it #LoadModule Rewrite_Module Modules / mod_rewrite.so and remove the hash icon "#";
Find all the entry of the string " ALLOWOVERRIDE NONE."And change them to" AllowOverride All ».

PHP Setup with MySQL

Edit the php.ini file and unavomat the extension 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 \u003d "./"; ON Windows: Extension_Dir \u003d "Ext"

Activate the following lines, it will enable the MYSQL module launch:

eXTENSION \u003d PHP_MYSQLI.DLL EXTENSION \u003d PHP_PDO_MYSQL.DLL

As well as the lines below if you use the Apache PHP Mysql Window S setting in the development environment:

extension \u003d php_curl.dll extension \u003d php_fileinfo.dll extension \u003d php_gd2.dll extension \u003d php_mbstring.dll extension \u003d php_opensl.dll

Unset ERROR_LOG to enable file logging:

; Log Errors to Specified File. Php "s default behavior is to leve this value; empty .; http://php.net/error-log; example: error_log \u003d c: php7php_errors.log

Save the changes.

IMPORTANT! Install the Path for Windows to find PHP

  • Right click on the label My computer - Properties - Optional - Wednesday Variables;
  • In chapter " System variables»Find the" Path "point, click on it and select" Change ";
  • Add at the end to the PHP folder ( mandatory after point with a comma ";"). For example: "; C: PHP7";
  • Click OK.

How to check if PHP is installed

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

Apache is the most popular free web server. For 2016, it is used for 33% of all Internet sites, and this is approximately 304 billion sites. This web server was developed in the distant 1995, as a replacement for the popular NCSA server and corrected many of his problems. It is rumored that his name is like a patchy, a patch, since it fixed the NCSA errors. Now, this is a cross-platform program that supports Windows, Linux and MacOS and ensures sufficient flexibility, customizability and functionality. The program has a modular structure, which allows it to expand its functionality almost indefinitely using modules.

You can install Apache in Linux using multiple commands, but the program provides a very a large number of Settings that can be changed, as well as modules, after switching on which it will work better. This article will consider installing and configuring Apache, as the main system we will use Ubuntu, but you can repeat these actions in any other distribution. Not only the installation of the program itself, but also the ways to configure, configure the APACHE virtual hosts, as well as the most useful modules.

At the moment, the most a new version 2.4 programs Therefore, Apache 2.4 configuration will be considered. As I said, in Linux program It is installed literally a couple of teams. To install in Ubuntu, you first update the system to the new version:

sudo Apt Update.
$ sudo APT UPGRADE

Then install Apache2:

sudo Apt Install Apache2

In other distributions, the program package is called either so, or httpd and its installation will not cause difficulties.

After the installation is complete, you need to add a web server to autoload in order not to run it manually after turning on the computer:

sudo SystemCTL Enable Apache2

Adjust Apache

The time has already passed when the Apache configuration was stored in one file. But it is correct when everything is distributed over your directories, it is easier to navigate in configuration files.

All settings are contained in the / etc / apache / folder:

  • File /etc/apache2/apache2.conf. responsible for basic settings
  • / etc / apache2 / conf-available / * - Advanced web server settings
  • / ETC / Apache2 / Mods-Available / * - Settings modules
  • / etc / apache2 / SITES-AVAILABLE / * - tinctures of virtual hosts
  • /etc/apache2/ports.conf. - Ports on which Apache works
  • / etc / apache2 / envvars

As you notice there are two folders for Conf, Mods and Site. This is available and enabled. When you turn on the module or host, a symbolic link is created from the Available folder (Available) to the Enable folder (enabled). Therefore, the settings are best executed in the Available folders. Generally speaking, it would be possible to do without these folders, take everything and in the old man in one file, and everything would work, but now no one does.

First, let's look at the main configuration file:

vi /ta/apache2/apache2.conf.

Timeout. - Specifies how long the server will try to continue interrupted transmission or receiving data. 160 seconds will be quite enough.

Keepalive ON. - very useful parameter, allows you to transmit multiple files for one connection, for example, not only hTML Page, but also pictures and CSS files.

MaxkeepaliveRequests 100. - The maximum number of requests for one connection, the more, the better.

KeepaliveTimeout 5.- Timeout connections, usually for downloading the page 5-10 seconds, so you do not need to install more, but also to tear the connection earlier than all the data is not necessary.

User, Group. - User and group, on behalf of which the program will work.

HostNameLookups. - write to logs instead of IP addresses domain names, it is better to turn off to speed up the work.

Loglevel. - Error logging level. By default, WARN is used, but that the logs are filled slowly enough to include ERROR

Include. - All Include directives are responsible for connecting the configuration files discussed above.

Directory directives are responsible for setting up access rights to a directory in file System. The syntax here is:


Parameter Value

These main options are available here:

AllowOverride - Specifies whether to read .HTaccess files from this directory, these are the same settings files and the same syntax. All - Allow all, None - Do not read these files.

Documentroot. - Sets from which folder you need to take documents to display the user

Options. - Indicates which features of the web server must be allowed in this folder. For example, ALL - Allow all, FollowSymLinks - go to symbolic links, indexes - display the contents of the directory if there is no index file.

Require - Sets which users have access to this catalog. REQUIRE ALL DENIED - ALL DANGER, REQUIRE ALL GRANTED - All resolve everything. You can use instead of all the user or group directive to explicitly specify the user.

Order - Allows you to manage access to the directory. Takes two Allow values, deny - allow for all other than those specified or DENY, ALLOW - to prohibit for all except the specified..ru.

Here all these directives are not used, since we are satisfied with the default values, but in files.htaccess they can be very useful.

We have left the /etc/apache2/ports.conf:

It is only one directive, Listen, which indicates the program on which port you need to work.

The last file / etc / apache2 / envvars, you can hardly use it, it specified variables that can be used in other configuration files.

Configuring Apache Server via HTAccess

Files.htaccess allow you to configure a web server on Ubuntu for behavior in a specific directory. All instructions specified in this file are performed as if they were incovered in the tag If it were in the main file.

It is important to notice that in order for the server to read the instructions from.htaccess settings for this folder in the main file or virtual host file should not contain ALLOWOVERRIDE NONE.so that all settings can work AllowOverride All..

And otherwise, any configuration of the Apache server can be performed here, from turning on the modules to the usual change to the folder. Since all parameters we have already considered simply give a pair of examples:

Order Deny, Allow
DENY FROM ALL

It prohibits all access to this folder, it is important to apply for folders with the configuration. Most often. Htaccess is used to work with the mod_rewrite module, which allows you to change requests for the fly:

RewriteEngine ON.
REWRITERULE ^ Product /([i^/\\._ +)/?$ Product.php? ID \u003d $ 1 [L]

But this is a very extensive topic and goes beyond this article.

Setting up Apache modules

As I said, Apache - modular programHer functionality can be expanded with modules. All available modules loaders and module configuration files are located in the / etc / apache / mods-available folder. And activated in / etc / apache / mods-enable.

But you do not need to analyze the contents of these folders. Adjusting Apache 2.4 by adding modules is performed using special teams. View all running modules can be team:

You can enable the module with the command:

sudo a2enmod name_Module

And disable:

sudo a2dismod_name_Module

After switching on or off modules you need to restart Apache:

sudo SystemCTL Restart Apache2

During the execution of one of these commands, a symbolic link to the module file with the LOAD extension in the Mods-Available directory is created or deleted. You can see the contents of this file, there is only one line. For example:

vi /etc/apache2/mods-available/deflate.load

This is to activate the module, it was possible to simply adding this line to the Apache2.Conf file. But it is customary to do just to avoid confusion.

Module settings are located in the same folder, only in the file with extension.conf instead of Load. For example, let's see the settings of the same module for the Deflate compression:

vi /etc/apache2/mods-available/deflate.conf.

Files in the CONF-Available folder are the same modules, only they are installed separately from Apache, it can be configuration files to turn on the PHP module or any other programming language. Everything works here exactly, only commands to enable and disable these modules are few others:

a2ENCONF Name_Module

a2DISCONF Module name

As you were convinced, turn on the modules is very simple. Let's turn on the several necessary, but not enabled by default modules:

sudo a2enmod expires.
$ sudo a2enmod headers
$ sudo a2enmod rewrite
$ sudo a2enmod ssl

EXPIRES and HEADERS modules reduce the load on the server. They return the NOT modified header if the document has not changed from the last request. The EXPIRIES module allows you to set the time to which the browser must cache the resulting document. Rewrite allows you to change the requested addresses on the fly, it is very useful when creating a CNC links and T d. And the latter to enable support for SSL encryption. Do not forget to restart Apache2 after completing the settings.

Setting up Apache virtual hosts

It would not be quite convenient if only one site could be placed on one physical machine. Apache can support hundreds of sites on one computer and produce proportion for each of them. For this, virtual hosts are used. The server determines which domain request comes and gives the desired content from the folder of this domain.

Apache host settings are located in the / etc / apache2 / hosts-available / folder. To create a new host, it is enough to create a file with any name (better over with the name of the host) and fill it with its desired data. Wrap all these parameters need to be in directive VirtualHost. In addition to the parameters considered here, such:

  • ServerName. - the main name of the domain
  • Serveralias. - Additional name to which site will be available
  • Serveradmin. - email Administrator
  • Documentroot. - folder with documents for this domain

For example:

vi /etc/apache2/sites-available/test.site.conf.

Here he is great and terrible. A set of novice web developers who have developed heads on setting up its configuration files on its century. 🙂 But we are with you people, strong nerves and steel stomachs - therefore, we went.

Initial installation and configuration

Unpack the distribution archive to C: \\ Apache2 directory.

Open in the text editor "C: \\ Apache2 \\ Conf \\ httpd.conf" in the text editor, which is the main configuration file of the Apache server.

Well, now hold on. Women, old men and children, please do not read. For the mental state of people who finished the article to the end - the authors of responsibility are not carried. 🙂

Edit file httpd.conf.

  1. To download the MOD_Rewrite module, find and unavailable (remove the "#" symbol at the beginning of the string) this line:
    LoadModule Rewrite_Module Modules / mod_rewrite.so
  2. To download the PHP interpreter, it is necessary to add a string to the end of the module load unit:
    LoadModule php5_module "C: /PHP/PHP5APACHE2_2.dll"
  3. Determine the directory containing configuration pHP fileBy adding the following line below:
    Phpinidir "C: / PHP"
  4. Find and unavomat the string:
    ServerName www.example.com:80
    Edit it as follows by setting the initial name of the server:
    ServerName Localhost: 80
  5. Find the string:
    Documentroot "C: / Apache2 / Htdocs"
    Assign the root directory management sites (a little later we will create it):
    Documentroot "C: / Apache"
  6. Find this unit:

    Options FollowSymLinks.
    ALLOWOVERRIDE NONE.
    Order Deny, Allow
    DENY FROM ALL

    And replace it to the following:

    Options Includes Indexes FollowSymLinks
    AllowOverride All.
    ALLOW FROM ALL
  7. Remove or complain the initial control unit directories (it will not need it), which looks like this without comment:

    Options Indexes FollowSymLinks.
    ALLOWOVERRIDE NONE.
    Order Allow, Deny
    ALLOW FROM ALL
  8. Find the unit:

    DirectoryIndex index.html.

    Replace it on:

    DirectoryIndex index.html index.htm index.shtml index.php
  9. Find the string:
    ErrorLog "Logs / Error.log"
    Replace to the following (in this case, view the global server error file will be more convenient):
    ErrorLog "C: /APACHE/error.log"
  10. Find the string:
    CustomLog "Logs / Access.log" COMMON
    Change to:
    CustomLog "C: /Apache/Access.log" Common
  11. For SSI operation (enabled on the server side), the following lines in the block , It is necessary to find and unassign:
    AddType Text / Html .shtml
    AddOutputFilter Includes .shtml.
  12. Add below to the same block two lines:
    AddType Application / X-Httpd-PHP .php
    AddType Application / X-Httpd-PHP-Source .PHPS
  13. And finally, find and uncomment lines:
    Include conf / extra / httpd-mpm.conf
    Include Conf / Extra / httpd-autoindex.conf
    Include conf / extra / httpd-vhosts.conf
    Include conf / extra / httpd-manual.conf
    Include Conf / Extra / httpd-default.conf

Save the changes and close the "httpd.conf" file

Now open the file "C: \\ Apache2 \\ CONF \\ EXTRA \\ httpd-vhosts.conf" and make the following changes in it.

Existing blocks of examples of virtual hosts must be removed, and insert only the following:
NameVirtualHost *: 80


Documentroot "C: / Apache / Localhost / www"
ServerName Localhost.
ErrorLog "C: /APache/localhost/error.log"
CustomLog "c: /apache/localhost/access.log" Common

Save the changes and close the file "httpd-vhosts.conf"

Configuring configuration files is completed, now you need to install the Apache2.2 service.

Installing Apache2.2 service in pictures

Run the command line and enter in it "C: \\ Apache2 \\ Bin \\ httpd.exe -k install"

This is what we have to see if the APACHE2.2 service is successful.

If everything went successfully, moving on - install the manual start of the Apache2.2 service for which you pass: "Start" ("Start") → "Control Panel" ("Administrative Tools" ("Administration") → "Services" ("Services"), in the service management window that opens, select the "Apache2.2" string and make a double click on it, after which you choose the manual launch of the service - "STARTUP TYPE: MANUAL "(" Start type: manually "). This must be done in order for unnecessary services to load the system. Considering that home computer Used not only for web developments, but also for many other needs, manual launch and stop, non-permanently used services, is the most acceptable.

Creating virtual host directories

At the root of the disc, you need to create a "Apache" directory - your virtual hosts (domains) will lie in it, the global error log file "error.log" (created by the program when you first start, automatically), the global access file "Access.log" (created automatically). In the Apache catalog, create another empty folder - "LocalHost", in which, in turn, create a folder "WWW", it is in the last one and it will be necessary to keep our good in the form of local scripts. This seemingly strange directory structure is dictated by a similar scheme for building directories in UNIX systems, and is designed to simplify its understanding and use.

An example of creating a virtual host

If you need to install your own virtual hosts, do the following:

Open the "httpd-vhosts.conf" file, and create a block in it, approximately the following content:

# Folder in which your host root will be.
Documentroot «C: /APACHE/Test.RU/www»
# Domain for which you can turn to a virtual host.
ServerName Test.ru.
# Alias \u200b\u200b(extension name) domain.
Serveralias www.test.ru.
The file in which the errors will be recorded.
ErrorLog "C: /APACHE/test.RU/error.log"
# File access magazine to the host.
CustomLog "C: /APache/test.ru/Access.log" COMMON

Then in the "Apache" directory, create a "Test.ru" folder (right so, with a point), in which, in turn, create the folder "WWW".

The next virtual host creation step is to change the C: \\ Windows \\ System32 \\ Drivers \\ ETC \\ HOSTS operating system. Open this file And add two lines to it:
127.0.0.1 Test.ru.
127.0.0.1 www.test.ru.

Now run the Apache server by running on the "C: \\ Apache2 \\ bin \\ httpd.exe -k -k -k" command, open the browser, enter in the address bar "test.ru" or "www.test.ru" and you will find yourself in your virtual Host. Just be careful, now you can get to the original site with the name of the virtual host ("www.test.ru", if any), only commented either by removing the string: "127.0.0.1 www.test.ru", in the above-mentioned file " hosts. "

Apache documentation, when the server is running, is available at http: // Localhost / Manual /

You can stop the work of Apache by performing "C: \\ Apache2 \\ Bin \\ httpd.exe -kk" in the command prompt. If you need to restart Apache, run on the "C: \\ Apache2 \\ Bin \\ httpd.exe -k -k -ktart" command line.

Installing and configuring the Apache web server is complete.

Creating batch files to start and stop service

Agree that manually edit the "hosts" file each time the services starts, it is not convenient, so for a more convenient, simultaneous startup of Apache, MySQL services, and change the HOSTS file, we will create two batch files: on starting and stopping that will perform All routine work automatically.

When using virtual hosts, you must create two files in the C: \\ Apache directory: vhosts-off.txt - containing the initial contents of the HOSTS file and vhosts-on.txt - containing all virtual hosts. Please note that when creating new virtual hosts, you will need to add them to the vhosts-on.txt file, and not in C: \\ Windows \\ System32 \\ Drivers \\ ETC \\ HOSTS. Look at the examples below.

The VHOSTS-OFF.TXT file (may contain one single line):
127.0.0.1 Localhost.

Example of the vhosts-on.txt file with virtual hosts www.test.ru and test.ru:

127.0.0.1 Localhost.
127.0.0.1 www.test.ru.
127.0.0.1 Test.ru.

In the same directory C: \\ Apache, create two batch files: start-webserver.bat - to start the services and submenus "hosts" file, and Stop-WebServer.bat - to stop the services and cleaning the HOSTS file.

Start-WebServer.Bat startup file:

@echo off echo. If Not Exist C: \\ Apache \\ Vhosts-On.txt Goto No_vhosts Echo Create Virtual Hosts: Copy / V / Y C: \\ Apache \\ VHOSTS-On.txt C: \\ Windows \\ System32 \\ Drivers \\ etc \\ hosts echo. : NO_VHOSTS NET START Apache2.2 Net Start MySQL

Stop-WebServer.bat stop file:

@echo off echo. If Not Exist C: \\ Apache \\ vhosts-off.txt Goto No_vhosts Echo Restore Hosts File: Copy / V / Y C: \\ Apache \\ VHOSTS-OFF.TXT C: \\ Windows \\ System32 \\ Drivers \\ etc \\ hosts echo. : NO_VHOSTS NET STOP Apache2.2 Net Stop MySQL

If you do not use virtual hosts or want to start the services without changing the HOSTS file, simply remove from the C: \\ Apache directory vhosts-on.txt and vhosts-off.txt files.

Simultaneously with the services, it is convenient to start the Apache Monitor program that displays the Apache server in the system tray, for which you can create another Batch file "START-WebServer-monitor.bat", the content of which is similar to the START-WebServer.bat file with the addition of End of the next line:

start "" "C: \\ Apache2 \\ Bin \\ ApacheMonitor.exe»

Now, to start the entire toolkit, you will need to run the "start-webserver-monitor.bat" file, or "start-webserver.bat", and to stop "Stop-Webserver.bat". If you wish, you can rename these files, move them to any other place from the "C: \\ Apache" folder, or create a label files for these to the desktop.

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

This article - step-by-step instruction By creating a local Web server. It describes the APACHE 2.4 Web Server on the Windows platform. Testing the installation was performed on Windows XP SP3.

The composition of the Web server:

  • Apache 2.4 (version 2.4.10);
  • PHP 5.4 (version 5.4.34);
  • MYSQL 5.5 (version 5.5.23).

This work environment will suit:

  • experienced webmasters for testing their projects;
  • beginner webmasters to create their first sites.

Distributions Apache 2.4 and PHP 5.4 are compiled in VC9 (Visual Studio 2008).

Version Apache 2.4 VC9 works, practically, with all relevant versions Windows (7/8 / Vista / XP SP3).

To work VC9 applications, first of all, you need to update the Visual C ++ libraries.

Installing your Visual C ++ library package

Download the VCREDIST_X86.EXE update distribution from the Microsoft website, run the file and perform an update.

Installing and setup APACHE 2.4 server

In the Apache distribution, there is no installation file. Therefore, the installation will be performed manually.

Create a folder and unpack the archive httpd-2.4.10-win32-vc9.zip.

In the HTTPD configuration file. Conf The default routes C: \\ Apache24 are installed. Therefore, edits in the configuration file will be much smaller if you unpack the archive into this folder.

We unpack the distribution in the C: \\ TestServer folder.

We introduce edits to the configuration file C: \\ TestServer \\ Apache24 \\ CONF \\ HTTPD. conf. When writing paths instead of the "\\" symbol (reverse deficiency), use the "/" symbol (direct oblique line). So ways are prescribed in Linux and UNIX operating systems. But initial Apache was designed for these operating systems.

Perform a group replacement of text C: / Apache24 on C: / TestServer / Apache24.

Install the value of the ServerName parameter.
ServerName Localhost: 80

Install the value of the Serveradmin parameter (Email Administrator).
Serveradmin. [Email Protected]

Install the value of the Documentroot parameter (location of the site documents).
Documentroot C: / TestServer / Apache24 / Htdocs

You may want to store the site documents separately from the server. For example, in the C: \\ MySites folder. Then this parameter can be changed.
Documentroot C: / MySites

APACHE executable files are located in the C: \\ TestServer \\ Apache24 \\ Bin folder. Add this value to the Path Windows environment variable.
Path \u003d C: \\ TestServer \\ Apache24 \\ Bin ;

Install Apache as a service.
httpd.exe -k install

If turned on windows Firewall, when installing the service, a message about blocking the program from external connections. To work the service, you must give permission to unlock.

Run the Apache server.
httpd.exe -k start

Check the server performance. In the browser command prompt, you collect the address: http: // localhost. If the Apache setting has passed successfully - the text of the IT Works text will appear on the screen! . Otherwise, we will see a blank screen.

If the server is not started, you should check whether the port 80 is busy, which uses Apache by default.

This is done with the team
netstat -anb.

Most often, this port is used by Skype or Firefox. In this case, you should either release the port or translate Apache to port 8080.

To do this, in the httpd file. CONF Change the values \u200b\u200bof the ServerName and Listen parameters. ServerName Localhost: 8080
Listen 8080.

After that restart the service team
httpd.exe -k re start

and again trying to go to http: // localhost

For convenience, the Apache server can be installed in the startup menu. Windows Labelindicating on C: \\ TestServer \\ Apache24 \\ Bin \\ Apachemonitor.exe

Installing PHP 5.4.

We go to the developer site http://windows.php.net/download/. We find the PHP 5.4 distribution in the VC9 X86 Thread Safe section and load the php-5.4.34-win32-vc9-x86.zip archive.

Create a folder on local computerlet it be C: \\ TestServer \\ PHP54, and unpack the archive.

Return to the site with the Apache distribution. In the Additional + VC9 section, we find the archive php5apache2_4.dll-php-5.4-win32.zip with Apache PHP modules and download it.

In the archive we find the folder with the latest version of the php5apache2_4.dll module and put it in the C: \\ TestServer \\ PHP54 folder.

In the HTTPD configuration file. CONF add strings:

LoadModule PHP 5_ Module "C: / TestServer / PHP 54 / PHP 5 Apache 2_4. DLL "
AddHandler Application / X - HTTPD - PHP. php.
# Configure The Path to Php. INI.
PHPINIDIR "C: / TESTSERVER / PHP 54 / PHP"

In folder C: \\ TestServer \\ Apache54 \\ Htdocs Create a Test.php file.

echo "Hello Apache!";
?>

Restart Apache.

In the browser address bar, we gain http: //localhost/test.php. If the text of Hello Apache will appear on the screen! The PHP installation was completed successfully.

Setting up php.ini

To work with the MYSQL database, we need to configure PHP. INI - PHP configuration file.

In the C: \\ TestServer \\ PHP54 folder are two templates: development and php.ini-product.

Rename the PHP.INI-PRODUCTION C template.

Libraries to work with the MYSQL database are located in the C: \\ TestServer \\ PHP 54 \\ EXT folder. This path must be registered in the EXTENSION_DIR directive PHP.ini configuration file.

We find this parameter, delete the comment symbol at the beginning of the line (this is a semicolon) and prescribe the path.
eXTENSION_DIR \u003d "C: / TestServer / PHP 54 / EXT"

To work with the MYSQL database, there are two libraries in PHP: php _ mysqli. DLL - newer and it is recommended that it is recommended to use; php _ mysql. DLL - old, but it is used on most sites.

The php.ini file is better to register both libraries.
eXTENSION \u003d PHP _ MYSQL. DLL
eXTENSION \u003d PHP _ MYSQLI. DLL

After the edit is complete, I will definitely restart the Apache server.

Installing and configuring MySQL

We go to the page http://www.mysql.ru/download/. Select the version for Win32 or Win64. We will upload the MYSQL-5.5.23-Win32.msi installation package.

Run the MySQL-5.5.23-win32.msi file.

Agree on licensed conditions, Select the type of TYPICAL installation.

Go to the configuration of MySQL server.

Select Detailed Configuration - detailed configuration setting.

Select the server type with minimal memory requirements - Developer Machine.

Now you need to decide with what databases (Innodb, Myisam) our server will work.

Multifunctional Database - Innodb and Myisam are supported.
Transactional Database Only - InnoDB is supported.
NON-TRANSALIENDAL DATABASE ONLY - MYISAM is supported.

When you select InnoDB, the next step is to choose the InnOdb table storage location.

Maximum number simultaneous connections It is better to choose MANUAL SETTING (manual installation) and agree with the default value (15).

At this step, the ENABLE TCP / IP Networking parameter includes support for TCP connections, the port is selected by which these connections will be performed. The ENABLE STRICT MODE parameter is also installed - strict compliance mode with the MYSQL standard.

Now you need to select the default encoding. The best way - UTF-8 encoding. Therefore, choose Best Support for Multilingualism.

In order for MySQL to be launched as windows service - Install Install AS Windows Service. If you need the autorun of this service - install Launch the MySQL Server Automatically.

Now install the administrator password and turn off the Modify Security Settings option.

After pressing the Next and Execute buttons, the MYSQL installation can be finished.

To check the performance of MySQL, press the Windows Start button, we find the work utility with MySQL Server Command Line and launch it.

After entering the administrator password, we fall into MySQL command prompt.

We enter the command
show databases;

If we see a database list - this will mean that the server works correctly.

We leave from the command line mode:
exit;

This is completed on this server. Good job!

Installing a web server on Linux:

  • If you have Ubuntu, then you will find an article "How to install the Apache web server with PHP 7, MariaDB / MySQL and PHPMYAdmin (LAMP) on Ubuntu 16.10".
  • If you have Arch Linux, then you will find the article "Installing Lamp (Linux, Apache, MySQL / MariaDB, PHP7 and PHPMYAdmin) in Arch Linux / Blackarch".

Local server highly useful tool. It is precisely useful to webmasters, programmers on PHP, penetration testers. All programs included in the typical web server installation are free, they have all the source code. The local web server consumes the minimum of resources and, in fact, it is absolutely easy to install and configure.

This instruction will tell you how to install a local web server without using ready-made assemblies. This method has its advantages. The most important of them are: full control on what you install; Ability to use the very following latest versions software.

If you exactly follow the instructions, you will definitely earn everything! In addition to those who have Windows XP - if you have this operating systemYou have a special instruction for you.

I will show an example of installing on Windows 10, but if you have another version of Windows, then let it confuse you - the procedure is identical everywhere. I will download the latter (the latest) at the time of writing the version of programs. If by the time you read, new versions will come out, then download them.

Installation steps:

You can also come in handy:

1. Preparation (download programs included in the server, creating a server structure)

We need:

  • Apache. (directly web server)
  • Php. - Wednesday PHP programs (Required almost all websites)
  • Mysql - database management system (required by most websites)
  • phpmyAdmin. - highly comfortable tool To manage databases

Apache developer official website is httpd.apache.org. You can download Apache from this site. But the official version is going to use the old compiler, for this reason it does not work with new pHP versions. The authors of PHP recommend Apache from ApacheLounge.com/downLoad. Therefore, for this instruction, you download Apache from the site apachelounge.com/download.

If you have a 64-bit version of Windows, you can choose both a 64-bit and 32-bit version of the components. The main rule - all components must be one of the triumbe. If you have a 32-bit version of Windows, then all components must be 32-bit. This does not apply to phpmyadmin, which is written on pHP Language. For PHP programs, the concept of biost is not applicable.

The free version of MySQL is called MySQL Community Server.. It can be downloaded on the page. On the same page there is an installer in the form of an executable file, but I recommend downloading a zip archive. On the download page, we are offered to register or enter the existing account - But this is not necessary. Just click on the link " No Thanks, Just Start My Download" Pay attention to the bitency.

We also need a C ++ Redistributable Visual Studio 2017 file, i.e. Spreadable component Visual C ++ for Visual Studio 2017 (or any other later), you can download it on the official Microsoft website on the link (direct link to download the 64-bit version; direct link to download 32-bit version). This file is needed for a web server. And for MySQL, you need distributed Visual C ++ packages for Visual Studio 2015. It can be downloaded by software.

So, I downloaded the following files:

  • httpd-2.4.29-win64-vc15.zip.
  • php-7.2.0-win32-vc15-x64.zip.
  • mysql-8.0.11-winx64.zip.
  • phpmyAdmin-4.7.6-All-Languages.zip.
  • vc_redist.x64.exe.
  • vcredist_x64.exe.

Set files vc_redist.x64.exe. and vcredist_x64.exe..

2. Creating a web server structure

Create the structure of the directories of our server. The main idea is to divide the executable files and files of sites with databases. It is convenient for servicing the server, including backup.

At the root of the disk C: \\ Create a catalog Server. In this directory, create 2 subdirectory: bin. (for executable files) and data..

Go to the catalog data. and there create subfolders DB (for databases) and htdocs. (for sites).

Go to the catalog C: \\ Server \\ Data \\ DB \\ and create an empty folder there data..

3. Installation Apache 2.4

The contents of the downloaded archive (more precisely speaking, only the catalog Apache24.), unpack in .

Go to the catalog c: \\ Server \\ Bin \\ Apache24 \\ CONF \\ and open the file httpd.conf. Any text editor.

In it, we need to replace a row row.

Define Srvroot "C: / Apache24"

Define Srvroot "C: / Server / Bin / Apache24"

#ServerName www.example.com:80

ServerName Localhost.

Documentroot "$ (srvroot) / htdocs"

Documentroot "C: / Server / Data / Htdocs /"

DirectoryIndex index.html.

DirectoryIndex index.php index.html index.htm

# ALLOWOVERRIDE CONTROLS WHAT DIRECTS MAY BE PLACED IN.HTACCESS FILES. # IT CAN BE "ALL", "NONE", OR ANY COMBINATION OF THE KEYWORDS: # ALLOWOINRIDE FILEINFO AUTHCONFIG LIMIT # ALLOWOVERRIDE NONE

# ALLOWOVERRIDE CONTROLS WHAT DIRECTS MAY BE PLACED IN.HTAccess Files. # It can be "all", "none", or any combination of the keywords: # allowOverride FileInfo Authconfig Limit # AllowOverride All

#LoadModule Rewrite_Module Modules / mod_rewrite.so

LoadModule Rewrite_Module Modules / mod_rewrite.so

Save and close the file. Everything, Apache setting completed! Description of each modified directive you will find on this page.

Open the command line (this can be done by pressing the Win + X key simultaneously). Choose there Windows PowerShell (Administrator) and copy there:

C: \\ Server \\ Bin \\ Apache24 \\ Bin \\ httpd.exe -k Install

If you receive a request from the firewall to the Apache ratio, then click Allow.

Now enter into the command line:

C: \\ Server \\ Bin \\ Apache24 \\ Bin \\ httpd.exe -k start

And press ENTER.

As a username, we enter root. Password field leave empty. If everything is done correctly, then everything should look like this:

7. Using a server and data backup

In catalog C: \\ Server \\ Data \\ Htdocs \\ Create folders and files, for example:

c: \\ Server \\ Data \\ Htdocs \\ Test \\ Ajax.php - This file, respectively, will be available at http: //localhost/test/ajax.php, etc.

To create a full backup of all sites and databases, it is enough to copy the directory C: \\ Server \\ Data \\.

Before updating modules, make backup folder bin. - In case of problems, it will be possible to easily roll back to the previous versions.

When re-installing the server or when it is updated, you need to re-configure configuration files. If you have copies of these files, the process can be significantly accelerated. It is advisable to take the following files:

  • c: \\ Server \\ Bin \\ Apache24 \\ CONF \\ httpd.conf
  • c: \\ Server \\ Bin \\ MySQL-8.0 \\ My.ini
  • c: \\ Server \\ Bin \\ PHP \\ php.ini
  • c: \\ Server \\ Data \\ Htdocs \\ phpMyAdmin \\ config.inc.php

All settings are stored in them.

8. Additional PHP setup

PHP is currently very powerful, flexible, convenient tool. On the local computer using it you can solve a variety of tasks, not necessarily related to the generation of Web pages. When solving extraordinary tasks, you can rest in the limit set in the settings. These settings are contained in the php.ini file (C: \\ Server \\ Bin \\ PHP \\ php.ini) Consider some of them:

Memory_Limit \u003d 128m.

sets the maximum amount of memory that the script can use

Post_max_size \u003d 8m

sets the maximum amount of data that will be accepted when sending by the POST method

; Default_charset \u003d "UTF-8"

sets the encoding (default, the string is commented)

Upload_max_FileSize \u003d 2m.

the maximum size of the file being downloaded to the server. Initially, very small size is installed - only two megabytes. For example, when loading a database in PHPMYAdmin, it will not be possible to upload a file more than 2 megabytes until this setting item is changed.

MAX_FILE_UPLOADS \u003d 20.

maximum number of files for download at a time

Max_execution_time \u003d 30.

maximum execution time of one script

It is absolutely optional to change these settings, but it is useful to know about them.

9. Additional PHPMYAdmin Setup

We have already configured phpmyadmin and most quite enough basic functional. However, on start page phpmyadmin is an inscription: "Additional PHPMYAdmin features are not fully configured, some features have been disabled."

New features are:

  • showing connections between (related) tables;
  • adding information about tables (starting with version 2.3.0 You can describe in a special table 'table_info' which column will be shown in the pop-up tip when moving the cursor over the connected key);
  • creating a PDF scheme (starting with version 2.3.0 you can create in phpmyAdmin PDF Pagesshowing links between your tables);
  • display column comments (starting with version 2.3.0 you can make a comment with a description of each column for each table. And they will be visible in " preview for print". Starting with version 2.5.0, comments are used on own pages tables and in viewing mode, showing how pop-ups over columns (properties table) or built into the table title in viewing mode. They can also be shown in the table dump);
  • create bookmarks (starting with version 2.2.0, PHPMYAdmin allows users to bookmarks to requests. It can be useful for frequently used requests);
  • history of SQL queries (starting with version 2.5.0 you can save your story all SQL requestswhich were made via the phpmyAdmin interface);
  • designer (starting from version 2.10.0, a designer tool is available; it allows you to visually manage the connections between the tables);
  • information about newly used tables;
  • setting up frequently used tables;
  • tracking (starting with version 3.3.x The tracking mechanism is available. It helps you to trace each SQL command that has been performed by phpmyAdmin. Supports recording data and recording commands. After switching on, you can make table versions);
  • custom settings (starting with version 3.4.x, PHPMYAdmin allows users to set most of the settings and save them in the database);
  • customizable menus (starting from version 4.1.0 You can create user groups to which only assigned menu items will be available. The user can be defined in the group and will only see the menu items available for its group);
  • hide / show navigation items (starting from version 4.1.0 you can hide / show items in the navigation tree).
  • other

Now we will configure these additional features fully. Follow the http: //localhost/phpmyadmin/chk_rel.php and click "Create a Database". After that, all new features will be activated.

Several screenshots of new features:

1) designer

2) Tracking

10. Installing the postal stub

In the C: \\ Server \\ Bin \\ bin directory, create a new directory called Sendmail. Now create a SendMail.php file in this directory with the following contents:

#! / USR / BIN / ENV PHP

Open the PHP configuration file, it is placed here. C: \\ Server \\ Bin \\ PHP \\ php.ini. And add one line there:

Sendmail_path \u003d "C: \\ Server \\ Bin \\ PHP \\ php.exe C: \\ Server \\ Bin \\ Sendmail \\ Sendmail.php --dir C: \\ Server \\ Bin \\ Sendmail \\ Emails"

Save the file and restart the server. Excellent, now all sent letters will be saved in the catalog C: \\ Server \\ Bin \\ Sendmail \\ Emails \\

Letters will have expansion .EML and they can be opened, for example, the program Thunderbird.. Or by the usual text editor.

11. Adding PHP directory in Path on Windows

If this is not done, there may be problems with some PHP modules, including with php_curl.dll, php_intl.dll, php_ldap.dll, php_pdo_pgsql.dll and php_pgsql.dll. At least, when you start the server, the following appears in the logs.

PHP Warning: PHP Startup: Unable to Load Dynamic Library "C: \\\\ Server \\\\ Bin \\\\ PHP \\\\ Ext \\\\ php_curl.dll" - \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xef \\ xbf \\ xef \\ xbf \\ xef \\ xef \\ "- \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xBD \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd. \\ R \\ N in unknown on line 0 PHP Warning: PHP Startup: Unable to Load Dynamic Library " C: \\\\ Server \\\\ Bin \\\\ PHP \\\\ Ext \\\\ PHP_LDAP.DLL "- \\ XeF \\ XBF \\ XBD \\ XeF \\ XBF \\ XBD \\ XeF \\ XBF \\ XBD \\ XeF \\ XBF \\ XBD \\ XeF \\ xBF \\ d \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd .dll "- \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd. \\ R \\ n in unknown on line 0 PHP Warning: PHP Startup: Unable to Load Dynamic Library "C: \\\\ server \\\\ bin \\\\ php \\\\ ext \\\\ php_pgsql.dll" - \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xef \\ xbf \\ xbd \\ xef \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd \\ xef \\ xbf \\ xbd. \\ R \\ N in Unknown on Line 0

To avoid these warnings, you need to add the path to PHP to the system variables.

Click the Start button (or how is it called on windows 10?), Start typing " Change system variables"And open the appropriate settings window.

There click " Environment Variables»:

In the window " System variables»Find and click on Path., then click " Change»:

Raise the entry to the upstairs:

Close all windows while saving changes made.

Restart the server.

12. Hanging, Traffic Slow and / or Error ASYNCHRONOUS ACCEPTEX FAILED

If your server, even without loading "hangs" - does not show web pages before restarting, and in the ASYNCHRONOUS ACCEPTEX FAILED error logs:

AH00455: Apache / 2.4.9 (Win64) PHP / 5.5.13 Configured - Resuming Normal Operations AH00456: Apache Lounge VC11 Server Built: Mar 16 2014 12:42:59 AH00094: Command Line: "C: \\\\ Server \\\\ (OS 64) The specified network name is more not available. : AH00341: WINNT_ACCEPT: ASYNCHRONOUS ACCEPTEX FAILED. (OS 64) The specified network name is more not available. : AH00341: WINNT_ACCEPT: ASYNCHRONOUS ACCEPTEX FAILED. (OS 64) The specified network name is more not available. : AH00341: WINNT_ACCEPT: ASYNCHRONOUS ACCEPTEX FAILED. (OS 64) The specified network name is more not available. : AH00341: WINNT_ACCEPT: ASYNCHRONOUS ACCEPTEX FAILED. (OS 64) The specified network name is more not available. : AH00341: WINNT_ACCEPT: ASYNCHRONOUS ACCEPTEX FAILED. (OS 64) The specified network name is more not available. : AH00341: WINNT_ACCEPT: ASYNCHRONOUS ACCEPTEX FAILED.

Then add an Apache configuration file:

AcceptFilter HTTP None AcceptFilter HTTPS NONE ENABLESENDFILE OFF ENABLEMMAP OFF

13. Setting up the CURL in the Apache web server on Windows

If you do not know what CURL is, then you do not need it. Those. Boldly skip this step.

cURL is a console utility that allows you to exchange data with remote servers using a very large number of protocols. CURL can use cookies and supports authentication. If a web application requires CURL, this should be indicated in dependencies. For many popular CURL applications, it is not required, for example, for phpmyAdmin and WordPress there is no need to configure CURL.

If CURL is configured incorrectly, you will receive errors:

Fatal Error: Call to Undefined Function Curl_multi_init () in ...

Curl error: SSL CERTIFICATE PROBLEM: Unable to get Local Issuer Certificate

To CURL worked in Apache on Windows you need:

1) Be sure to add PHP directory in PATH (System Variables Environment). How to do this is told slightly above:

2) in the file C: \\ Server \\ Bin \\ PHP \\ php.ini should be unassamed row eXTENSION \u003d CURL

It is usually not required, but if you wish, you can back up the binary (executable) server files. All these files are in the folder . This is Apache, MySQL and PHP - i.e. Programs that are responsible for the server work, but which we can download from official sites at any time and configure again.

If you want to make their backup (for example, before updating the server), stop your service:

C: \\ Server \\ Bin \\ Apache24 \\ Bin \\ httpd.exe -k Stop Net Stop MySQL

And copy the folder to safe place .

By the way, you can copy the entire server entirely, i.e. folder C: \\ Server \\ - In this case, simultaneously displays a backup copy and executable files, and data (databases, sites).

When copying is completed, start the service again:

C: \\ Server \\ Bin \\ Apache24 \\ Bin \\ httpd.exe -k Start Net Start MySQL

15. Server Update

All components that make up a web server are actively developing and regularly published. When you enter the new version, you can update one of some component (for example, PHP), or several minutes.

Removing Server

If you don't need the server anymoreOr you want to install it again, stop the service and remove them from the autorun sequentially by performing on the command prompt:

C: \\ Server \\ Bin \\ Apache24 \\ Bin \\ httpd.exe -k Stop C: \\ Server \\ Bin \\ Apache24 \\ Bin \\ httpd.exe -k Uninstall Net Stop MySQL C: \\ Server \\ Bin \\ Mysql-8.0 \\ Bin \\ Remove server files, delete the folder

Attention, it will delete all databases and your sites. C: \\ Server \\. How to protect the apache web server from hacking in Windows

With PHP (with version selection), with MySQL and phpMyadmin. This site is posted on it: responsive and qualified technical support, installing WordPress and other web applications in one click,

Previous article