How to install PHP: all the pitfalls of the process.


Last update: 16.12.2017

Eat different ways installation of everything necessary software. We can install components separately, or we can use ready-made assemblies like Denwer or EasyPHP. In such assemblies, the components already have initial setup and are already ready to create websites. However, sooner or later developers still have to resort to installation and configuration individual components, connecting other modules. Therefore, we will install all components separately. As operating system Windows will be used.

What does installing PHP involve? Firstly, we need PHP interpreter. Secondly, we need a web server, for example, Apache, with which we can access the resources of the site we are creating. Third, since we will be using databases, we will also need to install some kind of database management system. MySQL was chosen as the most popular in conjunction with PHP.

To install PHP, let's go to the developers' website http://php.net/. On the downloads page we can find various distributions for the operating system Linux systems. If our operating system is Windows, then we need to download one of the packages from the page http://windows.php.net/download/.

Download the zip package of the latest PHP release:

Usually, latest issue PHP has two versions: Non Thread Safe and Thread Safe. We need to select the Thread Safe version. This version has options for 32-bit and 64-bit systems.

Let's unpack the downloaded archive into a folder called php. Let this folder be located at the root of drive C.

Now we need to execute minimal configuration PHP. To do this, go to the c:\php directory and find the file there php.ini-development. This is the initial configuration file for the interpreter. Let's rename this file to php.ini and then open it in text editor.

Let's find the line in the file:

; extension_dir = "ext"

This line points to the directory with plug-in extensions for PHP. Let's uncomment it (removing the semicolon):

Extension_dir = "ext"

Since all extensions are in the ext directory.

Since we will be using bases MySQL data, then we need to specify the extension in php.ini. By default, it is already in the file, only it is commented out:

;extension=mysqli

Let's uncomment it by removing the semicolon:

Extension=mysqli

Now by default this library will be used when working with the database. We can also uncomment other extensions if necessary. But for starters, one is enough for us.

We will leave the rest of the file contents unchanged.

Now let's install the web server.

The php.ini configuration file is the main configuration tool for the PHP core. It is counted every time PHP is initialized. If the change is not visible, be sure to stop and restart httpd. If changes made are still valid, use the phpinfo() function to check where php ini is located.

The configuration file is well commented and detailed. Parameters are case sensitive, values keywords- No; spaces and lines starting with a semicolon are ignored. Boolean values ​​can be represented as 1/0, Yes/No, On/Off or True/False. Default values ​​in php.ini will affect PHP installation, which can be configured later.

In this article we will look at important settings in the php.ini file, which may be required for the PHP parser.

short_open_tag = Off

Short open tags look like this:. This setting must be set to Off if you want to use the XML processing features.

safe_mode = Off

If this setting is ON, you probably compiled PHP with the enable-safe-mode flag. Safe Mode is most important for using CGI.

safe_mode_exec_dir =

This option only has a meaning if enabled safe mode. It can also be installed with the --with-exec-dir flag during the Unix build process. PHP executes external functions in safe mode binary files only from this catalogue. The default directory is /usr/local/bin . This has nothing to do with serving a regular PHP/HTML web page.

safe_mode_allowed_env_vars =

This php ini option specifies which environment variables users can change in safe mode. By default, only those variables that have "PHP_" appended to them. If this directive is empty, then most variables can be changed.

safe_mode_protected_env_vars =

The parameter sets which environment variables users cannot change in safe mode, even if the safe_mode_allowed_env_vars option is enabled.

disable_functions =

Enough useful addition in the PHP4 configuration, which has been preserved in the PHP5 version, is the ability to disable selected functions for security reasons. Previously, this required manual editing of the C code in which the PHP interpreter was written. Functions file system, operating system and network should be first on this list because the ability to write files and change the system via HTTP is not secure.

max_execution_time = 30

At php settings ini you need to be aware that the set_time_limit() function will not work in safe mode. Therefore, this is the main way to implement delaying script execution in safe mode. On Windows you have to do force termination, based on maximum memory consumption rather than time. You can also use the Apache timeout setting to implement a delay. But it will also apply to non-PHP site files.

error_reporting = E_ALL & ~E_NOTICE

The default is E_ALL & ~E_NOTICE , all errors except notifications. Servers should be set to at least the default value. And only on main servers a lower value can be used.

error_prepend_string = [""]

Together with » is used with strings, as in forming the value of a form field.

variables_order = EGPCS

Replaces gpc_order . Both versions have been deprecated along with register_globals. It sets the order of various variables: Environment, GET, POST, COOKIE and SERVER (or Built-in). You can change this order. Variables will be overwritten sequentially from left to right, with the rightmost one always “winning”. This means that if you leave the default value and use one name for the environment variable, POST variable and the COOKIE variable, then, in the end, the name will belong to the COOKIE variable.

register_globals = Off

This php ini set option allows you to determine whether EGPCS variables should be registered as global. This method has now been deprecated, and as of PHP 4.2 this flag is set to Off by default. Use superglobal arrays instead.

gpc_order = GPC

This option is deprecated.

magic_quotes_gpc = On

Escapes quotes in GET/POST/COOKIE input. If you use many forms that submit data to themselves or other forms, and display form values, you will need to enable this directive or use the addslashes() functions on string data types.

magic_quotes_runtime = Off

This option escapes quotes in incoming database strings and text lines. Remember that SQL adds slashes to single quotes and apostrophes when storing strings and does not remove them when returning strings. If this option is disabled, you must use the stripslashes() function when outputting any type of string data from a SQL database. If magic_quotes_sybase is set to On , then this setting should be Off .

magic_quotes_sybase = Off

Escapes single quotes in incoming database strings and text strings with Sybase-style single quotes rather than backslashes. If magic_quotes_runtime is set to On , this option should be disabled.

auto-prepend-file=

If this php parameter ini path is specified, PHP should automatically add an include() construct to the beginning of every PHP file. Restrictions on include file paths should be taken into account.

auto-append-file=

If this parameter specifies a path, PHP must automatically insert an include() construct at the end of every PHP file, except when exiting using the exit() function. Restrictions on include file paths should be taken into account.

include_path =

If you set this value, you will only be allowed to include or request files from the specified directories. The include directory is usually located under the root document. This is necessary if you are working in safe mode. Set the parameter to .in to include files from the directory where your script is located. Multiple directories are separated by colons: .:/usr/local/apache/htdocs:/usr/local/lib.

doc_root =

When setting up php ini, if you are using Apache, then in the httpd.conf file is the document root directory for that server or virtual host already set. Set this value here if you are using Safe Mode or only want to allow PHP for part of the site ( for example, in only one subdirectory).

file_uploads =

Activate this flag if you are uploading files using a PHP script.

upload_tmp_dir =

Don't remove comments from this line if you don't understand what !

session.save-handler = files

Except in rare cases, you do not need to change this setting.

ignore_user_abort =

Determines what happens if a site visitor clicks the “Stop” button in their browser. The default is On, which means the script will continue to run until it completes or times out. If you change the value this parameter to Off , the script will be aborted. This option only works in module mode, not in CGI mode.

The course is intended for basic training of site administrators created on "1C-Bitrix: Site Management". After studying the course, you will master the basic methods of system administration, as well as expand your knowledge on the topics studied in the course Content manager.

If you study the course conscientiously, you will learn:

  • manage access to the system, sites, users, user groups;
  • work with system tools;
  • use the system management interface capabilities;
  • work with modules "1C-Bitrix: Site Management" related to optimization and security of the site;
  • Perform work to configure the web system for optimal performance.

If you have to self installation systems or transferring the site to hosting, then without a course Installation and configuration Well Installation and configuration intended for specialists installing "1C-Bitrix: Site Management" or "Bitrix24 in a box".

You can't get by.

Minimum knowledge required to study the course:

  • basic skills computer literacy and skills in working with Windows OS;
  • basic knowledge about WWW and organizing access to the web server;
  • knowledge of the system within the course Content manager We believe that you have already completed this course and know a lot about Bitrix. Therefore, there will be much fewer hints in pop-up windows than in the Content Manager course., so as not to get confused in the interface.

It would be nice to have basic skills in installing and administering *nix systems.

If this course is taken as the basis for offline teaching, then the recommended duration: 3 days (24 academic hours).

Save time and study on the way to work or university? Use the CHM format file, they open on any device. Readers are available in the AppStore and Play Market. CHM files are updated monthly, however, there may be some lag between them and the online version of the course.

Next we will install PHP and configure the web server to use it. Unpack the zip archive (php-5.2.9-Win32.zip) into a folder convenient for you (best in C:\php 5; I will follow in the article that the unpacking was done here, so if you have PHP in elsewhere, then, accordingly, continue to use your directory). Go to this folder and rename the php.ini-dist file to php.ini . Open this file with notepad or any text editor. I believe that standard settings good enough, just need to fix a few directives. First you need to select a location on the disk where server documents will be stored, that is, HTML, PHP files, etc. In the previous article, about installing Apache, we selected the C:\www\htdocs directory. Then we need to correct the directive in the php.ini file

Doc_root =

Doc_root = "C:\www\htdocs"

Also be sure to fix extension_dir with

Extension_dir = "./"

;extension=php_mysql.dll ;extension=php_mysqli.dll

If you plan to use other modules, then uncomment them too. Here is a list of main modules:

;extension=php_bz2.dll - for working with bz2 archives (unpacking/packing using scripts) ;extension=php_curl.dll is a curl extension; using it you can, for example, send a POST request from a script to another script; extension=php_exif.dll - for working with additional information in photo files; extension=php_gd2.dll - graphics library for generating pictures by scripts; extension=php_mbstring.dll is a library for working with multibyte (in Unicode encoding) strings, I strongly advise you to connect, otherwise some CMS may not work; extension=php_msql.dll - for working with the mSQL database; extension=php_mssql.dll - for working with Microsoft SQL Server ;extension=php_mysql.dll - standard MySQL library; For MySQL versions 5 and older, it is better to use the mysqli module; extension=php_mysqli.dll - an improved (MySQL Improved) library for working with MySQL. To work with MySQL5, it is better to use it; extension=php_pdo.dll - this module, as well as all PDO modules, provide a unified interface to many databases. But in particular it is useful because it (as far as I know, according to at least from standard) the only way to Work with SQLite databases 3 ;extension=php_pgsql.dll - for working with the PostgreSQL DBMS; extension=php_sockets.dll - a module for working with sockets from scripts; extension=php_sqlite.dll - for working with the serverless SQLite database. This module supports only version 2 of database files; extension=php_zip.dll - for working with zip archives (the same as for bz2)

You can immediately uncomment several more frequently used modules.

Extension=php_gd2.dll extension=php_mbstring.dll

This completes editing php.ini (don't forget to save the changes!). Now from the C:\php5 directory to the C:\WINNT\System32 directory, copy the libmysql.dll file. It is needed for PHP work with MySQL. Or add the path separated by a semicolon C:\php5 to the path variable - System Properties -> Advanced -> Environment Variables->Path. For the changes to take effect in this case, you need to reboot the computer.

Go to the catalog C:\Program files\Apache2.2\conf and open the httpd.conf file in a text editor.

Let's uncomment the lines added in the previous article:

LoadModule php5_module "c:/php/php5apache2_2.dll" PHPIniDir "C:/WINNT"

That's it, the web server and PHP are configured to work together. Be sure to restart your web server to make PHP work! To do this, use the Apache Monitor (pen icon with green arrow in the system tray)

Most likely, when working with scripts, you will need to change following settings in php.ini:

1. When installing the script, sometimes the following error appears:

Fatal error: Maximum execution time of 30 seconds exceeded in C:\blablabla\file.php on line 360

You can fix this by changing max_execution_time in php.ini

Max_execution_time = 60 ; Maximum execution time of each script, in seconds

to a higher value

Max_execution_time = 180

2. If they load through the script large files, for example, audio and video files, then you need to increase the value of the parameter upload_max_filesize up to your planned file size

; Maximum allowed size for uploaded files. upload_max_filesize = 100M

Hello, my dear readers! I really hope that today’s article will be useful not only to inexperienced network users, but also to experienced users who are confused about the features of various hosting systems.

I want to tell you how to configure php on . In general, the setup process is an adjustment of data in system file php.ini.

Basic Concepts

Рhp.ini– a file document that contains directives (configuration and settings) that determine the behavior of PHP (in particular a specific site).

Interpreter- a program that reads and executes line by line program code. First, it looks for settings in php.ini. And then it goes to the directory itself, specified in the PHP RC text variable.

After manual editing For any php file, it is important not to forget to leave its name unchanged, otherwise the interpreter will not be able to find it!

This information is purely generalized; in practice it should be clearer.

Choose one of the options

Option number 1 for those who use cPanel as an administrative panel.

Look for the “Configuration” section in the menu, where the PHP parameters for hosting are published.

You can even change the PHP version here. There are providers that give almost unlimited opportunities to users for independent adjustment, but there are also those that very strictly control any changes, and you cannot act without their knowledge.

If your hosting allows you to configure PHP, then you are lucky. If not, then move on to option No. 2 - contact technical support for help.

Step-by-step instructions or redefine php.ini in your own way

We find original file settings.htaccess and enter the following data into it:

chmod 755 php5.fcgi

Well, that's all, let's use it.

To this step by step instructions There are some clarifications. When creating the php5.fcgi file, you should use the current unix settings(line break), that is, write information in the file with the /n tag. And if error 500 occurs, you should check the php-error.log file, where you will most likely find the problem.

A couple more settings are important:

disable_functions– allows you to block calls to several functions within safe mode.

Note! The user indicates the list of such functions independently, separated by commas;

memory_limit– allows you to configure the parameters of the maximum amount of memory required to execute scripts.

And finally, I’ll add: in order to look at the settings and find out PHP version, you need to create a php file (the name does not matter), in which you should write the following code:

That's all, go for it! Don't forget to tell your friends on social media. networks about new material you have read, and subscribe to the mailing list of notifications about the revision of the next article. See you!

With respect! Abdullin Ruslan







2024 gtavrl.ru.