How to set up smartphones and PCs. Informational portal

Apache setup setup. Additional phpMyAdmin setup

The Apache web server is a service that runs in the background and does not have a GUI. This service is installed and started on the command line.

If you only need a web server without additional modules, then you can limit yourself to the basic setup.

Setting up Apache on Windows

In fact, the basic configuration of the web server is extremely simple - you only need to correctly specify the path to the folder in which the websites are placed - this will be enough to start the web server.

By the way, the default values ​​of many parameters are already written in the configuration file. For example, the default root directory is c:/Apache24. So if the folder Apache24 from you unzip to the root of the drive C, then you can start the web server without any configuration with the following command:

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

And at http://localhost you will see the standard web server page, which says that it is running:

By the way, to open a command prompt in Windows, use the keyboard shortcut win+x and in the window that opens, select Windows PowerShell (Administrator).

The web server is configured by editing a text file located in the folder Apache24\conf\ and called httpd.conf.

This file consists of directives with specific meanings. These directives govern the behavior of the web server. But there are more than directives in this comment file - they start with a pound sign ( # ) - comments are for the person who sets up the web server. The server itself lines starting with # just ignores. Those. you can just delete them.

This file does not contain all possible directives - many of them are missing here, because they are not required for most tasks. Even in this note, we will not consider all the settings available in the file - if the description of something is missing, then you simply do not need to touch it.

As already mentioned, it is important to set the path to the folder with websites. If it is installed incorrectly (for example, it is missing on the computer), then the web server will not start.

I think you have already noticed that the web server is different from other programs for Windows. If you are familiar with Linux or other similar operating systems, you should be familiar with working in the console and editing text files. Paths to files are also not written quite normally for Windows. Now the main thing is to understand two rules:

  • use absolute paths to the file (which start with a drive letter, then all subfolders follow), rather than relative ones - the server has its own rules for interpreting relative paths, so you may not understand each other;
  • always use forward slashes, not backslashes (ie, "c:/apache" instead of "c:\apache").

So open the file Apache24\conf\httpd.conf any text editor (though Notepad) and now we are ready to set up a web server.

Directive comes first ServerRoot is the top directory of the tree where the server configuration and log files are stored. Do not add a slash to the end of the folder path.

The default value is set by two directives:

Define SRVROOT "c:/Apache24" ServerRoot "$(SRVROOT)"

The first directive assigns a value to a variable SRVROOT, which by default "c:/Apache24". The second directive assigns a value to a variable $(SRVROOT) at the construction site ServerRoot.

ServerRoot- this is the folder where all the web server files are located - change the value to where you unpacked the web server files. This can be done using a two-variable construct:

Define SRVROOT "c:/Server/bin/Apache24" ServerRoot "$(SRVROOT)"

Or, if you don't plan to use the $(SRVROOT) variable again (and it will be used by default below!), then you can shorten the two-line entry to one line:

ServerRoot "c:/Server/bin/Apache24"

Directive Listen allows you to bind Apache to a specific IP address and/or port. Default value:

Listen 80

It means to listen on port 80 on any IP address (ie any network interface) available on your system. You can specify a specific IP address to listen on and therefore respond to requests from:

Listen 12.34.56.78:80

You can specify multiple ports:

Listen 80 Listen 8000

Or multiple IPs and ports:

Listen 192.170.2.1:80 Listen 192.170.2.5:8000

You can use any combination, the main rule is that the port on the specified interface (IP) must not be occupied by another program.

The default value is fine for a local web server - ie. here you can just not change anything.

In fact, everything you really need is already included - and for most websites to work, nothing needs to be changed - especially on a local web server. But there is one exception - the module mod_rewrite disabled by default. This is a very popular module, for example, all CNC (human readable page addresses) are made with it. You can turn it on, just find the line:

#LoadModule rewrite_module modules/mod_rewrite.so

and uncomment it, i.e. replaced by:

LoadModule rewrite_module modules/mod_rewrite.so

Directive ServerAdmin contains the administrator's e-mail, this e-mail address is written on some pages of the web server, which are automatically generated in case of errors. It is assumed that the administrator can be contacted at this address.

Directive ServerName- this is how the server identifies (names) itself. For a local web server, change the line

#ServerName www.example.com:80

servername localhost

Design

AllowOverride none Require all denied

denies access to the web server's file system (unless explicitly allowed) and denies the use of files .htaccess(until it is explicitly allowed).

DocumentRoot "$(SRVROOT)/htdocs"

DocumentRoot is the directory where websites are located by default. By default, this is where all requests that come to the web server are searched. Specify here the path to the root folder in the web documents. You don't need to write the trailing slash.

Design we have already met. But here a specific folder is indicated for which settings are made. These settings override the general settings that were specified earlier.

Paths to folders DocumentRoot And Directory don't forget to change yours!

Please note that the variable is again used to set the settings. $(SRVROOT), whose value was assigned at the very beginning. If you use the syntax with $(SRVROOT), then the document root folder must be located in the server root folder. I set up the server in a different way - my executable files are separated from the site files, so instead of a variable, you can simply write the paths to the desired folder with the sites:

DocumentRoot "c:/Server/data/htdocs/" Options Indexes FollowSymLinks AllowOverride None Require all granted

Directive Options includes various options. The default options are Indexes And FollowSymLinks. First ( Indexes) means to show index files if the request does not contain a filename. Let's say the user opens the address http://localhost/site/, then if there is an index file in this folder (for example, index.html or index.php), then this file will be shown. It is clear that if a request is made for a specific file, for example, http://localhost/site/page.html, then the requested page will be displayed.

The second option ( FollowSymLinks) means to follow symbolic links. It's kind of like shortcuts in Windows. In Linux, using such links, you can collect files located in different folders of the file system in one site. In fact, for novice server administrators, this is not very necessary.

Directive allowoverride installed on None, which means that files cannot be used .htaccess. I allow files on my server .htaccess(required for mod_rewrite, access restrictions), so I replace its value with All, it turns out like this:

AllowOverride All

A directive Require all granted gives visitors access to web documents.

I have already mentioned index files, the list of index files is set by the construction:

DirectoryIndex index.html

There is only one file - index.html. You can add any number of your own. I change:

DirectoryIndex index.html

DirectoryIndex index.php index.html index.htm

Other settings usually do not need to be changed for the local web server.

(you can read about the parametric configuration of Apache 2.4.34 in another article)

Apache installation problem under Windows

The main problem with installing the Apache Web server on Windows is that after the initial installation of the distribution, the entire package (executable programs, configuration files, server log files, and a file area for hosting Web pages) is located in one place. This interferes with the normal operation of the product for the following reasons:

  • Differentiation of access rights. The executable files must remain unchanged, the configuration files must be managed by the Web server administrator, and the Web page file area must be accessed by developers and site administrators. Permissions for the "Program Files" folder are configured on the assumption that it contains executable modules of software packages that do not need to be modified.
  • Cluttering system folders. The "Program Files" folder of the Windows operating system was initially designed to contain only executable files. It may be on a separate volume, the size of which is chosen by the system administrator, assuming its relative persistence. Certainly no one expects that this folder will store user data, image galleries, and the site's file archive.

Therefore, the installation of Apache under Windows should be carried out in two stages:

  1. Initial installation of the software package in the selected folder.
  2. Optimization of the placement of file areas of the web server and the corresponding change in its configuration.

When modifying Apache configuration files, you must always remember that the "forward slash" character must be used as a path separator for files and folders, as in Unix and Linux operating systems, not "backslash" as in Windows.

Initial installation

Installation requires at least Windows XP SP3 (this legacy version requires a Web server built with VC9 or VC10 compiler). Modern builds of Apache do not support the Windows 2000 operating system.

The Apache distribution package for Windows can be downloaded from one of two "official" vendors: Apache Lounge (version 2.4 only, with documentation) or Apache Haus (versions 2.4 and 2.2, without documentation). It is a ZIP archive, which, according to the intention of the distribution kit vendors, needs to be unpacked to the root of the C: drive.

Since we will still be optimizing the placement of the Web server file structure, the initial installation must be performed in the folder that is intended for placing the web server executable modules (exe-, lib-, so-files, and others that are not subject to change). This can be the "Program Files" system folder, or another one chosen by the system administrator.

After the initial installation, you need to move folders with files from the "base" folder to another place on the disk, which "ideologically" do not belong to the web server, but to the web site. For definiteness, we will assume that after unpacking the distribution, all its components are located in the "C:\Program Files\Apache24" folder, and the website will be located in the "D:\www" folder.

File area layout optimization

Immediately after installation, the folder structure of the Apache software package looks like this:

Bin - Web server executable files.
cgi-bin— Web site CGI scripts.
conf- Web server configuration files.
error - HTTP protocol error pages.
htdocs- the file area of ​​the Web site (in other words, the Web site is located here).
icons - Web server icons
include - included header files (h-files), required when building the Web server with the VC compiler.
lib - Web server library files.
logs- logs of the Web server.
manuals - Documentation in HTML format.
modules — additional program modules of the Web server (so-files).

Of the folders listed above, four (cgi-bin, conf, htdocs, and logs) do not belong in the Web server base folder. From you need to copy to the working folder of the Web site: "D:\www". The original folders could be deleted, but they may be needed to restore the initial situation if something goes wrong during the setup of the Web server. On the other hand, if they are left in the same place, then due to incomplete configuration of the Web server, it may happen that these folders are used, and not the ones we want. Therefore, after copying, it is better to simply rename them to cgi-bin.0, conf.0, htdocs.0 and logs.0, respectively.

Adjusting to a new file structure

Now you can reflect the actual file structure of the Web server in the parameters of the configuration file "D:\www\conf\httpd.conf":

  1. ServerRoot"C:/Program Files/Apache24" # path to the base folder of the web server
  2. PidFile"D:/www/logs/httpd.pid" # process ID of the web server
  3. DocumentRoot"D:/www/htdocs" # this is where the website is hosted
  4. <Directory"D:/www/ htdocs"> # web site folder properties

  5. ErrorLog"D:/www/logs/error.log" # web server error log
  6. CustomLog"D:/www/logs/access.log" common # web server activity log
  7. ScriptAlias ​​/cgi-bin/"D:/www/cgi-bin/" # server CGI scripts folder
  8. <Directory"D:/www/ cgi-bin"> # server scripts folder properties

  9. TypesConfig D:/www/conf/mime.types # descriptions of MIME types
  10. Include"D:/www/conf/extra/ httpd-manual.conf" # setting for accompanying documentation

Please note that in step 2 you need to add a line with the PidFile parameter to the configuration file, since this parameter is absent in the reference configuration file. The remaining parameters are already present in the configuration file - you need to find the lines containing them and replace the original folder paths with new ones.

Paragraph 10 assumes that to enable access to HTML documentation via the "http://localhost:8080/manual" link, you need to uncomment the corresponding line with the Include parameter and specify a new path to the included configuration file. However, since the location of the documentation has also changed, you will need to additionally make a change to the file "D:\www\conf\extra\httpd-manual.conf" by analogy with steps 3 and 8:

  1. AliasMatch^/manual(?:/(?:da|de|en|es|fr|ja|ko|pt-br|ru|tr|zh-cn))?(/.*)?$ "C:/Program Files/Apache24/ manual$1"
  2. <Directory"C:/Program Files/Apache24/ manual">

Starting the server and checking the setup

Since we have changed the file structure of the Web server, you need to launch the server executable module with the command (it can be written to a bat or cmd file): "C:\Program Files\Apache24\bin\httpd.exe" -w -f "D: \www\conf\httpd.conf" -d "C:\Program Files\Apache24\."

Apache running in custom application mode (i.e., running with the command line just shown) can be stopped with the +[C] key combination. If there are any difficulties, then you can use the following command: taskkill /f /IM httpd.exe

To install Apache as a service, run the command: "C:\Program Files\Apache24\bin\httpd.exe" -k install-f "D:\www\conf\httpd.conf" -d "C:\Program Files\Apache24\."

Starting and stopping the Apache Web server service is done with the commands: "C:\Program Files\Apache24\bin\httpd.exe" -k start and "C:\Program Files\Apache24\bin\httpd.exe" -k stop respectively.

You can remove Apache from the list of Windows services using the command: "C:\Program Files\Apache24\bin\httpd.exe" -k uninstall

Checking the correct installation and initial configuration of the Web server is performed by entering the URL in the Web browser: "http://localhost:80/". If everything was done correctly, a page with the text "It works!" should open.

If accompanying documentation in HTML format was installed, it should be available at "http://localhost:80/manual/"

Apache logs access to the site in the file "D:\www\conf\access.log". Information about server problems is recorded in the "D:\www\conf\error.log" file. Its analysis can be especially useful when configuring the execution of CGI scripts.

Additional setting

In addition to the settings listed above, you need to check the value of the Listen parameter, which sets the network interface settings (ip address and TCP port number) on which the server will accept client connections. If Apache is being used by a solo Web developer, then the following configuration might be recommended:

Listen 127.0.0.1:8080 # network interface parameters

The TCP port number must not conflict with other software installed on the computer. For example, the standard HTTP port 80 is often occupied by the Skype client. To share the server on a network, you must specify the correct IP address or network name of the computer on which the Web server is installed.

The Apache web server is most often used in conjunction with interpreters for server-side scripting languages ​​such as PHP and Perl. In order for the Web site to use PHP scripts (assuming PHP is installed in the C:\PHP5 folder), you need to add the following lines to the configuration file "D:\www\conf\httpd.conf":

  1. LoadModule php5_module" C:/PHP5/php5apache2_2.dll"
  2. AddType application/x-httpd-php .php
  3. PHPIniDir "C:/PHP5"

It should be noted that in the PHP5 folder there must be a php.ini configuration file created based on the php.ini-development file (if the server is used for developing Web sites) or php.ini-production (this is a real Web server). In order for PHP modules to find all the dynamic libraries they need, the path to the C:\PHP5 folder must be specified in the PATH variable of the Windows environment.

Perl server side CGI scripts must already be running under two conditions:

  1. The Perl interpreter is installed on this computer.
  2. The first line of the script files correctly specifies the path to the Perl interpreter, for example: #!C:/PERL/bin/perl.exe -w

To check, you can enter the URL in the browser: http://localhost:8080/cgi-bin/printenv.pl, having previously corrected the first line of the printenv.pl script in accordance with paragraph 2.

The rest of the nuances of configuring the Apache Web server under Windows are beyond the scope of this article.

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

Apache web server installation

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

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

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

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

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

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

And repeat the installation command.

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

Now let's check the functionality. We open the browser, and in the address bar we write http://localhost/ (you can just localhost). If the installation was successful, you should see a page that says It works!

PHP installation (manual)

Do we need Apache without PHP? Of course not, that's nonsense! Therefore, next we will consider the manual (without using the installer) installation of PHP.

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

Unpack the contents of the archive into the C:\PHP directory (we create the PHP folder ourselves). Next, in the C:\PHP folder, we 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 in the settings: developers are allowed to display errors on the screen, while for production systems, error output is disabled for security reasons.

Let's do a few things before proceeding with the PHP installation. Open Control Panel → Appearance and Personalization → Folder Options → View tab, find the line “Hide extensions for known file types”, and if there is a check mark, uncheck it and click “Apply”.

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

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

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

Save changes and close.

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

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

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

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

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

DirectoryIndex index.html

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

DirectoryIndex index.php index.html

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

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

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

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

Installing MySQL

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

We launch the installer, after a short download we see the following window:

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

The next window prompts us to check if there is a newer version of MySQL, check the Skip... (skip) checkbox and click Next >

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

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

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

After successful installation, click Next >

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

In the first settings window, check the Show Advanced Options checkbox, leave the rest as is and click Next >

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

In the next window, we erase the number 56 in the input field, leave the rest as it is and click Next>

Click Next >

Click Next >

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

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

Installation and basic configuration of phpMyAdmin

Open the download page http://www.phpmyadmin.net/home_page/downloads.php and choose to download the archive ending in *all-languages.7z or *all-languages.zip (at the time of this writing, the latest version was phpMyAdmin 4.1.9 ). Create a phpmyadmin folder in C:\Apache24\htdocs and extract the files of the downloaded archive there.

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

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

Now, in order to configure the connection settings to MySQL, click on the "New Server" button, a new window opens for us, in the "Server Host" column, localhost must be replaced with 127.0.0.1:

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

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

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

Folder preparation

I really don't like having everything lying around anywhere, so first let's create folders where we will have programs and sites.
Let's create a "Server" folder on the "C:\" drive (or wherever it is more convenient for you):
C:\Server\
We will create 2 folders in it:
C:\Server\web - this is the folder in which we will have programs
C:\Server\domains - and our sites will be in this folder
So, in the \web\ folder, we will create 3 folders for apache, php, mysql:
C:\Server\web\apache\
C:\Server\web\php\
C:\Server\web\mysql\
Next, go to the domains folder and create the \localhost\ folder
C:\Server\domains\localhost\
Inside the folder, we will have 2 subfolders: public_html - for site files; logs - for text files that record "who" accessed the site and what errors appeared in the site.
C:\Server\domains\localhost\public_html\
C:\Server\domains\localhost\logs\
This is where the folder structure ends, let's move on to configuring Apache.

Apache setup

To install Apache, we need Apache itself (Cap). Since we have Windows 8.1 x64, we will install Apache x64.
To download follow the link:
www.apachelounge.com/download/win64
and download "httpd-2.4.6-win64.zip". We also need the "Microsoft Visual C++ 2010 Redistributable Package (x64)" for normal operation. To do this, download it from this link:
www.microsoft.com/en-us/download/details.aspx?id=14632
and install.
After downloading our archive with Apache, open it. Having opened the archive, we will see the Apache24 folder, let's go into it. A lot of folders and program files will appear, we unpack everything into the previously prepared folder:
C:\Server\web\apache\
It should turn out like this:
C:\Server\web\apache\bin\
C:\Server\web\apache\cgi-bin\
C:\Server\web\apache\conf\
C:\Server\web\apache\error\
C:\Server\web\apache\htdocs\
C:\Server\web\apache\icons\
C:\Server\web\apache\include\
C:\Server\web\apache\lib\
C:\Server\web\apache\logs\
C:\Server\web\apache\manual\
C:\Server\web\apache\modules\
We do not need folders such as \cgi-bin\, \htdocs\, \icons\ and \manual\ - you can delete them.
Let's go to the folder:
C:\Server\web\apache\conf\
And open the Apache configuration file - "httpd.conf" with any text editor. In this file, each line contains directives for configuring Apache, and lines starting with a # sign (pound sign) contain a comment and an explanation. Let's start setting up:

Apache configuration file

# Apache directive
ServerRoot “C:/Server/web/apache”
# Listen on local IP port (80 by default)
Listen 127.0.0.1:80
# next, we will connect the extension libraries for Apache
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php5_module "C:/Server/web/php/php5apache2_4.dll"
# tell Apache that files with a php extension should be treated as php scripts
AddHandler application/x-httpd-php .php
# specify the location of the php settings file
PHPIniDir “C:/Server/web/php”
# change the server name
ServerName 127.0.0.1:80
# change directory access

Options Includes Indexes FollowSymLinks
AllowOverride All
Allow from all


# directory with our sites
DocumentRoot “C:/Server/domains”
# index files, by priority.

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

# folder for log files
ErrorLog “C:/Server/domains/logs/error.log”
CustomLog “C:/Server/domains/logs/access.log”
# add alias for phpMyAdmin, and fix alias for cgi

Alias ​​/pma "C:/Server/domains/phpMyAdmin"
ScriptAlias ​​/cgi-bin/ “C:/Server/web/apache/cgi-bin/”

# edit path for cgi

AllowOverride None
Options None
Require all granted

# file types


AddType text/html .shtml
AddOutputFilter INCLUDES.shtml
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

# Other configs:



Browser Match "MSIE 10.0;" bad_DNT


RequestHeader unset DNT env=bad_DNT

This completes the httpd.conf setup.
Additional configs have been included in the Apache httpd.conf configuration file:
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
Let's open the file "C:\Server\web\apache\conf\extra\httpd-mpm.conf" and quickly run through it.
# specify where we will store the pid file:

PidFile “C:/Server/web/apache/logs/httpd.pid”

The rest of the parameters are left unchanged. Let's open the file "httpd-autoindex.conf", change only the lines with the path there:
Alias ​​/icons/ "c:/Server/web/apache/icons/"

Options Indexes MultiViews
AllowOverride None
Require all granted

Apache Hosts File

# using domain localhost as an example

DocumentRoot "C:/Server/domains/localhost/public_html"
servername localhost
ErrorLog "C:/Server/domains/localhost/logs/error.log"
CustomLog "C:/Server/domains/localhost/logs/access.log" common


# add phpMyAdmin for the future (do not forget to create a folder)

DocumentRoot "C:/Server/domains/phpmyadmin/public_html"
servername localhost
ErrorLog "C:/Server/domains/phpmyadmin/logs/error.log"
CustomLog "C:/Server/domains/phpmyadmin/logs/access.log" common

This completes the editing of the file. Further, in the remaining files, only the paths are edited:
File "httpd-manual.conf":
AliasMatch ^/manual(?:/(?:da|de|en|es|fr|ja|ko|pt-br|ru|tr|zh-cn))?(/.*)?$ "C:/ server/web/apache/manual$1"

No changes are made to the "httpd-default.conf" file. This completes the Apache configuration setup.

PHP setup

Since we have Windows 8.1 x64 and Apache x64 installed and configured, then php must be x64.
Let's go to the site:

and download the latest php archive. We need php as a module i.e. To do this, download Thread Safe. After the archive has been downloaded, open it and transfer the contents to the "C:\Server\web\php\" folder. Let's create two empty folders "tmp" and "upload". Next, in this folder, look for the file "php.ini-development" and rename it to "php.ini". Open the file in a text editor and change the directives (commenting lines in the file starts with a semicolon).

php.ini setup

short_open_tag = On
zlib.output_compression = On
post_max_size = 64M
include_path = ".;C:\Server\web\php\includes"
extension_dir = "C:/Server/web/php/ext"
upload_tmp_dir = "C:/Server/web/php/upload"
upload_max_filesize = 64M
extension=php_bz2.dll
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
extension=php_sockets.dll
extension=php_sqlite3.dll
; in the section we specify the time zone of our server (http://php.net/date.timezone)
date.timezone = "Asia/Yekaterinburg"
session.save_path = "C:/Server/web/php/tmp/"


This completes the php setup.

MySQL setup

We put MySQL x64 as a socket under windows. Download the archive with the latest version of MySQL x64:
dev.mysql.com/downloads/mysql
At the bottom of the page we find Windows (x86, 64-bit), ZIP Archive and click on the "Download" button. You will be redirected to the registration page on the site. Click at the bottom of the page "No thanks, just start my download", the download of the MySQL archive will start. After downloading the archive, open it and transfer all the contents of the folder to "C:\Server\web\mysql\"
Now open the MySQL settings file - "C:\Server\web\mysql\my-default.ini". We delete all its contents and enter our data there.
port=3306
host=127.0.0.1
port=3306
bind-address=127.0.0.1
enable-named-pipe
basedir="C:/Server/web/mysql/"
datadir="C:/Server/web/mysql/data/"
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
That's all. In the configuration file, we specified that scripts can access the server both by local IP and by socket connection.
It remains the case for the small. Let's add the paths to Apache and MySQL to the "PATH" system variable, for this:
  1. Drag the mouse cursor to the lower right corner of the screen
  2. Click the search icon and type: control panel
  3. Select System -> Advanced
  4. Select Environment Variables, from the System Variables menu, find the PATH variable and click on it.
  5. Write down the paths to Apache and MySQL:
;C:\Server\web\apache\bin;C:\Server\web\mysql\bin
Next, install the Apache and MySQL services. To do this, use the key combination "Win + X", a drop-down menu will appear in the lower left corner. Select "Command Prompt (Admin)".
At the command line, enter to install Apache:
httpd -k install
to install MySQL:
mysqld.exe --install MySQL --defaults-file=”C:\Server\web\mysql\my-default.ini”
Set a password for the MySQL user. To do this, start the MySQL service with the command:
NET start MySQL
After the service has started, set the password:
mysqladmin –u root password YourPassword
We registered two sites in the “httpd-vhosts.conf” file, in order for the browser to see them, the names of the sites must be added to the “hosts” file. Let's go to the folder:
C:\Windows\System32\Drivers\etc\
open the “hosts” file with any text editor (run as administrator) and add to the end of the file:
127.0.0.1 localhost
127.0.0.1 phpmyadmin
We save the file.
For the convenience of starting and stopping the Apache and MySQL services, let's create the start-server.bat and stop-server.bat files.
To do this, go to the folder "C:\Server\" and create these two files.
Contents of "start-server.bat":
@echo off
NET start Apache2.4
NET start MySQL
Contents of "stop-server.bat":
@echo off
NET stop Apache2.4
NET stop MySQL
Apache, PHP and MySQL configuration is now complete. In order to test the server, let's create an index.php file in the C:\Server\domains\localhost\public_html folder with the following content:

Next, let's start our server, to do this, run "start-server.bat" as an administrator. Once the server has started, open a browser and type "localhost" in the address bar.
The PHP information page should be displayed.

Folder preparation

I really don't like having everything lying around anywhere, so first let's create folders where we will have programs and sites.
Let's create a "Server" folder on the "C:\" drive (or wherever it is more convenient for you):
C:\Server\
We will create 2 folders in it:
C:\Server\web - this is the folder in which we will have programs
C:\Server\domains - and our sites will be in this folder
So, in the \web\ folder, we will create 3 folders for apache, php, mysql:
C:\Server\web\apache\
C:\Server\web\php\
C:\Server\web\mysql\
Next, go to the domains folder and create the \localhost\ folder
C:\Server\domains\localhost\
Inside the folder, we will have 2 subfolders: public_html - for site files; logs - for text files that record "who" accessed the site and what errors appeared in the site.
C:\Server\domains\localhost\public_html\
C:\Server\domains\localhost\logs\
This is where the folder structure ends, let's move on to configuring Apache.

Apache setup

To install Apache, we need Apache itself (Cap). Since we have Windows 8.1 x64, we will install Apache x64.
To download follow the link:
www.apachelounge.com/download/win64
and download "httpd-2.4.6-win64.zip". We also need the "Microsoft Visual C++ 2010 Redistributable Package (x64)" for normal operation. To do this, download it from this link:
www.microsoft.com/en-us/download/details.aspx?id=14632
and install.
After downloading our archive with Apache, open it. Having opened the archive, we will see the Apache24 folder, let's go into it. A lot of folders and program files will appear, we unpack everything into the previously prepared folder:
C:\Server\web\apache\
It should turn out like this:
C:\Server\web\apache\bin\
C:\Server\web\apache\cgi-bin\
C:\Server\web\apache\conf\
C:\Server\web\apache\error\
C:\Server\web\apache\htdocs\
C:\Server\web\apache\icons\
C:\Server\web\apache\include\
C:\Server\web\apache\lib\
C:\Server\web\apache\logs\
C:\Server\web\apache\manual\
C:\Server\web\apache\modules\
We do not need folders such as \cgi-bin\, \htdocs\, \icons\ and \manual\ - you can delete them.
Let's go to the folder:
C:\Server\web\apache\conf\
And open the Apache configuration file - "httpd.conf" with any text editor. In this file, each line contains directives for configuring Apache, and lines starting with a # sign (pound sign) contain a comment and an explanation. Let's start setting up:

Apache configuration file

# Apache directive
ServerRoot “C:/Server/web/apache”
# Listen on local IP port (80 by default)
Listen 127.0.0.1:80
# next, we will connect the extension libraries for Apache
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php5_module "C:/Server/web/php/php5apache2_4.dll"
# tell Apache that files with a php extension should be treated as php scripts
AddHandler application/x-httpd-php .php
# specify the location of the php settings file
PHPIniDir “C:/Server/web/php”
# change the server name
ServerName 127.0.0.1:80
# change directory access

Options Includes Indexes FollowSymLinks
AllowOverride All
Allow from all


# directory with our sites
DocumentRoot “C:/Server/domains”
# index files, by priority.

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

# folder for log files
ErrorLog “C:/Server/domains/logs/error.log”
CustomLog “C:/Server/domains/logs/access.log”
# add alias for phpMyAdmin, and fix alias for cgi

Alias ​​/pma "C:/Server/domains/phpMyAdmin"
ScriptAlias ​​/cgi-bin/ “C:/Server/web/apache/cgi-bin/”

# edit path for cgi

AllowOverride None
Options None
Require all granted

# file types


AddType text/html .shtml
AddOutputFilter INCLUDES.shtml
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

# Other configs:



Browser Match "MSIE 10.0;" bad_DNT


RequestHeader unset DNT env=bad_DNT

This completes the httpd.conf setup.
Additional configs have been included in the Apache httpd.conf configuration file:
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
Let's open the file "C:\Server\web\apache\conf\extra\httpd-mpm.conf" and quickly run through it.
# specify where we will store the pid file:

PidFile “C:/Server/web/apache/logs/httpd.pid”

The rest of the parameters are left unchanged. Let's open the file "httpd-autoindex.conf", change only the lines with the path there:
Alias ​​/icons/ "c:/Server/web/apache/icons/"

Options Indexes MultiViews
AllowOverride None
Require all granted

Apache Hosts File

# using domain localhost as an example

DocumentRoot "C:/Server/domains/localhost/public_html"
servername localhost
ErrorLog "C:/Server/domains/localhost/logs/error.log"
CustomLog "C:/Server/domains/localhost/logs/access.log" common


# add phpMyAdmin for the future (do not forget to create a folder)

DocumentRoot "C:/Server/domains/phpmyadmin/public_html"
servername localhost
ErrorLog "C:/Server/domains/phpmyadmin/logs/error.log"
CustomLog "C:/Server/domains/phpmyadmin/logs/access.log" common

This completes the editing of the file. Further, in the remaining files, only the paths are edited:
File "httpd-manual.conf":
AliasMatch ^/manual(?:/(?:da|de|en|es|fr|ja|ko|pt-br|ru|tr|zh-cn))?(/.*)?$ "C:/ server/web/apache/manual$1"

No changes are made to the "httpd-default.conf" file. This completes the Apache configuration setup.

PHP setup

Since we have Windows 8.1 x64 and Apache x64 installed and configured, then php must be x64.
Let's go to the site:

and download the latest php archive. We need php as a module i.e. To do this, download Thread Safe. After the archive has been downloaded, open it and transfer the contents to the "C:\Server\web\php\" folder. Let's create two empty folders "tmp" and "upload". Next, in this folder, look for the file "php.ini-development" and rename it to "php.ini". Open the file in a text editor and change the directives (commenting lines in the file starts with a semicolon).

php.ini setup

short_open_tag = On
zlib.output_compression = On
post_max_size = 64M
include_path = ".;C:\Server\web\php\includes"
extension_dir = "C:/Server/web/php/ext"
upload_tmp_dir = "C:/Server/web/php/upload"
upload_max_filesize = 64M
extension=php_bz2.dll
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
extension=php_sockets.dll
extension=php_sqlite3.dll
; in the section we specify the time zone of our server (http://php.net/date.timezone)
date.timezone = "Asia/Yekaterinburg"
session.save_path = "C:/Server/web/php/tmp/"


This completes the php setup.

MySQL setup

We put MySQL x64 as a socket under windows. Download the archive with the latest version of MySQL x64:
dev.mysql.com/downloads/mysql
At the bottom of the page we find Windows (x86, 64-bit), ZIP Archive and click on the "Download" button. You will be redirected to the registration page on the site. Click at the bottom of the page "No thanks, just start my download", the download of the MySQL archive will start. After downloading the archive, open it and transfer all the contents of the folder to "C:\Server\web\mysql\"
Now open the MySQL settings file - "C:\Server\web\mysql\my-default.ini". We delete all its contents and enter our data there.
port=3306
host=127.0.0.1
port=3306
bind-address=127.0.0.1
enable-named-pipe
basedir="C:/Server/web/mysql/"
datadir="C:/Server/web/mysql/data/"
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
That's all. In the configuration file, we specified that scripts can access the server both by local IP and by socket connection.
It remains the case for the small. Let's add the paths to Apache and MySQL to the "PATH" system variable, for this:
  1. Drag the mouse cursor to the lower right corner of the screen
  2. Click the search icon and type: control panel
  3. Select System -> Advanced
  4. Select Environment Variables, from the System Variables menu, find the PATH variable and click on it.
  5. Write down the paths to Apache and MySQL:
;C:\Server\web\apache\bin;C:\Server\web\mysql\bin
Next, install the Apache and MySQL services. To do this, use the key combination "Win + X", a drop-down menu will appear in the lower left corner. Select "Command Prompt (Admin)".
At the command line, enter to install Apache:
httpd -k install
to install MySQL:
mysqld.exe --install MySQL --defaults-file=”C:\Server\web\mysql\my-default.ini”
Set a password for the MySQL user. To do this, start the MySQL service with the command:
NET start MySQL
After the service has started, set the password:
mysqladmin –u root password YourPassword
We registered two sites in the “httpd-vhosts.conf” file, in order for the browser to see them, the names of the sites must be added to the “hosts” file. Let's go to the folder:
C:\Windows\System32\Drivers\etc\
open the “hosts” file with any text editor (run as administrator) and add to the end of the file:
127.0.0.1 localhost
127.0.0.1 phpmyadmin
We save the file.
For the convenience of starting and stopping the Apache and MySQL services, let's create the start-server.bat and stop-server.bat files.
To do this, go to the folder "C:\Server\" and create these two files.
Contents of "start-server.bat":
@echo off
NET start Apache2.4
NET start MySQL
Contents of "stop-server.bat":
@echo off
NET stop Apache2.4
NET stop MySQL
Apache, PHP and MySQL configuration is now complete. In order to test the server, let's create an index.php file in the C:\Server\domains\localhost\public_html folder with the following content:

Next, let's start our server, to do this, run "start-server.bat" as an administrator. Once the server has started, open a browser and type "localhost" in the address bar.
The PHP information page should be displayed.

Top Related Articles