Professional development always focuses on its own tools - this is a guarantee of reliable and efficient fulfillment of obligations. Own hosting and servers for various purposes in the range of popular configurations expand the scope of tasks, increase the security and confidentiality of development.
Native HTTP: Apache, PHP, MySQL
The Apache web server has been a confident leader since the last century, as it provides fast, reliable and safe operation. A physical machine and a server running Linux or Windows is the foundation, HTTP is an add-on, although it is essentially a data transfer protocol. A Windows machine can be used as a server, but preference is given to the Linux family.
Apache on Windows is a local version used on one computer to duplicate development of resources hosted on external servers. Installation on Windows Server is acceptable, but not very popular. Configuring Apache on CentOs provides more options and is used to organize servers in local and global networks.
It is believed that Apache servers serve more than 50% of all active web resources, the rest falls on similar products from Microsoft, Sun, etc. Actually, the physical server and its operating system can be any. The HTTP server is installed on a ready-made platform and works in parallel with other applications on it. Apache is considered native to the entire Linux family, but in each case it has features.
Free, simplicity, reliability distinguish Linux systems and their applications. It doesn't matter what to use: installing and configuring Apache on Ubuntu is not much different from CentOs, Debian, or FreeBSD. Often the saturation of a particular operating system with additional software plays a role.
The Linux family is small in number of “relatives” on the line of one or another core of the system. The differences are more social in nature - in the sense of developers' attachment to the formulation and embodiment of the capabilities of the operating system.
In reality, to solve a specific problem of raising hosting, you need to decide on the necessary functionality, the required performance, conceptual priorities and the specific choice of a Linux representative, or stop on Windows Server.
Local development priority shift
It is difficult to assess the role of the global network in the development of programming, but it is easy to notice a real shift in the center of gravity: it has become customary to execute local applications as a web resource. Just write a program for the local computer - these are drivers, antiviruses, small projects with simple functionality. The programming language is ... VBA, although C / C ++ or C # can be used.
Any information project is a web resource on the company's local network, which can partially be accessed from the global network, for example, to coordinate the actions of employees outside the office who are on the road or on a business trip.
MySQL, PHP, Apache: tuning for a local application is a completely different dynamics of the application, the necessary functionality. Modern companies, regardless of size, number of employees and field of activity, seriously consider Internet programming, both local and global.
At the same time, local programming of a web resource can be distributed: company offices can be located anywhere, but this is not the Internet, but a distributed local network of the company.
MySQL, PHP, Apache local configuration:
- easily duplicated by network computers;
- Provides the ability to dynamically change the active component or compare it with the sample to evaluate hacking attempts;
- gives reason to develop a security system that does not risk being attacked by classical network methods.
If you take into account that MySQL and Apache in the Windows environment are services, and the PHP code is ordinary text processed by a tool (PHP interpreter), called at the right time by the HTTP server, then the level of variability, mobility and portability of the code will be much higher than with local development tools.
Preparing to Install Apache
Even in the era of the “beginning of beginnings”, the Unix operating system determined the unspoken principles of loyalty. Since then, everything that was done for Unix-like systems was automatically broadcast to other platforms. Configuring Apache on Windows is extremely simple, but solving serious problems requires good qualifications and a detailed understanding of the configuration of the HTTP server.
First of all, you need to download the latest version of the server (today it is version 2.4.33 dated 03/17/2018) from the official site in the zip archive format. It should be borne in mind initially that server versions are numerous and are offered on a variety of third-party resources, so it is important to choose the official implementation posted on a trusted web resource.
Previously, installing the server through a special installer was popular. Nowadays, simple zip archive deployment is widely practiced. This is simpler and makes it possible to understand the essence of the configuration process, which is very important and subsequently allows you to optimize the server for the required load and functionality.
Editing a configuration file
The server configuration is determined by the set of configuration files located in the conf folder. The main Apache configuration file is httpd.conf.
In the vast majority of cases, it is necessary to make changes to the main file, to clarify the contents of the files responsible for ssl and virtual hosts. Other settings are usually made during the operation of the server as problems arise or problems are resolved. Basically, further settings are related to optimizing the work of Apache or expanding its capabilities.
To start the server successfully, it is enough to edit only one line (in order - the 38th) - and the Apache configuration is complete.
In previous versions of the server configuration, it was necessary to make numerous edits to the real situation, but now there is a “universal” variable SRVROOT. It is worth indicating its correct value (the path to the server location), and everything will work right away.
Server Hosting Procedure
The server location must be considered carefully. Apache itself is interesting, but when it comes with PHP and MySQL, it is doubly interesting. It’s better when everything related to web development is in one place. You can agree to the default paths, but modern programming is not so ideal in its implementation, so you have to keep your finger on the pulse unequivocally and often. In addition, when choosing a convenient location, all initialization and configuration files, as well as logs on the operation of installed products, will be available.
The downloaded official Apache zip archive must be deployed in the selected location, placing the tool and work separately. In this example, the C: \ SCiA folder is a tool (Apache24, PHP, MySQL, ...), and the SCiB folder is the work, in fact, of sites that are created, maintained or modernized.
As a result of the first stage of work, only the bin, cgi-bin, conf, error, ... subfolders with all their contents fall into the C: \ SCiA \ Apache24 folder.
Editing the hosts file
The second step is to properly configure the hosts file - an indication of which IP addresses on this computer are mapped to which names. If only one site is developed or maintained on a computer, nothing can be changed.
Base IP - 127.0.0.1 usually always points to localhost. The hosts file is located at c: \ Windows \ System32 \ drivers \ etc and looks like the one shown below.
To put the hosts file in the right place, you need to use the command line in administrator mode. You can prepare the correct contents of the file anywhere on the computer’s file system, but you can write it to c: \ Windows \ System32 \ drivers \ etc only with the tool that has administrator rights. This is the easiest way to do this through the command line.
Install Apache Server
There is nothing easier. It is enough to run the command line as administrator and go to the folder C: \ SCiA \ Apache24. Since this is the path on a Windows system, direct slashes are used. In a particular case, the path may be different. But if you can still experiment with the name of the folder for hosting the Holy Trinity - Apache, PHP and MySQL, then changing the folder names for each of them is impractical.
In this case, the server archive is deployed in the C: / SCiA / Apache24 folder, therefore, you need to write the command in the bin folder:
The server will test the configuration file and install itself. Most likely, there will be minor errors, but if you correctly edit the configuration file, then all errors will be insignificant, and they can be quickly fixed.
Window (1) of the command line - installation of the service, window (2) - a list of services in which the server appeared, window (3) - the source file index.html, located at C: / SCiB / localhost / www, window (4) - the result of the server.
In this example, an error was deliberately made: instead of setting the value of the SRVROOT variable, numerous edits were made “the old fashioned way”: everything was manually changed. This is not the best solution. Before applying knowledge, you should familiarize yourself with the current version of the product. As a rule, everything changes quickly, and knowledge should be applied “with knowledge of the matter and understanding of the current situation”.
Zip archive deployment practice
Modern sites are far from always written on site management systems. There is a lot of manual labor. The problem of transferring the site to another hosting led to a good solution - a zip archive. They rolled up the content in one place, expanded it in another.
Having an installer is good practice, but the dynamics of modern information technology does not give time to write beautiful installations. Using the installation through the deployment of a zip archive is modern, practical and convenient. In this scenario, Apache configuration is limited to modifying configuration files.
When installing the server, it is important to specify:
- Where is he located;
- Where is the web resource (localhost) located?
- using ssl;
- virtual hosts.
The latter position is relevant when it is supposed to develop or maintain several resources at once on the server. For a real developer, this is a must-have solution: even if it provides the operation of one site, it will not be superfluous to have a fallback.
Gentleman's sets
The ease of deployment of the zip archive is obvious, Apache (installation and configuration) - just two or three clicks. However, the result when installers were popular was equivalent. The developer simply spent more time developing the next version of his product. Installing a server, server language, and database is essentially just sets of files, starting services, the hosts file, and the default paths in the path operating system variable.
The appearance of "Denver" and similar gentlemanly developer kits was a revolutionary step along the lines of simplicity and convenience, but you should not be mistaken. Revolution and programming are completely incompatible things. The first is a child of the conflict and its violent resolution, the second is a serious matter requiring absolute calm, punctuality, accuracy, systematicity, attentiveness, security, reliability.
Configuring the Apache server is a serious procedure that you need to be very careful about and do everything so that tomorrow you can change and clarify something.
In most cases, the development of web resources is a rather lengthy process in which the requirements for services (Apache, PHP, MySQL, ...) change quickly, but there is always time to understand the next task and its optimal solution. But this is not a reason to go on about gentleman's sets. Time passes, and the gentleman does not change, this is a much more compelling argument than the Denver declaration - it is simple, fast and affordable.
Multiple Sites - One Server
Configuring Apache 2.4 for a single host is an unreasonable luxury. Despite its compact design, on the shoulders of this server hangs a huge weight of responsibility for more than half of the active web resources of the Internet. In addition, not all resources have a representative part and are visible on the network.
The server can be used as a database, as an information transfer point, as a filter, as a parser, as a working mechanism in a more global information process. As a result of this, setting up Apache virtual hosts is almost always a must.
One server can support any number of web resources, for this you need to remove a comment from line 501 in the httpd.conf file:
- # Include conf / extra / httpd-vhosts.conf
and describe all the necessary hosts in the file
- extra \ httpd-vhosts.conf.
You may need to clarify which ports and IP the server listens to, but this is a separate topic, for the first time you can limit yourself to what is.
It should be noted that in the example, for the convenience of describing real virtual web resources (and there are many of them), a variable (DOCROOT) was introduced with the path to the shared folder of all web resources accessible through the installed server.
Configuring Apache SSL is available in a similar way. In the httpd.conf file, you just need to leave “as is” lines 524 through 531, which are responsible for the operation of SSL.
The simplicity and complexity of Apache
The times when setting up a server was really a difficult task are long gone. Today, Apache configuration is a very simple procedure that does not require special skills from the developer.
Three simple steps:
- expand the archive;
- change the configuration file;
- install the server.
As a result, Apache is fully operational. If you do not take into account the subtleties of the process of server operation at maximum load or perform local development on a Windows computer, additional knowledge is not required.
Difficulties can arise on Linux systems. A significantly different idea of the file system, the rights of users and groups, as well as the organization of the process of interaction with other applications require a greater competence and understanding of how Linux computers work.
Configuring Apache on any Linux system opens up much more possibilities for the developer and gives access to the local network and the Internet. By tradition, a Windows computer is a local workstation, and the server is internal there. A Linux computer is a file server, a web server, and a host on a local network or a point in Internet space.
Professional Developer Environment
Apache is the fundamental brick of the Internet space, which can be easily and simply configured, used and will become the backbone of the company's network infrastructure .
This logic implies the presence of at least one server on the network based on CentOS, Ubuntu, FreeBSD, workstations on Windows. It is optimal to have two Linux servers (primary and secondary), setting up Apache for the local computer in a Windows environment. In the event of a virus attack or an unforeseen situation, the secondary server will be replaced to the main one, and the main one - to repair and restore. You can replace the local installation of Apache on a workstation (under Windows) from the archive.
This trivial solution can be clarified and supplemented in real practice. The size of the company's information flows can determine the desired configuration and the desired number of servers. Actually, Apache is designed to work under load, but nothing prevents you from distributing the responsibilities of one server across several. A solution that takes into account the specifics of a particular company is always more promising than adapting a third-party option.