Apache setup. Setting up MySQL. Setting up PHP. Or a local DIY development environment. Installing Apache on Windows

We present to your attention a new course from the team The Codeby- "Penetration testing of Web Applications from scratch." General theory, working environment preparation, passive fuzzing and fingerprinting, Active fuzzing, Vulnerabilities, Post-exploitation, Tools, Social Engeneering and much more.


Good things should be shared.

Here are instructions for Windows. If you have Linux, then " " is for you.

A local web server is a very useful tool. It is needed both by those who develop Web applications, and by those who learn to work with a variety of scripts, engines, as well as by those involved in web penetration testing. There are various popular all-in-one builds that include Apache, PHP, MySQL and other components. You can use them too. But installing a server yourself has a number of advantages:

  • the ability to use the newest components, the latest versions of Apache, PHP, MySQL, phpMyAdmin;
  • you can use these components on the day new versions are released - no need to wait for the authors of large packages to do this;
  • absence of unnecessary, redundant components - we install only what we need;
  • additional security - we do not know what changes were made by the authors of different assemblies. During self-installation, we download only official files from official sites;
  • Installing a server yourself is an important step towards studying it, towards understanding the underlying processes.

In fact, installing Apache, as well as other required elements - PHP, MySQL, phpMyAdmin, is a very simple operation. The difficulties that arise are due to the fact that error messages are not very informative. For example, if there is an error in the configuration, Apache simply does not start and that’s it. And it’s not always easy for a beginner to understand what’s wrong.

If you follow all the points in this instruction exactly, then everything will definitely work for you, regardless of your version of Windows!

Server installation includes installation and configuration of several elements:

  • the web server itself (Apache);
  • scripting language PHP;
  • MySQL database management system;
  • web interface for administering the MySQL DBMS phpMyAdmin.

Installation stages:

1. Preparatory stage - downloading Apache, PHP, MySQL, phpMyAdmin

We will install the latest versions of programs downloaded from official sites. The official Apache website is https://httpd.apache.org/. But this version only works with older versions of PHP. The PHP authors recommend the version from apachelounge.com. Therefore, follow the link https://www.apachelounge.com/download/

At the top of the page there are two versions of Apache Win64 or Win32. If you have 64-bit Windows, then select any one (this is unimportant and will not affect the work in any way. Just follow the rule that all versions of the server components are of the same bit size). I chose the 64-bit version.

If the previous downloaded files differed in bit depth, then for phpMyAdmin there is no such thing, since it consists of PHP scripts.

For PHP (as well as Apache) to work, you need to install Visual C++ Redistributable for Visual Studio 2012 from the official Microsoft website. To do this you need to follow the link.

When you try to start, Apache will complain that the file is missing and refuse to start. This file is part Visual C++ Redistributable for Visual Studio 2015, so download it in advance from the link (select the 32- or 64-bit version).

The downloaded file will be named vc_redist.x64.exe.

As a result, we have the following files:

  • httpd-2.4.12-win64-VC11.zip
  • php-5.6.6-Win32-VC11-x64.zip
  • mysql-5.6.23-winx64.zip
  • phpMyAdmin-4.3.11-all-languages.zip
  • vcredist_x64.exe
  • vc_redist.x64.exe

Run and install files vcredist_x64.exe and vc_redist.x64.exe- We will not return to them anymore.

2. Selecting the server structure.

Now everything is ready, you can start. A few words about the structure of our server.

On disk C create a directory Server, we create directories in it bin(here we will install Apache, PHP, MySQL) and data(our website and database will be here).

It would seem, what is this for? In fact, it makes backup easier. For example, folder bin changes very rarely and there is no point in backing it up every day. On the contrary, the contents of our site and databases may change daily and it makes sense to back up the folder data often. When we, for example, install a new version of PHP, we can force a copy bin and, in case of errors, you can easily roll back to an older version.

Let's continue our preparations. In the catalog data Let's create two folders:

  • D.B.(databases will be stored here)
  • htdocs(our sites will be here)

3. Installing and configuring Apache 2.4

To catalog bin unpack the Apache files (from the httpd-2.4.12-win64-VC11.zip archive), or rather we are only interested in the folder Apache24.

After unpacking, go to the directory c:ServerbinApache24conf and open the file httpd.conf any text editor.

#ServerName www.example.com:80

ServerName localhost

ServerRoot "c:/Apache24"

ServerRoot "c:/Server/bin/Apache24"

DocumentRoot "c:/Apache24/htdocs"

DocumentRoot "c:/Server/data/htdocs/"

DirectoryIndex index.html

DirectoryIndex index.html index.php index.htm

Save and close the file. That's it, Apache setup is complete!

Open the command line (this can be done by pressing the keys simultaneously Win+X). Select there Command Line (Administrator):

And copy there:

C:ServerbinApache24binhttpd.exe -k install

And press Enter. My firewall started up:

Click Allow if the same window appears.

Now enter into the command line:

C:ServerbinApache24binhttpd.exe -k start

And press Enter.

Enter as username root. 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:Serverdatahtdocs create folders and files, for example:

c:Serverdatahtdocstestajax.php - this file, accordingly, will be available at https://localhost/test/ajax.php, etc.

For creating full backup of all sites and databases just copy the directory data.

The Guarantor is a trusted intermediary between the Participants during the transaction.


Be your own host or install Apache on the Windows platform

This article is a step-by-step guide to creating a local web server. It describes the installation of the Apache 2.4 web server on the Windows OS platform. The installation was tested on Windows XP SP3.

Web server composition:

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

This workspace will suit:

  • experienced webmasters to test their projects;
  • for beginning webmasters to create their first websites.

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

Version Apache 2.4 VC9 works with almost all current versions of Windows (7/8/Vista/XP SP3).

For VC9 applications to work, you first need to update the Visual C++ libraries.

Installing the Visual C++ library update package

Download the vcredist_x86.exe update distribution from the Microsoft website, run the file and perform the update.

Installing and configuring Apache 2.4 server

There is no version of Apache 2.4 for Windows on apache.org. Therefore, we will take the distribution kit from apachelounge.com. At the time of writing, the latest release is Apache 2.4.10.

In the Additional + VC9 section, you can choose two distribution options - with and without ssl support. We choose the second option and download the archive httpd-2.4.10-win32-VC9.zip.

The Apache distribution does not have an installation file. Therefore, the installation will be done manually.

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

The default routes in the httpd.conf configuration file are C:\Apache24. Therefore, there will be much fewer edits in the configuration file if you unpack the archive into this folder.

We will unpack the distribution into the C:\TestServer folder.

We make changes to the configuration file C:\TestServer\Apache24\conf\httpd.conf. When writing paths, instead of the "\" (backslash) character, use the "/" (forward slash) character. This is how paths are written in Linux and Unix operating systems. But Apache was originally developed specifically for these operating systems.

We perform a group replacement of the text C:/Apache24 with C:/TestServer/Apache24.

Set the value of the ServerName parameter. ServerName localhost:80

Set the value of the ServerAdmin parameter (administrator's e-mail). ServerAdmin

Set the value of the DocumentRoot parameter (location of site documents). DocumentRoot C:/TestServer/Apache24/htdocs

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

The Apache executables are located in the C:\TestServer\Apache24\bin folder. Add this value to the Windows PATH environment variable. PATH = C:\TestServer\Apache24\bin;

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

If the Windows Firewall is enabled, when installing the service, a message will appear indicating that the program is blocked from external connections. For the service to work, you must give permission to unlock.

Let's start the Apache server. httpd.exe -k start

We check the performance of the server. In the browser command line, type the address: http://localhost. If the Apache installation was successful, the text It works! will be displayed on the screen. Otherwise we will see a blank screen.

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

This is done using the command netstat –anb

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

To do this, in the httpd.conf file we change the values ​​of the ServerName and Listen parameters. ServerName localhost:8080 Listen 8080

After this, restart the service with the command httpd.exe -k restart

and again we try to go to http://localhost

To make it easier to work with the Apache server, you can install a shortcut in the Windows startup menu pointing to C:\TestServer\Apache24\bin\ApacheMonitor.exe

Installing PHP 5.4

We go to the developer’s website http://windows.php.net/download/. Find the PHP 5.4 distribution in the VC9 x86 Thread Safe section and download the php-5.4.34-Win32-VC9-x86.zip archive.

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

We return to the site with the Apache distribution kit. 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 place it in the C:\TestServer\PHP54 folder.

Add the following lines to the httpd.conf configuration file:

LoadModule php5_module "C:/TestServer /PHP54/php5apache2_4.dll" AddHandler application/x-httpd-php .php # configure the path to php.ini PHPIniDir "C:/TestServer /PHP54/php"

In the C:\TestServer\Apache54\htdocs folder, create a file test.php. echo "Hello Apache!"; ?>

Restart Apache.

In the address bar of the browser we type http://localhost/test.php. If the text Hello Apache! appears on the screen, then the PHP installation was completed successfully.

Setting up php.ini

To work with the MySQL database, we need to configure php.ini – the PHP configuration file.

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

Rename the php.ini-production template to php.ini.

Libraries for working with the MySQL database are located in the C:\TestServer\PHP54\ext folder. This path must be specified in the extension_dir directive of the php.ini configuration file.

We find this parameter, remove the comment character at the beginning of the line (this is a semicolon) and write the path. extension_dir = "C:/TestServer/PHP54/ext"

There are two libraries for working with the MySQL database in PHP: php_mysqli.dll - the newer one and it is recommended to use it in your work; php_mysql.dll is old, but most sites use it.

It is better to include both libraries in the php.ini file. extension=php_mysql.dll extension=php_mysqli.dll

After completing the edits, be sure to restart the Apache server.

Installing and configuring MySQL

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

Run the file mysql-5.5.23-win32.msi.

We agree to the license terms and select the Typical installation type.

Let's move on to setting up the MySQL server.

Select Detailed Configuration – detailed configuration settings.

We select the server type with minimal memory requirements - Developer Machine.

Now we need to decide which databases (InnoDB, MyISAM) our server will work with.

Multifunctional Database – InnoDB and MyISAM supported. Transactional Database Only - InnoDB supported. Non-Transactional database Only - supported by myISAM.

When choosing InnoDB support, the next step is choosing where to store the InnoDB tables.

For the maximum number of simultaneous connections, it is better to select Manual Setting and accept the default value (15).

At this step, the Enable TCP/IP Networking parameter enables support for TCP connections and selects the port through which these connections will be made. The Enable Strict Mode parameter is also set – the mode of strict compliance with the MySQL standard.

Now you need to select the default encoding. The best option is UTF-8 encoding. Therefore, we choose Best Support For Multilingualism.

In order for MySQL to run as a Windows service, install Install as Windows Service. If you need to autostart this service, install Launch the MySQL Server automatically.

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

After clicking the Next and Execute buttons, the MySQL installation can be considered complete.

To check the functionality of MySQL, click the Windows Start button, find the MySQL utility (MySql Server 5.5 MySQL Server Command Line) and run it.

After entering the administrator password, we are taken to the MySQL command line.

Enter the show databases command;

If we see a list of databases, this will mean that the server is working correctly.

Exit command line mode: exit;

This completes the server installation. Good luck!

WindowsTune.ru

WAMP and XAMPP not working on Windows 10?

– October 10, 2015Categories: Miscellaneous

If you did a clean installation of Windows 10, you may not have the Word Wide Web Publishing Service at all. In this case, after installing WAMP / XAMPP, the web server should work fine without any problems.

If this does not happen, try installing Visual C++ Redistributable, and then reinstall WAMP / XAMPP.

As soon as the official upgrade from Windows 7 to Windows 10 became available, I did not fail to take advantage of this opportunity. The update went with a bang, everything was great, but when I tried to run my XAMPP under the new OS, I was disappointed: the Apache web server did not start. I note that problems with XAMPP / WAMP have already become an unpleasant tradition with every Windows update. I found two ways to solve this problem.

Option #1: How to run Apache on Windows 10

As I managed to find out, the culprit was port 80, occupied by the “Web Application Service”. Stopping this service and restarting XAMPP solved the problem. Below I show how to find this service and stop it from working.

  • Click the “Start” button and type the word “Services” (or services.msc).
  • In the window that appears, go down, where we find the line “Web Publishing Service”.
  • Right-click on the service and select the “Stop” option.

How to run Apache on Windows 10: Stopping the “Web Application Service”

After this, restart XAMPP / WAMP and Apache should work for you.

Read also: Windows 10 Hot Keys – Directory of Main Shortcuts

Option #2: How to run Apache on Windows 10

After a “clean” installation of Windows 10, as mentioned above, you may not have the “Web Application Service” at all. If in this situation, WAMP / XAMPP still does not work for you, try the following solution. It is necessary to change the port that will serve WAMP. Here's how to do it.

  • open WAMP/XAMPP.
  • Go to Apache settings, where select http.conf
  • In the text document that opens, find the line Listen 80.
  • Change the number 80 to whatever suits you, for example, 8090.
  • Restart WAMP/XAMPP.

Everything should work. However, now you will have to constantly use this port number when accessing the server. For example, if previously you simply wrote http://localhost/, now you will need to add http://localhost:8090/

If you have found another solution to this problem, write in the comments about your experience.

itdistrict.ru

Installing Apache on Windows 7

There are quite a lot of articles on the Internet where the authors provide detailed instructions with screenshots, thanks to which not a single user was able to install the Apache server for PHP and the MySql DBMS. But most of them leave the user with many questions to which he cannot find an answer for a long time. Let's look at what Apache, MySql, PHP are, what they are needed for and how to install these products.

A little theory

Apache is a free http server named after the North American tribe of Apache Indians. It is widely used on all platforms, including Windows, and has become a de facto standard in the development of web applications and services. In addition to it, we will need to install the MySql DBMS, which is also a standard in its field, and one of the most common and universal scripting languages ​​- PHP.

Apache (as users call it) differs from other servers in that all applications and services are guaranteed to work on it, without requiring the user to perform additional configuration. Compared to its analogues, Apache is not characterized by high performance and low consumption of computer resources, but any application is guaranteed to function on its basis. Here you can also add ease of setup, work on virtually all modern platforms and excellent documentation.

Now let's look at how to install Apache on a computer running Windows 7 (in later editions the process is almost identical), so that the server is installed on a real hosting.

Installation Apache

  • We go to the official Apache support resource and download its latest edition.

In fact, there is practically no difference between the versions of the product for the developer, unless the old Apaches are supported by the latest versions of the PHP scripting language.

  • Run the downloaded installation file.
  • We fill out the first two fields as in the screenshot: enter “localhost” in both lines.
  • We set absolutely any mailbox.
  • the first is responsible for installing the product as a Windows service that will use port number 80;
  • the second will connect the server to port number 8080, after which you will have to automatically start it every time.

Product developers recommend choosing the first option, so let’s look at it a little lower. When installing Apache, pay attention to the path where its files are stored. It is best to install in the “public” directory, located in the “users” folder on the system partition of your hard drive.

After closing the installation wizard, make sure Apache is running. To do this, go down to the tray and check for the presence of the icon shown below.

If it doesn't work, run the command line. This is done by entering “cmd” into the text form of the command interpreter (Win + R).

On the command line we write “net start Apache2.2” to start the server.

This entry is valid only for product version 2.2; in other versions the numbers will be corresponding.

The server is stopped by typing a command with the following parameters: “net stop Apache2.2”.

Let's look at a few more methods for starting, shutting down, and rebooting Apache. For regular work, using the command line to manage the server is ineffective - it will take a lot of time. The way out of the situation is to use the context menu of the tray icon: right-click on it and select what action needs to be performed.

The same is done by managing the service of the same name through the appropriate utility that provides access to Windows services, or the Services snap-in. It is launched through the search bar or “Administration” in the “Control Panel”.

Setting up Apache

When choosing the first server installation method, you can specify the method for starting it. If you use it regularly and have free resources on your PC, use Apache autostart. Otherwise, select to start it manually through the service context menu.

After manually or automatically starting the server, open a convenient browser and go to the address: http://localhost. A blank page will appear with the same address.

To get started, do the following.

  • We go to the “htdocs” directory, located in the folder with the software product files.
  • We delete the html file from it and create a directory with the name of the site (mysite).
  • You can go to the future site by entering http://localhost/mysite.
  • Go to the “conf” folder and open the “httpd.conf” file in a text editor (preferably with syntax support).
  • Go to line number 227 and replace “none” with “all”. The resulting value should be “AllowOverride All”.

See also: How to clean your computer from Windows 7 junk

Doing this will allow the "htaccess" document to be used. It is an advanced Apache configuration file.

  • We look for the line with the text “#LoadModule rewrite_module modules/mod_rewrite.so” and remove the “#” symbol.

This action activates the module responsible for the creation and operation of CNC links.

  • We save the changes made and be sure to restart Apache.

Installing PHP

  • We go to the PHP download page and download the latest stable version of the scripting language.

Attention! You will have to download not an executable file in msi or exe format, but a biz archive.

  • We create a directory and decompress the archive into it using 7zip or Winrar.
  • Open “httpd.conf” if you closed it and add the following text to the end:

"LoadModule php5_module "C:\Users\Public\php\php7Apache2_2.dll"

AddType application/x-httpd-php .php"

The numbers in the first line and the address will change depending on the versions of the products used and the directory paths and PHP.

  • Again, save the changes and restart Apache.

When an information dialog box appears indicating an error during the operation, restart Windows.

All PHP configuration parameters, when installed, are stored in the "php.ini" file. Instead, there are documents whose name begins with “php.ini”.

  • Rename any one to “php.ini” to create a configuration file.
  • Then copy this document to the Windows directory, for example, “C:\Windows”.
  • We restart the server through the context menu of its icon.

This completes the installation and configuration of PHP. All that remains is to check the functionality of the server. Go to “htdocs” and create a file in the folder with any name (preferably Latin) and php extension (for example, file.php). Open it using a text editor and enter the following code fragment:

Now open or maximize the browser window and enter the path to the created file in the address bar. In our case it is: http://localhost/mysite/file.php

See also: What to do if your Windows 7 computer takes a long time to boot

If everything went well and without errors, you will see a similar image.

Pay attention to the line “Loaded configuration file”. The path to the “php.ini” configuration file should be specified there.

This completes the installation of Apache with PHP on a Windows computer. If you need to install any CMS, the DBMS is installed.

Installation of the DBMS

  • Download the current version of MySql for your version and bitness of Windows.
  • After clicking on the “Download” button, click on the link highlighted in the screenshot to download MySql without registration.
  • We launch the installer, the functioning of which will require the .NET Framework library version 4.5.
  • We accept the terms of use of MySql on Windows.
  • Move the switch to the “Server only” position.
  • Click on the “Execute” button to start the MySql installation after checking the requirements.
  • We set a password for MySql, which will be used to provide access to the database.

The server installation with scripting language and MySql is complete. All that remains is to connect the last two components so that they can interact.

To do this, open the already known configuration file “php.ini” and delete the “;” symbol. in lines with the following data:

extension=php_mysql.dll

extension=php_mysqli.dll.

Find the text “; extension_dir = “ext”” and replace it with the following “extension_dir = “C:\Users\Public\php\ext””, where after the “equals” sign we set the path to the directory with PHP.

To check the functionality of MySql, create a file with the php extension (for example, file.php) in the “htdocs” directory with the following contents:

mysql_connect();

If, after opening the document, you see a picture on the screen like below, then everything is configured correctly, MySql is connected and Apache is ready to work.

(Visited 6,008 times, 6 visits today)

windowsprofi.ru

My experience setting up Apache x64 under Windows 8.1 x64

Preparing folders
I really don’t like having everything lying around, so first let’s create folders where our programs and websites will be located. Create a “Server” folder on the “C:\” drive (or wherever is more convenient for you):

Let's create 2 folders in it:

C:\Server\web – this is the folder in which we will have programs

C:\Server\domains – and this folder will contain our websites. 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’s operation.

C:\Server\domains\localhost\public_html\

C:\Server\domains\localhost\logs\ This completes the folder structure, 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/ru-ru/download/details.aspx?id=14632

And we install. After our archive has been downloaded from Apache, let's open it. Having opened the archive, we will see the “Apache24” folder, go into it. Many folders and program files will appear, unpack everything into the previously prepared folder:

C:\Server\web\apache\

It should look 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 don’t 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 # (hash) sign contain a comment and explanation. Let's start setting up: Apache configuration file# Apache ServerRoot directive “C:/Server/web/apache” # Listen on the local IP port (80 according to the standard) Listen 127.0.0.1:80 # then connect the extension libraries for Apache LoadModule rewrite_module modules/mod_rewrite .so LoadModule php5_module "C:/Server/web/php/php5apache2_4.dll" # we indicate to Apache that files with the php extension should be treated as php scripts AddHandler application/x-httpd-php .php # we indicate the location of the php settings file PHPIniDir “C:/Server/web/php” # change the server name ServerName 127.0.0.1:80 # change access to the directory 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 correct alias for cgi Alias ​​/pma “C:/Server/ domains/phpMyAdmin” ScriptAlias ​​/cgi-bin/ “C:/Server/web/apache/cgi-bin/”

# correct the 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:

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 BrowserMatch "MSIE 10.0;" bad_DNT RequestHeader unset DNT env=bad_DNT This completes the httpd.conf configuration. Additional configs were 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 Open the file “C:\Server\web\ apache\conf\extra\httpd-mpm.conf" and quickly go over it.

# indicate where we will store the pid file:

PidFile “C:/Server/web/apache/logs/httpd.pid” We leave the remaining parameters 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 Next, go to the “httpd-vhosts.conf” file and delete its contents. After we have done this, we begin to fill it again: Apache hosts file # using the example domain localhost 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 (don't 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 ends editing the file. Next, in the remaining files we edit only the paths: 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 should be x64. Let's go to the site:

www.anindya.com/tag/php

And download the php archive of the latest version. 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 “php.ini-development” file and rename it to “php.ini”. Open the file in a text editor and change the directives (commenting lines in the file begins with a semicolon). Setting php.inishort_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 indicate the time zone of our server (http://php.net/date.timezone) date.timezone = "Asia/Yekaterinburg" session.save_path = "C:/Server/web/php/tmp/" That's it for setting up php ends.

Setting up MySQL
We install 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” to start downloading the MySQL archive. After the archive has been downloaded, 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 indicated that scripts can access the server both via local IP and via a socket connection. There's just a little bit left to do. Let's add the paths to Apache and MySQL to the system variable "PATH", for this:

  1. Drag your mouse cursor to the lower right corner of the screen
  2. Click the Search icon and enter: control panel
  3. Select System->Advanced
  4. Select Environment Variables, from the System Variables menu, find the PATH variable and click on it.
  5. Enter the paths to Apache and MySQL:
;C:\Server\web\apache\bin;C:\Server\web\mysql\bin Next, we will install the Apache and MySQL services. To do this, use the keyboard shortcut “Win ​​+ X”, a drop-down menu will appear in the lower left corner. Select "Command Prompt (Administrator)". On 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”

Let's set a password for the MySQL user. To do this, start the MySQL service with the command:

After the service has started, set a password:

mysqladmin –u root password YourPassword

We have 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 Save the file. For the convenience of starting and stopping the Apache and MySQL services, we will create the files start-server.bat and stop-server.bat. To do this, let's go to the “C:\Server\” folder and create these two files. Contents of “start-server.bat”:

NET start Apache2.4 NET start MySQL Contents of “stop-server.bat”:

NET stop Apache2.4 NET stop MySQL Configuring Apache, PHP and MySQL is now complete. In order to test the server, let's create a file "index.php" with the contents in the "C:\Server\domains\localhost\public_html" folder:Install PhpMyAdmin Download the latest version of PhpMyAdmin from here:

www.phpmyadmin.net/home_page/index.php

Open the downloaded archive and transfer the contents of its folder to the folder for our domain “C:\Server\domains\phpmyadmin\public_html\”. Find the file “config.sample.inc.php”, make a copy of it and rename the copy to “config.inc.php”. Open the file with a text editor and change the data:Save and close the file. Open the website “http://phpmyadmin” in your browser and enjoy.

The article turned out to be lengthy, but I hope it is useful.

Tags:

  • windows 8.1
  • apache
  • mysql
  • phpmyadmin

habrahabr.ru

How to install Apache 2.4 along with PHP 5.6 and MySQL 5.6 on Windows OS versions 7 - 10

This material will become an indispensable instruction for novice web developers when installing the Apache web server with new versions of the PHP interpreter on their Windows computer. Typically, a simpler solution is used for this task - installing an assembly. This eliminates the need to fiddle with settings. But understanding the specifics of how a web server works, how to install and configure it correctly is one of the required skills of a web developer. Therefore, we will figure it out.

Please note: the above versions of VC11 will be very difficult, if not impossible, to run under Windows XP.

Preparation process.

First you need to make sure that the version of Windows on your computer is not older than version seven. Additionally, the instructions in this article for Apache 2.4 will not work for Windows XP.

First of all, remove all web servers that were installed previously. Next, you need to go to the services and make sure that Apache or IIS is not among them. If there is any other web server, there is a high probability that the one installed in parallel will not work.

If you use Skype on this computer, then in its settings you need to disconnect from port 80.

You will need a file manager or code editor to create files of different resolutions.

As for the folder structure, it may be different, but this instruction was developed for a specific structure that should be taken into account so that everything works 100%.

Before you begin the installation procedure, you should create a separate USR folder on drive D. There you need to create the apache, php, tmp, www, log folders, without specifying version numbers. Using a file manager or code editor, create the following files in the www directory:

  • index.html which contains: It works!
  • index.php which contains:

If you don't have a file manager or code editor, you need to download them here. These tools are a must-have for every developer on their PC.

In the PATH system variable we write:

;D:\USR\apache;D:\USR\apache\bin;D:\USR\php;

Important! The numbering of lines in configuration files for different versions of apache and php may differ from those shown.

Any commands are executed only on behalf of the Administrator, and editing files is no exception.

Apache 2.4 installation process

By and large, the development process in PHP does not require a separate web server, since it has a built-in web server and, as a rule, it is enough to develop 1 project. However, we recommend installing and configuring the Apache web server at a minimum to learn all the intricacies of working with this web server and its configuration. This skill will certainly be useful to you in the future.

  • First, let's download Apache 2.4 binaries VC11 for your system by going to: http://www.apachelounge.com/download/VC11/. We assume that you have a 64-bit operating system, where you will need a file called: httpd-2.4.16-win64-VC11.zip
  • All additional modules, if necessary, can be downloaded there. However, this is not necessary to complete a basic installation.
  • From the previously downloaded archive in D:\USR\apache, unzip the contents of the Apache24 folder and note that in D:\USR\apache it is necessary to place the contents of the Apache24 folder, and not the folder itself. No installation required.
  • In the D:\USR\apache\conf\httpd.conf file, change the ServerRoot value to "d:/USR/apache" on line 37, and the DocumentRoot (and Direcroty) value to "d:/USR/www" on line 242 and 243. Uncomment line 218, after which it needs to be changed to ServerName localhost:80.
  • The log storage parameters in this file need to be found and changed as follows:
  • Installing the Ahache service. Do not forget that it is executed only on behalf of the Administrator. Open a command prompt and paste:
    D:\USR\apache\bin\httpd.exe -k install
  • During the installation process, you must pay close attention to any pop-up error messages. If the installation is carried out correctly, they should not be there. The situation when, at the end of the execution of the line, the next one does not appear again, indicates that an error was made. To avoid errors, use the copy/paste functions.
  • The next step is to create a shortcut on the desktop for D:\USR\apache\bin\ApacheMonitor.exe and place it to load automatically. The startup window is called up like this: in WIN8, press WIN+R, then enter shell:Startup and click Ok.
  • Launch Apache Monitor. The shortcut should appear in the system tray. Left-click on it and then select Apache24 -> Start.
  • Go to http://localhost/ in your browser. The inscription “It works!” should be displayed here. If it is not there, it means something was entered incorrectly. To identify and correct the error, you need to read the logs, Google, etc.

PHP 5.6 installation process

  • To install PHP 5.6, download the latest VC11 x86 Thread Safe or the latest VC11 x64 Thread Safe from http://windows.php.net/download/. This is where VC11 and Thread Safe are needed. Please note that the bit depth is identical to that of Apache. The file you need will probably have a name like this: php-5.6.11-Win32-VC11-x86.zip or php-5.6.11-Win32-VC11-x64.zip
  • Next you need to extract the contents of the archive to D:\USR\php. No installation required.
  • In the file D:\USR\apache\conf\httpd.conf we write:
  • The DirectoryIndex value needs to be changed to index.html index.php on line 276.
  • Next, run the command Apache24-> Restart in Apache Monitor to restart Apache.
  • In the browser we type http://localhost/index.php, go and see that PHP works.
  • Copy the file D:\USR\php\php.ini-development, which is called D:\USR\php\php.ini
  • Go to the search to find, uncomment, and then change the parameters like this:
  • We set php-m on the command line and look at the list of modules that were connected.
  • Using Apache Monitor we restart Apache.

Virtual Hosts in Apache

  • In a situation where several projects are postponed on one PC, the need for virtual hosts arises. For example, we use two: s1.localhost and s2.localhost. To avoid confusion, we create folders with identical names, but in reality this is not necessary.
  • Remember that when using a virtual host, the DocumentRoot parameter in the Apache configuration file becomes meaningless. Now the main host of the server, which is located on http://localhost/, will be the main virtual host in the configuration file.
  • First, add the following lines to the file c:\Windows\System32\drivers\etc\hosts: (again, as administrator)
    127.0.0.1 s1.localhost
    127.0.0.1 s2.localhost
  • At this stage, after the work has been done, a reboot will not hurt. If lack of access rights prevents you from changing the file, you can make a copy of it on your desktop and change it there, then return it back.
  • Next you need to make folders for the virtual hosts D:\USR\www\s1.localhost and D:\USR\www\s2.localhost, where the files will be located. In all folders you need to create files with index.html, which will contain S1 and S2. This will allow you to monitor the correct operation.
  • Next, you need to make separate folders for logs: D:\USR\log\s1.localhost and D:\USR\log\s2.localhost - they will contain logs of all sites. It is more convenient to store logs in separate folders, but you can also store them in one common folder.
  • In the file D:\USR\apache\conf\httpd.conf, uncomment the line Include conf/extra/httpd-vhosts.conf to enable virtual host support.
  • After this, we edit in d:\USR\apache\conf\extra\httpd-vhosts.conf. Each virtual host has a separate VirtualHost block:
  • From now on, the first virtual host s1.localhost will become the main host of the system, because its block is the first one in the configuration file and is available when you go to http://localhost/
  • Using Apache Monitor, we restart Apache and go first to http://s1.localhost/, and then to http://s2.localhost/.

Let's summarize.

To add a new virtual host, you only need to create a separate folder for its files in D:\USR\www, for logs - in D:\USR\log, indicate its name in the hosts file and add the VirtualHost block to the virtual hosts configuration file.

There are quite a lot of articles on the Internet where the authors provide detailed instructions with screenshots, thanks to which not a single user was able to install the Apache server for PHP and the MySql DBMS. But most of them leave the user with many questions to which he cannot find an answer for a long time. Let's look at what Apache, MySql, PHP are, what they are needed for and how to install these products.

A little theory

Apache is a free http server named after the North American tribe of Apache Indians. It is widely used on all platforms, including Windows, and has become a de facto standard in the development of web applications and services. In addition to it, we will need to install the MySql DBMS, which is also a standard in its field, and one of the most common and universal scripting languages ​​- PHP.

Apache (as users call it) differs from other servers in that all applications and services are guaranteed to work on it, without requiring the user to perform additional configuration. Compared to its analogues, Apache is not characterized by high performance and low consumption of computer resources, but any application is guaranteed to function on its basis. Here you can also add ease of setup, work on virtually all modern platforms and excellent documentation.

Now let's look at how to install Apache on a computer running Windows 7 (in later editions the process is almost identical), so that the server is installed on a real hosting.

Installation Apache

  • We go to the official Apache support resource and download its latest edition.

In fact, there is practically no difference between the versions of the product for the developer, unless the old Apaches are supported by the latest versions of the PHP scripting language.

  • Run the downloaded installation file.
  • We fill out the first two fields as in the screenshot: enter “localhost” in both lines.

  • We set absolutely any mailbox.
  • the first is responsible for installing the product as a Windows service that will use port number 80;
  • the second will connect the server to port number 8080, after which you will have to automatically start it every time.

Product developers recommend choosing the first option, so let’s look at it a little lower. When installing Apache, pay attention to the path where its files are stored. It is best to install in the “public” directory, located in the “users” folder on the system partition of your hard drive.

After closing the installation wizard, make sure Apache is running. To do this, go down to the tray and check for the presence of the icon shown below.

If it doesn't work, run the command line. This is done by entering “cmd” into the text form of the command interpreter (Win + R).

On the command line we write “net start Apache2.2” to start the server.

This entry is valid only for product version 2.2; in other versions the numbers will be corresponding.

The server is stopped by typing a command with the following parameters: “net stop Apache2.2”.

Let's look at a few more methods for starting, shutting down, and rebooting Apache. For regular work, using the command line to manage the server is ineffective - it will take a lot of time. The way out of the situation is to use the context menu of the tray icon: right-click on it and select what action needs to be performed.

The same is done by managing the service of the same name through the appropriate utility that provides access to Windows services, or the Services snap-in. It is launched through the search bar or “Administration” in the “Control Panel”.

Setting up Apache

When choosing the first server installation method, you can specify the method for starting it. If you use it regularly and have free resources on your PC, use Apache autostart. Otherwise, select to start it manually through the service context menu.

After manually or automatically starting the server, open a convenient browser and go to the address: //localhost. A blank page will appear with the same address.

To get started, do the following.

  • We go to the “htdocs” directory, located in the folder with the software product files.
  • We delete the html file from it and create a directory with the name of the site (mysite).
  • You can go to the future site by entering //localhost/mysite.
  • Go to the “conf” folder and open the “httpd.conf” file in a text editor (preferably with syntax support).
  • Go to line number 227 and replace “none” with “all”. The resulting value should be “AllowOverride All”.

Doing this will allow the "htaccess" document to be used. It is an advanced Apache configuration file.

  • We look for the line with the text “#LoadModule rewrite_module modules/mod_rewrite.so” and remove the “#” symbol.

This action activates the module responsible for the creation and operation of CNC links.

  • We save the changes made and be sure to restart Apache.

Installing PHP

  • We go to the PHP download page and download the latest stable version of the scripting language.

Attention! You will have to download not an executable file in msi or exe format, but a biz archive.

  • We create a directory and decompress the archive into it using 7zip or Winrar.
  • Open “httpd.conf” if you closed it and add the following text to the end:

"LoadModule php5_module "C:\Users\Public\php\php7Apache2_2.dll"

AddType application/x-httpd-php .php"

The numbers in the first line and the address will change depending on the versions of the products used and the directory paths and PHP.

  • Again, save the changes and restart Apache.

When an information dialog box appears indicating an error during the operation, restart Windows.

All PHP configuration parameters, when installed, are stored in the "php.ini" file. Instead, there are documents whose name begins with “php.ini”.

  • Rename any one to “php.ini” to create a configuration file.
  • Then copy this document to the Windows directory, for example, “C:\Windows”.
  • We restart the server through the context menu of its icon.

This completes the installation and configuration of PHP. All that remains is to check the functionality of the server. Go to “htdocs” and create a file in the folder with any name (preferably Latin) and php extension (for example, file.php). Open it using a text editor and enter the following code fragment:

Now open or maximize the browser window and enter the path to the created file in the address bar. In our case it is: //localhost/mysite/file.php

If everything went well and without errors, you will see a similar image.

Pay attention to the line “Loaded configuration file”. The path to the “php.ini” configuration file should be specified there.

This completes the installation of Apache with PHP on a Windows computer. If you need to install any CMS, the DBMS is installed.

Installation of the DBMS

  • Download the current version of MySql for your version and bitness of Windows.

  • After clicking on the “Download” button, click on the link highlighted in the screenshot to download MySql without registration.

  • We launch the installer, the functioning of which will require the .NET Framework library version 4.5.
  • We accept the terms of use of MySql on Windows.
  • Move the switch to the “Server only” position.

  • Click on the “Execute” button to start the MySql installation after checking the requirements.

  • We set a password for MySql, which will be used to provide access to the database.

  • Click “Next”.

The server installation with scripting language and MySql is complete. All that remains is to connect the last two components so that they can interact.

To do this, open the already known configuration file “php.ini” and delete the “;” symbol. in lines with the following data:

extension=php_mysql.dll

extension=php_mysqli.dll.

Find the text “; extension_dir = “ext”” and replace it with the following “extension_dir = “C:\Users\Public\php\ext””, where after the “equals” sign we set the path to the directory with PHP.


In this article I will talk about how to set up a local development environment with your own hands. Of course, you can use ready-made solutions, for example, and others like it. But, look at the comments to and. Either Denver is not installed, or Apache does not start, or it is not known where Denver hid the databases.

In addition, the hosting provider’s server does not have a development package, but native distributions of Apache, MySQL and PHP. Just the other day, I was faced with a situation where the site being created worked normally in an installed and manually configured development environment, but under Denver it did not work at all.

A ready-made development environment often lacks flexibility in settings. Configuration files are hidden in well-known places in Denver.

Personally, I have some kind of schizophrenic fear that the builder of a local development package got into the distribution kit with his own hands, corrected something there at his own discretion, picked something up, and maybe even inserted a virus (that’s why I don’t use various tweaked assemblies of Windows and I set up my local development environment myself).

I will describe the process in detail installing and configuring Apache server to your local computer. This will allow you to get rid of the magical awe of the principles of operation of the site from the hosting provider’s server.

Besides, install and configure PHP. In the case of manually downloading the distribution from the developer’s website, I can be sure that I am downloading the full version of the package, the one that I need. And a situation with the need to additionally install modules discarded by the author of the distribution kit of a ready-made development environment cannot arise. From now on, I myself am the author of the development environment.

Installing and configuring MySQL. Exactly the same situation. The author is myself.

A few words for beginners. Why do we need a local development environment at all? If you are developing a site that will consist of several static HTML pages, then the development environment is just a convenience when viewing the site in a browser while debugging. It is convenient to access the website being developed using a domain name. That seems to be all the advantages.

In the case of developing a dynamic website (using PHP scripts and MySQL databases), as well as when working with engines, a local development environment is a necessity. Because, in this case, you need a tool that processes PHP scripts and SQL queries.

Well, let's go!

Installing Apache

I promised to save you from the magical awe of the principles of loading a site from a hosting provider's server in your browser. I'll do it now.

A server is nothing more than a powerful computer on whose hard drive your website files are stored. Typically, such a computer runs Unix-like systems. This computer is running a program called Apache. When accessing server port 80, the Apache program will provide the accessing computer with HTML code and graphic files stored on the hard drive. The user's computer browser will accept the received data and format it into a familiar site page.

The server's hard drive can contain several sites at once. All of them are distributed into folders with unique names (in this case, the sites are called virtual hosts). Apache is configured in such a way that when accessing port 80 with a specific site URL, it knows exactly what data and from which folder it needs to be sent to the requesting computer.

That's all the magic. When I just started to understand Internet technologies, such an answer to my question “how do websites really work,” which I read in one of the books, put everything in its place in my head, which I was very happy about. I hope some of our respected readers were no less delighted now than I was at one time.

Now I'll tell you how to install and configure Apache on your local computer.

After installing and configuring Apache, you can enter the domain name you came up with into the browser, which will be matched to the site being developed on the local computer, and the local server will provide the browser with the requested HTML.

Step 1. Download Apache.

On the next screen, be sure to check the box Include Bin Directory in Windows PATH:

If you don't do this, PHP won't be able to find the file it needs and will complain.

Click Next. In the next window we need to specify the database administrator password. Indicate something easy to remember. Then, when connecting to databases, you will need to enter this password:

At this point, the process of setting directives for configuration is completed and you can begin to apply them:

Now our local development environment can be considered installed. All that remains is to configure it.

Apache Setup and PHP Setup

First, somewhere on your hard drive you need to create a folder in which all projects will be stored.

This is my folder www at the root of the disk " WITH».

Step 1: Allow Apache access to dad www on your hard drive.

Now in the Apache settings I need to specify the path to this folder and allow access.

To do this, you need to open the main Apache configuration file in any text editor. This is a file .

In the file we look for a block of instructions:

AllowOverride None Options None Order allow,deny Allow from all

Below this block we insert the following instructions:

AllowOverride All # Options None Options Indexes FollowSymLinks Order allow,deny Allow from all

Thus, we allowed Apache access to the folder www at the root of the hard drive.

Step 2. Create a place to store site files.

In folder www you need to create a folder with the name of our site (for example mysite). In folder mysite create two more folders: www- for storing site files and logs- here Apache will automatically record errors related to server operation and information about connections to the site.

Since work is usually carried out with several sites (i.e. in the folder www the root of the hard drive, there may be several projects: mysite, mysite1, noviysite etc.) available at different local URLs, then you need configure Apache to work with virtual hosts.

To do this, in the configuration file C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf need to connect additional virtual host configuration file.

Looking in the file httpd.conf line #Include conf/extra/httpd-vhosts.conf. The process of including an additional virtual hosts configuration file is to remove the hash (#) character before this line.

#Include conf/extra/httpd-vhosts.conf

Include conf/extra/httpd-vhosts.conf

The fact is that in the Apache settings, the hash symbol (#) indicates a commented out line that is not involved in the server configuration.

The additional configuration file is now connected. Here is the file: . Again, open this file in any text editor and describe access to the site being developed.

At the end of the file you need to add the following block:

ServerName moysite.loc DocumentRoot "C:/www/moysite/www" ErrorLog "C:/www/moysite/logs/error.log" CustomLog "C:/www/moysite/logs/access.log" common

Paragraph ServerName specifies the URL that will be used to access the site being developed from the local computer browser, the files of which are located in the folder C:/www/moysite/www. File C:/www/moysite/logs/error.log will contain information about errors in the operation of the site, and the file C:/www/moysite/logs/access.log- information about connections.

Step 3: Redirect requests to the local server.

The last step is to redirect requests to the local server. We need to tell Windows that when the browser requests the URL mysite.loc it should be processed by our local Apache. To do this, open the file C:\WINDOWS\system32\drivers\etc\host in any text editor and add one line at the end: 127.0.0.1 moysite.loc.

That's all, now we restart Apache by left-clicking on the icon next to the clock and selecting Restart.

I draw your attention, dear reader, to the fact that it is necessary to restart Apache with any changes in its configuration and in the PHP configuration in order for the changes to be applied.

Let's shine

If during project development you are using CNC, then you need to enable the mod_rewrite.so module in the main Apache configuration file C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf.

Enabling the module is done by simply uncommenting the line LoadModule rewrite_module modules/mod_rewrite.so

#LoadModule rewrite_module modules/mod_rewrite.so

LoadModule rewrite_module modules/mod_rewrite.so


Using shortened tags. Some lazy programmers instead of complete code ..., at the beginning of the PHP script, use the shortened form ... To enable shortened tags, you need to configure the PHP configuration file C:\Program Files\PHP\php.ini:

Short_open_tag = Off

Short_open_tag = On

I draw your attention, dear reader, to the fact that in the PHP settings the symbol; is intended for commenting a line.

That's it for setting up your local development environment. Now, to create a new virtual host(For example noviysite.loc) you just need to take four simple steps:

1. In a folder C:\www\ create a new folder noviysite, inside which create a folder www And logs.

2. In the Apache virtual hosts configuration file C:\Program Files\Apache Software Foundation\Apache2.2\conf\extra\httpd-vhosts.conf specify settings for the new virtual host noviysite.loc:

ServerName noviysite.loc DocumentRoot "C:/www/noviysite/www" ErrorLog "C:/www/noviysite/logs/error.log" CustomLog "C:/www/noviysite/logs/access.log" common

3. On file C:\WINDOWS\system32\drivers\etc\hosts specify redirection for the new virtual host to the local server: 127.0.0.1 noviysite.loc

4. Restart Apache by left-clicking on the icon next to the clock and selecting Restart.

P.S.: Naturally in a folder C:\www\noviysite\www there should be site files that will be displayed in the browser when you enter the URL noviysite.loc/....

If only the domain name is entered noviysite.loc from folder C:\www\noviysite\www the file will be downloaded index.html(Apache is configured this way by default and it is this file that is automatically launched when you enter only the domain name).

Since dynamic sites written in PHP have recently become widespread, the start file will not be named index.html, A index.php. In order to, along with index.html when you entered only the domain name, it also automatically launched index.php need to make some minor changes to the file C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf:

Finding a block of directives DirectoryIndex index.html. After the directive DirectoryIndex index.html you need to add a space index.php so that it turns out like this: DirectoryIndex index.html index.php.

I would like to note that in this case Apache will first look for the file index.html and try to launch it, and then index.php.

If the site folder does not contain a file index.html or index.php(and it contains a file called kakoeto_imya.html), then set the URL noviysite.loc it won't end well in the browser (Apache won't find the files it wants to run by default). To run a file from a site folder named kakoeto_imya.html you need to type URL noviysite.loc/kakoeto_imya.html.

A legitimate question arises: How to administer MySQL databases if there is no phpMyAdmin?
The answer to this question is the HeidiSQL program and .

For dessert

After reading this article, I hope you have clarity on the question of “how a website works from a hosting provider’s server,” as well as “how to install and configure Apache, PHP and MySQL yourself.” Now it’s not a sin to drink a cup of coffee and watch a funny video.

I express my gratitude to the excellent programmer Pavel Krasko

for assistance in writing this article.

I devoted myself to the problem of installing a local development environment on a computer running Windows. If, after reading the article, you were unable to start the local environment, I highly recommend watching the video tutorial.

The Apache web server is a service that runs in the background and does not have a GUI. This service is installed and started from 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 setup of a web server is extremely simple - you just need to correctly specify the path to the folder in which the websites are located - this will be enough to start the web server.

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

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

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

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

Setting up a web server is done by editing a text file located in the folder Apache24\conf\ and is called httpd.conf.

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

This file does not contain all possible directives - many of them are not included here because they are not required for most tasks. Even in this note, we will not look at all the settings available in the file - if the description of something is missing, then you just don’t 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 from the computer), then the web server will not start.

I think you've already noticed that the web server is different from other Windows programs. 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 written in a way that is not quite usual for Windows. Now the main thing is to understand two rules:

  • use absolute file paths (which start with a drive letter, followed by all subfolders), 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 rather than backslashes (ie, "c:/apache" instead of "c:\apache").

So open the file Apache24\conf\httpd.conf any text editor (even Notepad) and now we are ready to configure the web server.

First comes the directive ServerRoot is the top directory of the tree where 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 is the default "c:/Apache24". The second directive assigns a value to a variable $(SRVROOT) at a construction site ServerRoot.

ServerRoot- this is the folder in which 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 construction:

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

Or, if you don't plan to use the $(SRVROOT) variable again (and it is used by default below!), you can reduce 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 listening on port 80 on any IP address (i.e. any network interface) available on your system. You can specify a specific IP address to listen to and, therefore, to respond to requests from:

Listen 12.34.56.78:80

You can specify multiple ports:

Listen 80 Listen 8000

Or several 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) should not be occupied by another program.

The default value is quite suitable for a local web server - i.e. here you can simply not change anything.

In fact, everything you really need is included - and most websites don't need to change anything - 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 using it. You can enable it, 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 web server pages, which are automatically generated in case of errors. It is understood 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 (until explicitly allowed) and prevents the use of files .htaccess(until it is explicitly allowed).

DocumentRoot "$(SRVROOT)/htdocs"

DocumentRoot- This is the directory where sites 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 web documents. There is no need to write a trailing slash.

Design We've already met. But here the specific folder for which settings are made is indicated. These settings overwrite the general ones specified previously.

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

Please note that the variable is again used to set the settings $(SRVROOT), the value of which was assigned at the very beginning. If you use the syntax with $(SRVROOT), then the root document folder must be located in the server root folder. I configure the server differently - my executable files are separated from the site files, so instead of a variable, you can simply enter the paths to the desired folder with 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 file name. 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 shown.

Second option ( FollowSymLinks) means to follow symbolic links. These are something 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, this is not very necessary for novice server administrators.

Directive AllowOverride installed on None, this means prohibiting the use of files .htaccess. On my server I allow files .htaccess(needed for mod_rewrite, access restrictions), so I replace its value with All, it turns out like this:

AllowOverride All

And the directive Require all granted Gives visitors access to web documents.

I have already mentioned index files; the list of index files is established by the construction:

DirectoryIndex index.html

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

DirectoryIndex index.html

DirectoryIndex index.php index.html index.htm

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