Apache: installing and configuring a web server

What is Apache? E That software open source web server, which powers about 46% of websites worldwide. The official name is Apache HTTP Server, maintained and developed by the Apache Software Foundation.

A web server allows website owners to serve their content on the Internet, as the name “web server” implies. Apache is one of the oldest and most reliable web servers with the first version released more than 20 years ago in 1995.

When someone wants to visit a website, they enter the domain name into the address bar of their browser. The web server then delivers the requested files as a virtual messenger.

At Hostinger, our infrastructure uses Apache in parallel with NGINX, another popular web server. This combination allows us to take full advantage of both. This greatly improves performance by compensating weaknesses one strengths another.

File processing, database processing, mail and web server uses different kinds server software. Each of these applications can access files stored on the real server and use them for different purposes.

The job of a web server is to serve a website on the Internet. To do this, it acts as an intermediary between the server computer and the client computer. It takes content from the server for each user request and delivers it to the network.

The biggest challenge of a web server is to simultaneously serve various requests from many users. The web server processes files written in different programming languages, such as PHP, Python, Java and others.

It turns them into static HTML file and sends them to the user’s browser for service. When you hear the term web server, think of it as a tool for communication between a server and a client.

How does the Apache web server work?

Although Apache is called a web server, in reality it is not a server, but a program that runs on the server. Its task is to establish a connection between the server and the visitors' browser (Firefox, Google Chrome, Safari, etc.) while delivering files back and forth between them (client-server structure). Apache is cross-platform software, which means it works well on both Unix and Windows servers.

When a visitor wants to load a page on your site, e.g. home page or “About Us” page, its browser sends a request to your server and Apache returns a response with all the requested files (text, image, etc.). The server and client communicate using HTTP and Apache is responsible for a smooth and secure connection between the two machines.

Apache is highly customizable because it has a modular structure. Modules allow server administrators to enable or disable additional functionality. Apache has modules for security, caching, URL editing, password authentication, and others. You can set your own configuration via the .htaccess file, which is a settings file for Apache and is supported by all tariff plans Hostinger.

Apache and other web servers

Besides Apache, there are quite a few other web servers. Each web server application was created for a different purpose. Although Apache is the most widely used, there are several alternatives and competitors.

Select the latest version (at the time of writing this article - 2.2.17) and go to the list of distributions. On your home computer you are unlikely to need SSL, so download the version Win32 Binary without crypto (no mod_ssl) (MSI Installer).

Now run the installer (the user must have administrator rights). At the beginning there is nothing interesting - just a welcome screen:

The second stage is to agree to the license terms:

The third stage is a few introductory words from the developers. Immediately click Next:

Fourth stage. Here you need to enter data in all three text fields. You can enter a non-existent domain like test.test or example.com. This data is needed to create a basic configuration file. Under the text fields, one of the most important settings is to install Apache as a service or as a regular program. Select “for All Users, on port 80, as a Service - Recommended” - install as a service:

Type of instalation. Select Custom:

Sixth stage. Selecting components and installation location. I left all the default values:

Seventh stage. Everything is ready for installation. Click Install:

We complete the installation (Finish):

Installation completed. An Apache icon will appear in the tray, with which you can quickly stop/start the service:

We check the functionality. Open the browser and address bar enter http://localhost/. If everything is correct, a page should open that says It works!

In order for the server to be accessible not only on the local computer, but also from outside, you need to open TCP port 80 for entry in the Windows Firewall.

Opening a port in Windows Firewall

Open Start -> Control Panel -> System and Security -> Windows Firewall. In the left column, click on the link “ Extra options" In the window that opens, also in the left column, click on “Rules for incoming connections” and then in the right column “Create a rule...”:

The Create Rule Wizard will open. Select the rule type “For port”:

Protocols and ports. TCP protocol. Below, select the “Specified local ports” option, and enter the port number - 80 - in the text field on the right:

Action. Select “Allow connection”:

Profile. Leave it as default (all three options are checked: domain, private, public):

Finally, enter the name of the created rule. For example Apache Web Server:

That's all. Click Finish. Now you can try connecting from another computer.

I remind you that for connections to the server not only from local network, but also from the Internet, on the router (if you have one) you need to configure forwarding of port 80 (port forwarding or this is often called a virtual server).

PHP installation (manual)

Download the latest version of PHP (5.3.5 at the time of writing) from the site: http://windows.php.net/download/. There are several versions available here:

  1. VC9 x86 Non Thread Safe - for installation on IIS in FastCGI mode.
  2. VC9 x86 Thread Safe - ???
  3. VC6 x86 Non Thread Safe - for installation on Apache in CGI/FastCGI mode.
  4. VC6 x86 Thread Safe- for installation on Apache in module mode - our choice.

Because we started installation in manual mode, download the zip archive.

We unpack the contents of the archive into the installation directory. I selected C:\Program Files\PHP.

Let's go to this directory. In the installation root you will find two files php.ini-development and php.ini-production. These files contain basic settings. The first file is optimized for developers, the second for production systems. The main difference is that the settings for developers allow errors to be displayed on the screen, while for production systems the display of errors is prohibited for security reasons.

So, select the file you need (I chose php.ini-development), open it and save it in the same folder under the name php.ini. This operation can be done in a regular notepad, but it is still better to use a more convenient editor, for example notepad2.

Now you need to make a few changes to php.ini:

  1. Find the extension_dir option (use CTRL+F search) and change the path to the ext folder in accordance with the PHP installation path. For me it looks like this: extension_dir = “c:\program files\php\ext”
  2. Find the upload_tmp_dir option. Here you need to specify the path to the temporary folder. I chose c:\windows\temp. All together: upload_tmp_dir = “c:\windows\temp”
  3. Find the session.save_path option. Here you also need to specify the path to the temporary folder: session.save_path = “c:\windows\temp”
  4. Go to the Dynamic Extensions section. Here you need to uncomment the lines (remove the semicolon at the beginning) corresponding to PHP modules, which you need for work. A basic set of modules might look something like this: ;extension=php_bz2.dll ;extension=php_curl.dll ;extension=php_fileinfo.dll extension=php_gd2.dll ;extension=php_gettext.dll ;extension=php_gmp.dll ;extension=php_intl.dll ; extension=php_imap.dll ;extension=php_interbase.dll ;extension=php_ldap.dll extension=php_mbstring.dll extension=php_exif.dll ; Must be after mbstring as it depends on it extension=php_mysql.dll extension=php_mysqli.dll ;extension=php_oci8.dll ; Use with Oracle 10gR2 Instant Client ;extension=php_oci8_11g.dll ; Use with Oracle 11g Instant Client ;extension=php_openssl.dll ;extension=php_pdo_firebird.dll ;extension=php_pdo_mssql.dll ;extension=php_pdo_mysql.dll ;extension=php_pdo_oci.dll ;extension=php_pdo_odbc.dll ;extension=php_pdo_p gsql.dll ;extension =php_pdo_sqlite.dll ;extension=php_pgsql.dll ;extension=php_phar.dll ;extension=php_pspell.dll ;extension=php_shmop.dll ;extension=php_snmp.dll ;extension=php_soap.dll extension=php_sockets.dll ;extension=php_sqlite. dll extension=php_sqlite3.dll ;extension=php_sybase_ct.dll ;extension=php_tidy.dll ;extension=php_xmlrpc.dll extension=php_xsl.dll extension=php_zip.dll

Now let's move on to Apache settings.

Open the Apache installation folder (by default C:\Program Files\Apache Software Foundation\Apache2.2\). Open the conf folder. Open the httpd.conf file.

Go to the end of the file and add the following lines there:

# Charset AddDefaultCharset windows-1251 # PHP LoadModule php5_module "c:\program files\php\php5apache2_2.dll" PHPIniDir "c:\program files\php" AddType application/x-httpd-php .php

The path to the php folder is the one you chose during the installation process.

In the same file we find the following lines:

DirectoryIndex index.html

Before index.html we add index.php separated by a space. The result is:

DirectoryIndex index.php index.html

For the changes to take effect, restart the Apache service. If the service restarts, this is a good sign. If not, look for errors in the configuration files. Check all paths especially carefully.

To make sure PHP is working, open the Apache installation directory, then open the htdocs folder (this contains the default website files). Create an index.php file in this folder with the following content:

Now open http://localhost/ in your browser. If everything is fine, you will see a page similar to this:

If you see a page that says "It works!", try refreshing the page using CTRL+F5.

Installing MySQL

Moved into a separate article.

Today we will launch the Apache 2.2.2 web server and look at its basic settings.
To begin, let's check how the installation went: Open your browser and enter http://localhost - You will see the welcome page: It Works! So the installation went well for us.

Next, right-click on the pen icon in the taskbar and select “Open Services”. In the service management window that opens, select the line “Apache2.2” and double-click on it, then in the “General” tab select the manual start of the service - “Startup type: Manual”. . This must be done to prevent unnecessary services from loading the system. Considering that a home computer is used not only for web development, but also for many other needs, manually starting and stopping intermittently used services is most appropriate.

In the root of drive C: you need to create the "apache" directory - it will contain your virtual hosts (domains), the global error log file "error.log" (created by the program upon first launch, automatically), the global access file "access.log" (created automatically). In the “apache” directory we create another empty folder - “localhost”, in which, in turn, we create the “www” folder, it is in the latter that our site project in the form of local scripts will be needed. This seemingly strange directory structure is dictated by a similar directory structure in Unix systems, and is intended to simplify its understanding and use in the future.

Editing the httpd.conf file
1. To load the mod_rewrite module, find and uncomment (remove the “#” symbol at the beginning of the line) this line:

LoadModule rewrite_module modules/mod_rewrite.so


2. To load the PHP interpreter, you need to add the following line to the end of the module loading block:

#LoadModule php5_module "C:/php/php5apache2_2.dll"


3. Define the directory containing the configuration PHP file by adding the following line below:

#PHPIniDir "C:/php"


uncomment after installing php

4. Find the line:

DocumentRoot "C:/server/htdocs"

Assign the root directory for site management (you already created it a little earlier):

DocumentRoot "C:/apache"

5. Find this block:


Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all


And replace it with the following:


Options Includes Indexes FollowSymLinks
AllowOverride All
Allow from all

6. Delete or comment out the original directory control block (we won't need it), which without comments looks something like this:


#
# Possible values ​​for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

7. Find the block:


DirectoryIndex index.html

Replace it with:


DirectoryIndex index.html index.htm index.shtml index.php

8. Find the line:

ErrorLog "logs/error.log"


Replace with the following (in this case it will be more convenient to view the global server error file):

ErrorLog "C:/apache/error.log"

9. Find the line:

CustomLog "logs/access.log" common


Change to:

CustomLog "C:/apache/access.log" common

10. For SSI to work (server-side enablement), the following lines located in the block must be found and uncommented:

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

11. Add two lines below, in the same block:

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

12. Finally, find and uncomment the 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 changes and close the "httpd.conf" file

Now open the file "C:\server\conf\extra\httpd-vhosts.conf" and make the following changes in it.

The existing virtual host example blocks need to be removed and only the following inserted:

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 "httpd-vhosts.conf" file

Let's move on - set up manual launch of the Apache2.2 service, for which we go the path: "Start" → "Control Panel" → "Administrative Tools" → "Services" Services"), in the service management window that opens, select the line "Apache2.2" and double-click on it, then in the "General" tab select manual start of the service - "Startup type: Manual" : manually"). This must be done to prevent unnecessary services from loading the system. Considering that a home computer is used not only for web development, but also for many other needs, manually starting and stopping intermittently used services is most appropriate.

Example of creating a virtual host

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

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

# The folder where your host's root will be.
DocumentRoot "C:/apache/dom.ru/www"
# The domain by which you can access the virtual host.
ServerName dom.ru
# Alias ​​( extension name) domain.
ServerAlias ​​www.dom.ru
# The file where errors will be written.
ErrorLog "C:/apache/dom.ru/error.log"
# Host access log file.
CustomLog "C:/apache/dom.ru/access.log" common

Then in the "apache" directory, create a folder "dom.ru", in which, in turn, create a folder "www".
The next step in creating a virtual host is to modify the C:\WINDOWS\system32\drivers\etc\hosts file of the operating system. Open this file and add two lines to it:
127.0.0.1 dom.ru
127.0.0.1 www.dom.ru
Now restart the Apache server, open your browser, enter "dom.ru" or "www.dom.ru" in the address bar and you will find yourself in your virtual host. Just be careful, now you can get to the original site with the virtual host name ("www.dom.ru" if it exists) only by commenting out or deleting the line: "127.0.0.1 www.dom.ru" in the above file " hosts".
Apache documentation, with the server running, is available at http://localhost/manual/
Installation and configuration of the Apache web server is complete.

Here he is - great and terrible. In its lifetime, it has ruined many novice web developers who lost their lives setting up its configuration files. 🙂 But you and I are people with strong nerves and stomachs of steel - so let’s go.

Initial installation and setup

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

Open the file “C:\Apache2\conf\httpd.conf” in a text editor, which is the main configuration file for the Apache server.

Well, now hold on. Women, elderly people and children are asked not to read further. The authors are not responsible for the mental state of people who read the article to the end. 🙂

Editing the httpd.conf file

  1. To load the mod_rewrite module, find and uncomment (remove the “#” symbol at the beginning of the line) this line:
    LoadModule rewrite_module modules/mod_rewrite.so
  2. To load the PHP interpreter, you need to add the line to the end of the module loading block:
    LoadModule php5_module "C:/php/php5apache2_2.dll"
  3. Define the directory containing the PHP configuration file by adding the following line below:
    PHPIniDir "C:/php"
  4. Find and uncomment the line:
    ServerName www.example.com:80
    Edit it as follows, setting the original server name:
    ServerName localhost:80
  5. Find the line:
    DocumentRoot "c:/Apache2/htdocs"
    Assign a root site management directory (we'll create one a little later):
    DocumentRoot "C:/apache"
  6. Find this block:

    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all

    And replace it with the following:

    Options Includes Indexes FollowSymLinks
    AllowOverride All
    Allow from all
  7. Remove or comment out the original directory control block (we won't need it), which without comments looks something like this:

    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  8. Find the block:

    DirectoryIndex index.html

    Replace it with:

    DirectoryIndex index.html index.htm index.shtml index.php
  9. Find the line:
    ErrorLog "logs/error.log"
    Replace with the following (in this case it will be more convenient to view the global server error file):
    ErrorLog "C:/apache/error.log"
  10. Find the line:
    CustomLog "logs/access.log" common
    Change to:
    CustomLog "C:/apache/access.log" common
  11. To operate SSI (server side enablement), the following lines are located in the block , you need to find and uncomment:
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
  12. Add below in the same block , two lines:
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
  13. Finally, find and uncomment the 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.

The existing virtual host example blocks need to be removed and only the following inserted:
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 "httpd-vhosts.conf" file

Setting up the configuration files is complete, now you need to install the Apache2.2 service.

Installing the Apache2.2 service in pictures

Let's launch command line and enter “C:\Apache2\bin\httpd.exe -k install” in it

This is what we should see when the Apache2.2 service is successfully installed.

If everything went well, we move on - set up a manual launch of the Apache2.2 service, for which we follow the path: “Start” → “Control Panel” → “Administrative Tools” → “Services”, in the service management window that opens, select the line “Apache2.2” and double-click on it, then in the “General” tab select manual start of the service - “Startup type: Manual” "(Startup type: manual). This must be done to prevent unnecessary services from loading the system. Considering that a home computer is used not only for web development, but also for many other needs, manually starting and stopping intermittently used services is most appropriate.

Creating a virtual host directory structure

In the root of the disk you need to create the “apache” directory - it will contain your virtual hosts (domains), the global error log file “error.log” (created by the program when you first start it, automatically), the global access file “access.log” (created automatically). In the “apache” directory we create another empty folder - “localhost”, in which, in turn, we create the “www” folder, it is in the latter that we will need to keep our stuff in the form of local scripts. This seemingly strange directory structure is dictated by a similar directory structure in Unix systems, and is intended to simplify its understanding and use in the future.

Example of creating a virtual host

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

Open the file “httpd-vhosts.conf” and create a block in it with approximately the following content:

# The folder where your host's root will be.
DocumentRoot "C:/apache/test.ru/www"
# The domain by which you can access the virtual host.
ServerName test.ru
# Alias ​​(additional name) of the domain.
ServerAlias ​​www.test.ru
# The file where errors will be written.
ErrorLog "C:/apache/test.ru/error.log"
# Host access log file.
CustomLog "C:/apache/test.ru/access.log" common

Then, in the “apache” directory, create the “test.ru” folder (just like that, with a dot), in which, in turn, create the “www” folder.

The next step in creating a virtual host is to modify the C:\WINDOWS\system32\drivers\etc\hosts file of the 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 start the Apache server by executing “C:\Apache2\bin\httpd.exe -k start” on the command line, open the browser, enter “test.ru” or “www.test.ru” in the address bar 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 one exists) only by commenting out or deleting the line: “127.0.0.1 www.test.ru” in the above-mentioned file “ hosts".

Apache documentation, with the server running, is available at http://localhost/manual/

You can stop Apache by running “C:\Apache2\bin\httpd.exe -k stop” on the command line. If you need to restart Apache, run “C:\Apache2\bin\httpd.exe -k restart” at the command line.

Installation and configuration of the Apache web server is completed.

Creating batch files to start and stop services

Agree that manually editing the “hosts” file every time you start services is not convenient, so for a more convenient, simultaneous start of Apache, MySQL services, and changing the “hosts” file, we will create two batch files: for starting and stopping, which will perform all routine work automatically.

When using virtual hosts, you need to 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 to C:\WINDOWS\system32\drivers\etc\hosts. Look at the examples below.

File vhosts-off.txt (can contain one single line):
127.0.0.1 localhost

Example of a 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 services and replace the “hosts” file, and stop-webserver.bat – to stop services and clear the “hosts” file.

Launch file start-webserver.bat:

@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 file stop-webserver.bat:

@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 services without replacing the “hosts” file, simply remove the files vhosts-on.txt and vhosts-off.txt from the C:\apache directory.

Simultaneously with the services, it is convenient to run the Apache Monitor program, which displays the status of the Apache server in the system tray, for which you can create another batch file “start-webserver-monitor.bat”, the contents of which are similar to the file “start-webserver.bat” with the addition of end of next line:

start "" "C:\Apache2\bin\ApacheMonitor.exe"

Now to run the entire toolkit you will need to run the file “start-webserver-monitor.bat”, or “start-webserver.bat”, and to stop it “stop-webserver.bat”. If you wish, you can rename these files, move them to any other location from the “C:\apache” folder, or create shortcuts to these files, for example, to the desktop.

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

Installing a web server on Linux:

  • If you have Ubuntu, then the article “How to install Apache web server with PHP 7, MariaDB/MySQL and phpMyAdmin (LAMP) on Ubuntu 16.10” is suitable for you.
  • If you have Arch Linux, then the article "Installing LAMP (Linux, Apache, MySQL/MariaDB, PHP7 and phpMyAdmin) on Arch Linux / BlackArch" is suitable for you.

Local server is a very useful tool. It will definitely be useful for webmasters, PHP programmers, and penetration testers. All programs included in a typical web server installation are free, they all have source. A local web server consumes minimal resources and is actually not difficult to install and configure.

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

If you follow the instructions exactly, then everything will definitely work for you! Except for those who have Windows XP - if you like this operating system, then special instructions have been made for you.

I will show an example of installation on Windows 10, but if you have a different Windows version, then don’t let this bother you - the procedure is identical everywhere. I will download the latest (most recent) versions of the programs at the time of writing. If by the time you read, new versions will be released, then download them.

Installation steps:

You may also find it useful:

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

We need:

  • Apache(directly web server)
  • PHP- environment for PHP work programs (required by almost all websites)
  • MySQL- database management system (required by most websites)
  • phpMyAdmin- a very convenient tool for database management

The official website of the Apache developers is httpd.apache.org. You can download Apache from this site. But the official version is compiled using an old compiler, for this reason it does not work with new ones PHP versions. PHP authors recommend Apache from apachelounge.com/download. Therefore, for this instruction, we download Apache from the site apachelounge.com/download.

If you have a 64-bit version of Windows, then you can choose both 64-bit and 32-bit versions of components. The main rule is that all components must be of the same bit size. 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 in PHP. For PHP programs, the concept of bit depth is not applicable.

The free version of MySQL is called MySQL Community Server. It can be downloaded on the page. There is an executable installer on this same page, but I recommend downloading the ZIP archive. On the download page we are asked to register or log in to an existing one. account- but this is not necessary. Just click on the link " No thanks, just start my download" Pay attention to the bit depth.

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

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

Install files vc_redist.x64.exe And vcredist_x64.exe.

2. Create a web server structure

Let's create the directory structure of our server. The main idea is to separate executable files and website files with databases. This is convenient for server maintenance, including backups.

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

Go to the directory data and create subfolders there D.B.(for databases) and htdocs(for websites).

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

3. Installing Apache 2.4

The contents of the downloaded archive (more precisely, only the directory Apache24), unpack into C:\Server\bin\.

Go to the directory c:\Server\bin\Apache24\conf\ and open the file httpd.conf any text editor.

In it we need to replace a number of lines.

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 directives may be placed in .htaccess files.

# It can be "All", "None", or any combination of the keywords: # AllowOverride FileInfo AuthConfig Limit # AllowOverride None

# AllowOverride controls what directives 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. That's it, Apache setup is complete! A description of each changed directive can be found on this page. Open the command line (this can be done by pressing the Win+X keys simultaneously). Select there

Windows PowerShell

(administrator) and copy there:

C:\Server\bin\Apache24\bin\httpd.exe -k install

If a request is received from the firewall for Apache, click Allow.

Now enter into the command line:

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

And press Enter.

Enter root as the username. Leave the password field blank. If everything is done correctly, then everything should look like this: 7. Server use and data backup In the catalog

c:\Server\data\htdocs\

create folders and files, for example: c:\Server\data\htdocs\test\ajax.php - this file, accordingly, will be available at http://localhost/test/ajax.php, etc..

To create a complete backup of all sites and databases, just copy the directory bin C:\Server\data\

When reinstalling the server or updating it, you need to re-configure the configuration files. If you have copies of these files, the process can be significantly speeded up. It is advisable to backup 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 now a very powerful, flexible, user-friendly tool. On a local computer, you can use it to solve a variety of tasks that are not necessarily related to generating Web pages. When solving extraordinary problems, you may run into restrictions set in the settings. These settings are contained in the php.ini file (c:\Server\bin\PHP\php.ini). Let's look at some of them:

Memory_limit = 128M

sets the maximum amount of memory that a script can use

Post_max_size = 8M

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

;default_charset = "UTF-8"

sets the encoding (by default, the line is commented out)

Upload_max_filesize = 2M

the maximum size of a file uploaded to the server. The size is initially set to a very small size - only two megabytes. For example, when loading a database into phpMyAdmin, you will not be able to upload a file larger than 2 megabytes until this setting item is changed.

Max_file_uploads = 20

maximum number of files to upload at one time

Max_execution_time = 30

maximum execution time for one script

Changing these settings is completely optional, but it is useful to know about them.

9. Additional settings for phpMyAdmin

We have already configured phpMyAdmin and for most people the basic functionality is enough. However, on the phpMyAdmin start page there is a message: “Additional features of phpMyAdmin are not fully configured, some functions have been disabled.”

New features are:

  • showing relationships between (related) tables;
  • adding information about tables (starting from version 2.3.0 you can describe in a special table ‘table_info’ which column will be shown in the tooltip when moving the cursor over the associated key);
  • creating a PDF diagram (starting from version 2.3.0 you can create PDF pages, showing the relationships between your tables);
  • display column comments (since version 2.3.0 you can make a comment describing each column for each table. And they will be visible in " preview for print". Since version 2.5.0, comments are used on native table pages and in view mode, appearing as tooltips above columns (property tables) or embedded in the table header in view mode. They can also be shown in the table dump);
  • create bookmarks (since version 2.2.0, phpMyAdmin allows users to bookmark queries. This can be useful for frequently used queries);
  • history of SQL queries (starting from version 2.5.0 you can save your history of all SQL queries that were made through the phpMyAdmin interface);
  • designer (starting from version 2.10.0, the Designer tool is available; it allows you to visually manage relationships between tables);
  • information about recently used tables;
  • customizing the interface of frequently used tables;
  • tracking (starting from version 3.3.x, a tracking mechanism is available. It helps you track every SQL command, which was executed by phpMyAdmin. Recording of work with data and recording of commands is supported. Once enabled, you will be able to make versions of tables);
  • user settings (starting from version 3.4.x, phpMyAdmin allows users to set most settings and save them in the database);
  • custom menus (starting from version 4.1.0 you can create user groups that will only have access to assigned menu items. A user can be assigned to a group and will only see menu items available to their group);
  • hide/show navigation items (starting from version 4.1.0 you can hide/show items in the navigation tree).
  • and others

Now we will configure these additional features fully. Go to the link http://localhost/phpmyadmin/chk_rel.php and click "Create database". After this, all new features will be activated.

A few screenshots of the new features:

1) Designer

2) Tracking

10. Installation of a mail plug

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

#!/usr/bin/env php

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

Sendmail_path = "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. Great, now all sent emails will be saved in the directory C:\Server\bin\Sendmail\emails\

Letters will have the extension .eml and they can be opened, for example, by the program Thunderbird. Or a regular text editor.

11. Adding a PHP directory to PATH on Windows

If this is not done, there may be problems with some PHP modules, including php_curl.dll, php_intl.dll, php_ldap.dll, php_pdo_pgsql.dll and php_pgsql.dll. At least, every time the server starts, 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\ 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_intl.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\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\ 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_pdo_pgsql.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\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\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

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

Click the Start button (or whatever it's called on Windows 10?), start typing " Changing system environment variables» and open the corresponding settings window.

There click " Environment Variables»:

In the window " System Variables» find and click on Path, then click " Change»:

Move the entry to the top:

Close all windows and save your changes.

Restart the server.

12. Freeze, slow traffic and/or server error Asynchronous AcceptEx failed

If your server “freezes” even without load - it does not show web pages until restarted, and in the server logs there are errors Asynchronous AcceptEx failed:

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\\ bin\\Apache24\\bin\\httpd.exe -d C:/Server/bin/Apache24" AH00418: Parent: Created child process 4952 AH00354: Child: Starting 64 worker threads.

(OS 64)The specified network name is no longer available. : AH00341: winnt_accept: Asynchronous AcceptEx failed.

(OS 64)The specified network name is no longer available. : AH00341: winnt_accept: Asynchronous AcceptEx failed.

(OS 64)The specified network name is no longer available. : AH00341: winnt_accept: Asynchronous AcceptEx failed.

(OS 64)The specified network name is no longer available. : AH00341: winnt_accept: Asynchronous AcceptEx failed.

(OS 64)The specified network name is no longer available. : AH00341: winnt_accept: Asynchronous AcceptEx failed.

(OS 64)The specified network name is no longer available. : AH00341: winnt_accept: Asynchronous AcceptEx failed.

Then add to the Apache configuration file:

AcceptFilter http none AcceptFilter https none EnableSendfile off EnableMMAP off

13. Configuring cURL in the Apache web server on Windows

1) Be sure to add the PHP directory to PATH (system environment variables). How to do this is explained just above:

2) In a file C:\Server\bin\PHP\php.ini line should be uncommented extension=curl

This is usually not required, but you can make a backup copy of the server binary (executable) files if you wish. All these files are located in the folder C:\Server\bin\. These are Apache, MySQL and PHP - i.e. programs that are responsible for the operation of the server, but which we can download from official websites and configure again at any time.

If you want to make a backup copy of them (for example, before upgrading the server), then stop the services:

C:\Server\bin\Apache24\bin\httpd.exe -k stop net stop mysql

And copy the folder to a safe place C:\Server\bin\.

By the way, you can copy the entire server, i.e. folder C:\Server\- in this case, you will simultaneously get a backup copy of both executable files and data (databases, websites).

When the copying is complete, start the services again:

C:\Server\bin\Apache24\bin\httpd.exe -k start net start mysql

15. Server update

All components that make up the web server are actively being developed and new versions are regularly released. When a new version is released, you can update one component (for example, PHP), or several at once.

Deleting a server

If you no longer need the server, or you want to install it again, stop the services and remove them from autostart by sequentially executing on the command line:

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\ mysqld --remove

Delete the server files; to do this, delete the folder C:\Server\. Warning, this will delete all databases and your sites.

How to protect your Apache web server from hacking on Windows

With PHP (with choice of versions), with MySQL and phpMyAdmin. This site is hosted exactly on it: responsive and qualified technical support, installation of WordPress and other web applications in one click,



2024 wisemotors.ru. How it works. Iron. Mining. Cryptocurrency.