Installing PHP on Windows

Optimizing PHP installation and configuration is a promising activity. This is done quickly, it does not entail any special costs, but, focusing on the use of PHP as the basis of the system of objects created to solve the problem, it is difficult to achieve the desired result.

Using and Installing PHP

PHP works when preparing a page for transfer to the visitor’s browser, in the background and in algorithms that use the AJAX mechanism to update page elements without reloading it.

PHP is called through the http server when it detects PHP code on the page. Calling PHP from the command line or otherwise is also possible, but these options are used outside of the task of exchanging information between the server and the browser.

An example of installing PHP 7 on Windows 10 is shown below.

Install PHP 7

This example demonstrates the result of the phpinfo () PHP function that was called on the local domain immediately after installing PHP.

The interpreter’s zip-archive was downloaded from the official website of the developer, deployed in the destination folder “C: / SCiA / PHP”, and a link to it was indicated in the Apache server “httpd.conf” file (first insert). In order to be able to start the site with a call to PHP, it is additionally indicated that "index.php" takes precedence over "index.html" (second insert).

Thus, installing PHP includes five steps:

  • download the official interpreter package (zip archive);
  • deploy the zip archive in the PHP working folder;
  • Paste the PHP location into the Apache “httpd.conf” file;
  • put the path to the PHP location in the environment variable of the operating system - path;
  • adjust php.ini settings file.

You can skip the last point at the initial stage, limiting yourself to minimal changes. The configuration of the interpreter often depends on the tasks that it solves. For example, very often, but not always, MySQL is used, and therefore, whether or not to enable an extension to work with this particular database is a specific task.

install php ubuntu

Installing PHP on Debian is significantly different:

  • apt-get install php5-common libapache2-mod-php5 php5-cli

According to the logic of the Linux family of systems, the necessary dependencies and available capabilities are automatically determined. The fact that in the Windows environment you need to specifically install, specify or specify, in the Linux family is done automatically.

It makes no difference what to install before - Apache or MySQL, but PHP should be installed last.

General description of php.ini

Installing PHP on Windows does not require much attention to the initialization file, but some points should be included immediately. Usually, extensions are immediately allowed to work: curl, fileinfo, gd2, gettext, mbstring, mysqli, openssl. Other extensions are connected as needed.

In the initialization file, you can specify the settings for the PHP language itself. For example, using simplified syntax ("<?" Instead of "<? Php"), using the ASP style (not recommended), output buffering, the number of decimal places for fractional numbers, enable or disable safe mode.

For many tasks, resource management is essential, for example, the maximum execution time of the script (max_execution_time) or the amount of allocated memory (memory_limit).

The php.ini file allows you to manage error handling, logging operations, and event logging. Data processing can be controlled through the priorities set in the variables_order directive. Here you can determine which is more important: GET, POST Cookie or other language objects.

PHP allows you to upload files to the server. However, without authorization from “php.ini”, you cannot upload a file (file_uploads). In addition, you can determine where temporary files will be uploaded and what is the maximum upload size (upload_tmp_dir, upload_max_filesize).

install php debian

PHP can load one or more files in one operation. In this operation, it supports the capabilities of JavaScript, which through the AJAX mechanism can transmit information about the data to be loaded.

In recent versions, MySQL is built into the core of PHP, but you must use the ability to specify the host, username and password via "php.ini" if you follow the security rules. If there are no problems with the hosting and there is no chance that the file with the web resource configuration will fall out in the browser window upon failure, then the declaration of confidential data in “php.ini” is certainly better than their indication in the web resource code.

PHP external working conditions

PHP installation is performed on a server, usually Apache. The operation of an HTTP server depends on many factors, but it is its configuration that determines how the launch and operation of applications suspended on the server are performed.

Usually, PHP Thread Safe is installed under Windows, that is, a multithreaded version. In this case, setting up Apache is essential. In particular, setting the MPM, MaxRequestsPerChild, MinSpareServers, MaxSpareServers, MaxClients directives, optimizing the file cache and RAM cache.

In most cases, everything will have to be verified empirically. Each web resource has its own unique information structure and the dynamics of information processes. What can be found on the Internet described as a perfectly working option will not work similarly in another specific case.

The essential points in the working conditions of PHP is the actual code that adequately takes into account the settings in “php.ini”, the minimum number of third-party templates and developments of popular site management systems.

It’s better to rewrite critical places in the code manually than rely on engines of well-known CMS, which sacrifice performance for their own rating.

Site management systems

Installing PHP and setting up php.ini - two to three minutes of work on correctly installed Apache and MySQL working properly. The problem, however, happens in that the orientation to one or another CMS determines the second, more demanding level of settings.

man at the computer

The issue of a sharp decrease in performance when using any content management system can not even be discussed. For example, a simple page, made manually, can be written in 3-4Kb of code, its counterpart on Bitrix is ​​1.6Gb, and installation will take about an hour, you will have to negotiate with the hosting regarding the special conditions for the "content" of the web resource.

Having chosen a promising CMS, you can immediately plan a change in the tariff plan: the hoster will certainly put the condition for the transition from virtual hosting (disk space) to a dedicated server (physical or virtual).

However, the promising CMS will take on a significant part of the functions that otherwise would have to be done manually.

Solution price: PHP installation will continue in the CMS installation. The CMS installation program will require that you meet the necessary hosting conditions. This is a positive point, because you do not have to think about how and what to do. But there is a negative aspect: CMS developers pursue optimization goals within the framework of their ideas, and not in the context of a specific task.

PHP Objects and Server Operation

Installing PHP in Ubuntu Server can be done in different ways - it all depends on its version and the version of the operating system itself. In Windows, you have to do everything yourself, and the process is transparent.

It cannot be said that this circumstance is a disadvantage of the Linux family, but there is still a moment of uncertainty.

The stage of physical configuration is a link to PHP from "httpd.conf" and the refinement of the file "php.ini", then the step of logical refinement if a promising CMS is selected. Ultimately, the foundation of the site works, followed by functionality.

Actually the server and the database appear before the main code through the interface. As a rule, each developer separates the main code from the code for working with the database, with the browser (visitor), with the server (file downloading, import, export, etc.). The problem with the main code is that every time a visitor comes to the page or the AJAX engine starts, the main code is initialized. In fact, every time the site prepares itself for work.

JavaScript browser objects exist continuously while the visitor is on the page. PHP objects are only active when a page is loading, updating, or executing an AJAX request.

JSON or center of gravity transfer

Optimizing PHP installation and configuration is a promising activity. This is done quickly, it does not bear any particular costs, but, focusing on the use of PHP as the basis of the system of objects created to solve the problem, it is difficult to achieve the desired result.

The PHP object system "lives" from time to time. This means that every time she spends time on her installation and configuration, and only then does her job.

JS & PHP Optimization

Using the JSON data exchange mechanism, moving the main system of objects to JavaScript, you can achieve more. The JS object system is always “alive” while the visitor is on the page. The actions of JS objects are translated to a server that does what JavaScript cannot do, and are returned.

Optimizing the combination of JavaScript and PHP is the ideal solution in almost any situation and in any field of application.

Source: https://habr.com/ru/post/K41/


All Articles