Configuring and installing Apache2 for a Ubuntu-based server. Enable Virtual Host in Apache

Home / Mobile devices

This article - step by step instructions on 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 work environment suitable:

  • 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).

Apache 2.4 VC9 version works with almost all current Windows versions(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

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

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

In the configuration file httpd. conf default routes 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 operating rooms Linux systems and Unix. 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 [email protected]

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 C:\MySites folder. 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 enabled Windows firewall, then 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! . IN 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 move Apache to port 8080.

To do this, in the httpd file. conf 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 re start

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

For ease of working with the Apache server, you can install it in the startup menu Windows shortcut, indicating 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 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.

In the httpd configuration file. conf add the lines:

LoadModule php 5_ module « C :/ TestServer / PHP 54/ php 5 apache 2_4. dll"
AddHandler application / x - httpd - php . php
# configure the path to php . ini
PHPIniDir "C:/TestServer/PHP 54/php"

In a folder C:\TestServer\Apache54\htdocs 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! , then the PHP installation completed successfully.

Setting up php.ini

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

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

Rename the php.ini-production template to .

Libraries for working with the MySQL database are located in the folder C:\TestServer\PHP 54\ext. 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/PHP 54/ext"

There are two libraries for working with the MySQL database in PHP: php_mysqli. dll is newer and is recommended to be used in 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 be downloading 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.

Select the server type with minimum requirements to memory – Developer Machine.

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

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

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 ( manual installation) 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 utility for working with MySQL ( 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 command
show databases;

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

Exiting the mode command line:
exit;

This completes the server installation. Good luck!

How to set up an Apache server? What is the httpd.conf file? In this tutorial I will answer these questions and show the basic directives for setting up a server.

Server configuration files

The Apache server has three configuration files: httpd.conf, srm.conf, access.conf. Typically these files are located in the directory /etc/httpd/conf(linux). All server setup consists of editing these three files. Let's look at what functions these files perform:

  1. File httpd.conf- this is the main server configuration file. It contains technical description server operation.
  2. In file srm.conf parameters of documents that are hosted on the server are specified.
  3. File access.conf contains server access parameters.

httpd.conf file

The file contains almost all the directives necessary for the server to operate. Below are basic directives Apache server configuration file:

ServerName - directive that defines the name of the Apache server. Moreover, the official name of the server must be specified here in the form in which it should appear in the address bar of the browser. This name must be registered with DNS server your network.

ServerType - a directive that defines the server type. The default value is standalone. If you want to achieve maximum performance from your Web server, do not change this option.

ServerType standalone

ServerRoot - This directive specifies the location of the Apache server configuration files. By default, the /etc/httpd directory is used for these purposes.

ServerRoot "D:/MyFolder/usr/local/Apache"

PidFile - This directive specifies the name of the file in which the initial server process will be registered. This file contains its process identifier (PID). You can use this information to stop or restart the server when writing your own scripts. This file will only be created if the Apache server is running in standalone mode.

PidFile logs/httpd.pid

Timeout - specifies the period of time in seconds during which the server continues to attempt to resume suspended data transfer. The meaning of the Timeout directive applies not only to the transmission, but also to the reception of data. If you need to receive large files, I recommend increasing this value.

Timeout 300

KeepAlive - allows persistent connections, that is, connections in which more than one request is made at a time.

Keep Alive On

MaxKeepAliveRequests - The maximum number of requests allowed during a persistent connection. Set to 0 to remove the limit. To improve performance, it is recommended to set this number relatively high.

MaxKeepAliveRequests 100

KeepAliveTimeout - defines the timeout for a persistent connection.

KeepAliveTimeout 15

ServerAdmin - Sets email address webmaster of your website. In case of errors, a message will be sent to this address.

ServerAdmin root@localhos

StartServers - Sets the number of child processes that are created when the server starts. The parameter is dynamic and changes during operation, so you don’t have to change it.

MinSpareServers - Sets the minimum number of idle child processes that wait to receive a request. Creating a new process is quite a costly operation and large quantities requests will place an extra load on the server.

MinSpareServers 8

MaxSpareServers – Specifies the maximum number of idle child processes that are waiting to receive a request. Again, if many additional processes are created, the system will be heavily loaded even with a minimum number of clients.

MaxSpareServers 20

ServerLimit – This directive sets the maximum value of MaxClients. It is recommended to set this value equal to the value in the Maxclients directive.

MaxClients - Please note that this is the most important setting parameter for Prefork MPM. The directive sets the maximum number of parallel processes created to process requests. The larger the value, the more requests can be processed simultaneously and the more memory will be consumed. When using dynamic pages with PHP, 16-32MB can be allocated per process. To determine more precisely, you need to run the command ‘ through an SSH connection ps -ylC httpd --sort:rss‘. At the output, we will receive a table where the required values ​​of occupied memory will be found in the RSS column; to obtain values ​​in megabytes, they need to be divided by 1024. To obtain general information about memory you can run the command ‘free -m’. Now you can calculate the approximate value of the parameter itself using any of the formulas:

MaxClients≈ (RAM – size_of_loaded_applications)/(size_of_process), or
MaxClients≈RAM* 70% / Max_memory_size_per_process.

MaxRequestsPerChild – Sets the number of requests that the child process can process before restarting. The value should be large enough to avoid creating new processes all the time. But it is still recommended to limit it (0 - unlimited), so that when Apache is running for a long time, in the event of a “memory leak”, the process is forced to terminate.

Apache is the most used Internet server on Linux systems. Internet servers are used to provide Internet pages upon request client computers. Clients typically request and view Internet pages using Internet browser applications such as Firefox, Opera, Chromium or Mozilla.

Users enter a Uniform Resource Locator (URL) to identify an Internet server by its fully qualified domain name(FQDN) and path to the required resource. For example, to see the home page of the Ubuntu website, the user must enter only the FQDN:

www.ubuntu.com

SymLinksIfOwnerMatch- Follows symbolic links if the target file or directory has the same owner as the link.

httpd settings

This section covers some basic configuration settings for the service. httpd.

LockFile- The LockFile statement sets the path to the lockfile when the server is compiled with the USE_FCNTL_SERIALIZED_ACCEPT or USE_FLOCK_SERIALIZED_ACCEPT option. It must be saved on a local disk. It is worth leaving the default value unless the log directory is located on an NFS share. Otherwise, the original value should be changed to a local disk directory with read permissions only for root.

PidFile- the PidFile instruction sets up a file in which the server writes its process ID (pid). This file should only be readable by root. In most cases, this parameter should be left unchanged.

User- The User statement sets the userid (user ID) used by the server to respond to requests. This setting determines the server's access rights. Any files that are inaccessible to this user will also be inaccessible to visitors to your site. The default user is "www-data".

Group- the Group instruction is similar to the User directive. Group sets the group under which the server will respond to requests. The default value is also "www-data".

Apache2 modules

Apache2 is a modular server. This means that only the most basic functionality is included in the core of the server. Advanced features are available through modules that can be loaded into Apache2. By default, a basic set of modules is included in the server at compilation time. If the server is compiled to use dynamically loaded modules, then the modules can be compiled separately and added at any time using the instruction LoadModule. Otherwise Apache2 must be recompiled to add or remove modules.

Ubuntu compiles Apache2 with the ability to load modules dynamically. Configuration directives can be included based on the presence of the corresponding module in the block .

You can install additional Apache2 modules and use them with your Internet server. For example, run the following command in a terminal to install the MySQL authorization module:

Sudo apt-get install libapache2-mod-auth-mysql

Look for additional modules in the /etc/apache2/mods-available directory.

Use the a2enmod utility to enable the module:

Sudo a2enmod auth_mysql sudo service apache2 restart

Similarly, a2dismod will disable the module:

Sudo a2dismod auth_mysql sudo service apache2 restart

Setting up HTTPS

Module mod_ssl adds an important feature for the Apache2 server - the ability to encrypt connections. So when your browser connects using SSL, the https:// prefix is ​​used at the beginning URLs in the navigation bar.

Module mod_ssl available in the apache2-common package. Run the following command in a terminal to enable this module:

Sudo a2enmod ssl

The default settings for HTTPS are in the file /etc/apache2/sites-available/default-ssl. For Apache2 to provide HTTPS, key and certificate files are also required. The initial HTTPS setup uses a certificate and key generated by the ssl-cert package. These are fine for testing, but must be replaced with a certificate that matches your site or server. For information on creating keys and obtaining certificates, see the Certificates section.

To configure Apache2 for HTTPS, enter the following:

Sudo a2ensite default-ssl

The /etc/ssl/certs and /etc/ssl/private directories are used by default. If you installed the certificate and key in other directories, be sure to change the SSLCertificateFile and SSLCertificateKeyFile options accordingly.

With Apache2 now configured to HTTPS, let's restart the service to allow the new settings:

Sudo service apache2 restart

Depending on how you issued your certificate, you may need to enter passphrase when Apache2 starts.

You can access the pages of the secure server by typing https://your_hostname/url/ in the address bar of your browser.

Record Sharing Rights

In order for more than one user to have write access to the same directory, you must grant write access to the group that unites them. The following example grants write permission to the /var/www directory for the group "webmasters".

Sudo chgrp -R webmasters /var/www sudo find /var/www -type d -exec chmod g=rwxs "()" \; sudo find /var/www -type f -exec chmod g=rws "()" \;

If access must be granted to more than one group per directory, use Controlled Access Lists (ACLs).

12/25/13 39.4K

A web server is a program that runs on a local or remote machine, and its main purpose is to allow the user to view web documents. When the website address is entered in the address bar, when you press Enter keys the browser generates a request directed remote computer- web server.

Apache HTTP server (short for a patchy server) is one of the most popular and widespread programs created for web developers and Internet resource administrators. According to independent researchers, Apache is installed on 50% of the computers of all HTTP server users.

The main advantages of Apache are stability, speed and flexibility, and they are due to its modular organization, as well as the fact that development is carried out by open group programmers, albeit under the official name Apache Software Foundation.

Apache supports a huge number of operating systems and hardware platforms, and is quite often used under operating system Windows. It is also important that this web server is distributed completely free of charge.

How to install Apache server for operating system Windows systems 7, will be discussed in this article.

Installing Apache

First of all, you need to download the latest version of the Apache distribution without SSL support and run the installation. In the welcome window you need to click on “Next”, read license agreement developer and confirm your agreement with him.


Then, in the installation window, you need to fill in the fields as shown in the picture below, and in the “ Administrator's Email Address» indicate your address email, click “Next” and set the switch to the “Custom” position.

Next, move on to the next step of the process “installing Apache”. By default, the web server installs to the folder C:Program FilesApache Software FoundationApache 2.2.
Next, you need to create a www directory on drive C and specify it as the installation folder for Apache, click “Next” in this and “Install” in the next window. When the installation is complete, click on “Finish".

If everything went well, the Apache web server management icon should appear in the tray. You can stop and restart it by left-clicking on the icon.


By clicking on the same icon right click mouse, you can navigate to various operating system system services or open the Apache monitor.
To check if it works installed server Apache, type http://localhost in your browser's address bar
If a page appears with the encouraging inscription “It works! ", this means that the Apache installation was successful and it is functioning correctly.

Basic web server setup

Although Apache is very convenient and extremely reliable, not everyone is ready to use it as a local server for a number of reasons, and the main one is the absence even in the environment Microsoft Windows any graphical configurator, which is quite unusual for most users.

The server is configured by manually editing the httpd.conf configuration file. However, contrary to ideas about the incomprehensibility and complexity this process, there is nothing complicated in this operation for two reasons: firstly, in order to turn a newly installed Apache into a server that is configured for acceptable and comfortable operation, you need to change very little data in the configuration file, and secondly, comments httpd.conf contains quite a lot useful information, necessary to understand the setup.

What is needed?

  • Run Apache under Windows platform 7;
  • Store the files of the future website in a user-friendly directory (for example, C:www);
  • Do not experience problems with encoding, and in particular with the display of the Cyrillic alphabet;
  • Ability to work with several sites simultaneously.

To successfully solve these problems, go to the Apache installation folder, find and open the httpd.conf file in the conf subfolder. Please note that lines starting with “hash” are text comments, and lines that do not have a “hash” icon at the beginning are used as web server settings.

First you need to configure the directory that will be used by the server as the website folder. Find the line in the text that starts with DocumentRoot. This directive determines which folder will be the root.

Correct it to DocumentRoot “C:/www”. It should be clarified that the slashes in this file should be slanted to the right, and not to the left, as you are probably already used to Windows users. After the above manipulations, the problem with the location of your site is solved.

Options (defines which server functions will be available) AllowOverride (defines which directives from .htaccess can override those in httpd.conf) Order (sets certain rules for accessing the server)

List of parameters used:

Options. The following options are possible:

  • Includes – use of SSI is allowed;
  • IncludesNOEXEC – use of SSI is allowed with restrictions (#include and #exec are not allowed);
  • Indexes – the use of index files is allowed, and if the URL points to a site directory (for example, www.domain.ru/dir/) in which there is no index file, the contents of this directory will be shown, and if this option is not present, an alert will be issued that access is prohibited;
  • ExecCGI – execution of CGI scripts is allowed;
  • FollowSymLinks – the server follows the existing symbolic links of the directory (used on Unix systems);
  • SymLinksIfOwnerMatch – the server follows existing directory symbolic links only if the target file has the same owner as the link;
  • All – all of the above together is allowed;
  • None – all of the above together is prohibited;
  • MultiViews – the ability to select specific content and display it depending on browser preferences (even if Options All is enabled. Specified separately).

AllowOverride. Options:

  • AuthConfig – allows you to use directives for authorization;
  • FileInfo – allows the use of directives for working with various types documents;
  • Indexes – allows the use of directives for working with indexing files;
  • Limit – allows the use of directives to determine access to the host;
  • Options – allows the use of directives to work with certain specific directory functions;
  • All – all of the above together;
  • None – none of the above together.

Order. Options:

  • Deny, Allow – Deny is defined before the Allow directive, access is allowed by default, except for hosts that are specified in the line following Deny from;
  • Allow,Deny – Allow is defined before the Deny directive, access is denied by default, except for hosts that are specified in the line following Allow from;
  • Mutual-failure – access is allowed only to those hosts that are absent in Deny and present in Allow.

Based on the above, try setting up your server. In the httpd.conf file, the Directory directive exists in two copies by default - And . The first option should not be touched, so in the second, set the parameters as follows:

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

In other words, the following options are selected for the C:/www folder and all its subfolders:

  • Among the possible functionality of the existing server, indexes in directories and navigation through symbolic links are allowed;
  • The possibility of parametric override using .htaccess files is completely absent, however, given that you have full access to the server, it is not relevant - everything can be configured via httpd.conf;
  • Access to the web server is allowed from all hosts.

Now, save the httpd.conf file and restart Apache using Apache Monitor or using the apache –k restart command on the command line. Setting up the site's root folder is complete.

You should check if you did everything correctly. Create a simple web page in the C:www folder, open your browser and enter http://127.0.0.1/your_created_page. The page should open. Otherwise, you must carefully check all changes to the httpd.conf file for correctness.

If the page opens successfully, there is a chance that instead of Cyrillic characters you will see unreadable characters. They can be displayed for two reasons. First, the web server provides your browser that requested the page with a default encoding. Secondly, oddly enough, this encoding is not Cyrillic.

If the notorious Internet Explorer in such cases determines the encoding from the page itself, then, for example, Mozilla Firefox and Opera have absolutely no inclination for such actions, and the method of manually setting the encoding in the browser can hardly be called convenient. Therefore, you need to configure Apache to return the required encoding by default.

Find the line in the httpd.conf file that starts with AddDefaultCharset . Most likely, the encoding is ISO-8859-1, which does not contain Cyrillic characters. Change ISO-8859-1 to windows-1251, save the file and restart Apache. Now the correct display of the Russian language on your website will work in any browser.

The Apache server is quite easy to set up to work with multiple sites. Addresses that can be used for them are 127.0.0.2, 127.0.0.3, etc. In this case, only the default site (127.0.0.1) will be visible on the network, but for local work this is not critical. The section of the httpd.conf file, in which everything necessary for this is configured, is located at the very end and is called VirtualHosts.

In order to add an additional site, create a directory that is used as its root, for example, C:www2. Assuming that the site will respond to the address 127.0.0.2, give it the name site911 and at the very end of the VirtualHosts section add the following lines:

ServerAdmin webmaster@site911 ServerName site911 DocumentRoot "C:/www2" ScriptAlias ​​/cgi/ "C:/www2/cgi/" ErrorLog "C:/www2/error.log" CustomLog "C:/www2/custom.log" common

Restart the Apache server. By typing 127.0.0.1 in the address bar of your browser, you will be taken to your first local site, and by typing 127.0.0.2 you will be taken to your second local site. It should be kept in mind that within each VirtualHosts container, absolutely any Apache web server directives can be used, so each site can be customized in the most detailed way.

Bottom line

Installation and configuration is complete, and now you can fully begin to study the operation of the Apache server in practice.

If you decide to get involved in website administration, your next step should be to study the Apache PHP MySQL bundle, because without a database management system, as well as without support for one of the most common web programming languages ​​and a web tool for administering the MySQL system, you cannot not a single server on the World Wide Web costs. As they say, " hard to learn, but easy to fight».

We wish you good luck in studying this difficult but interesting matter!

Good Bad

There are quite a lot of articles on the Internet where the authors give 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 run on it, without requiring the user to perform additional settings. 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. 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 control 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, are old Apaches not supported? latest versions 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, which 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 system partition 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 corresponding utility, which 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 it manual start through context menu services.

After manual or automatic start server, open a convenient browser and go to the address: //localhost. will appear blank page 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 is the installation and PHP setup completed. 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). We open it with text editor and enter the following piece of code:

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.

DBMS installation

  • 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 using 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.


© 2024 ermake.ru -- About PC repair - Information portal