IMCAFS

Home

install and configure php 7.3 in debian 9 and nginx

Posted by lipsius at 2020-04-13
all

As Debian 9 knows, only PHP version 7.0 is available by default. If we need a new one, what can we do, for example, PHP version 7.2 or 7.3?

Next we will discuss how to quickly install and configure the package

Original data: Debian 9.11) stretch, program task: install and configure php-fpm 7.3 as mysite.org domain.

It is expected that you have installed and configured the foundation of the program. If not, you can use my article.

1. Install a third-party repository with all the necessary latest versions of PHP:

2. PHP 7.3 is available:

The list will be quite impressive, and we will choose a basic set and install it as necessary.

3. PHP installation:

We found the location of the default configuration file. Please note that this is a version of PHP with CLI (console), and php-fpm file will be different.

Result:

PHP/etc/php/7.3/cli/php.ini。

I ran to the front and said, PHP configuration file / etc PHP / 7.3 FPM / php.ini PHP configuration file / etc / FPM / 7.3/fpm PHP FPM / FPM / FPM / FPM / PHP. D The library profile must have an extension.

Let's examine the PHP FPM Charter:

Set to automatically start the php-fpm server:

4. Setup and php-fpm:

You can use the command to view a list of bullets that are running.

perhaps

In the initial installation, we created a pool - WWW, as I said, in the / etc / PHP 7.3 FPM / pool.dl directory, we created a configuration file / etc / PHP / 7.3 / FPM / pool. D www.conf/

Let's leave his configuration without comment:

Result:

The detailed description of each instruction can be read in the official documents here.

Now we need to connect to the program using php-fpm to handle the requirements for PHP files.

Now let's build a simple PHP website. For example, we have a registered mysit.org domain, You have configured the DNS type of a DNS entry to indicate the IP address of your server, and installed it to make the IP address 195.56.56.10) in reality, you will have a real IP address.

Create a virtual nginx file, which is almost a duplicate of the recommended nginx file. The only thing we added was our instruction list and domain name of IP address (instruction server name, website directory) and php-fpm of path to PHP socket) It corresponds to the socket in the command list from / etc / PHP / 7.3/fpm pool.d/www.conf.:

Then we create a SIMLINK / etc / nginx / sites available / mysite.conf in the / etc / nginx / sites enabled directory

Why SIMLINK? This is a convenient way to quickly start and shut down the virtual server, because in / etc / nginx / nginx.conf, we have written the following instructions:

According to it, any configuration files will be read in the / etc / nginx / sites enabled directory, and there, we are only the simlinki / etc / nginx / sites for the files needed by / etc / nginx / sites available

Establish:

Let's look at:

Now we create a directory for our website. In the / etc / nginx / sites available mysite.conf root command, we point out:

Create a simple PHP file:

Set the owner and permissions of the directory and all files. Please note that it is not easy for us to install the user directory and file owner www data and group www data. The problem is that the program we run and the WWW data user rights, the program needs to access the virtual server directory. Next, our unique php-fpm pool www. the same run represents the user www data) instructs users and groups in / etc / PHP / 7.3/fpm pool.d/www.conf Socket / run PHP / php7.3-fpm.sock has a set of www-data and user owner www-data) instructions listen.owner and listen.group in / etc / PHP / 7.3/fpm/pool.d/www.conf. In principle, a php-fpm library does not need to run their work as a program under the same user. It can create a single user and group, which is the right choice, But the program must be able to read and write to the UNIX socket of the required php-fpm library is an important condition. But we will limit the programs that run in the same user's php-fpm library.

We ask the right and the owner:

After that, check the configuration of the program:

If there are no errors, restart the program configuration:

Presumably, the network screens on our servers are disabled or have no restrictions on external connections. Don't forget to make sure, because Otherwise, connecting to port 80 may be locked and we cannot open our website.

Let's check the Internet screen.)

Result:

All chains are accept, no ban.

All ready to verify the site through a web browser. Open our browser at mysit.org and you should have a standard PHP information page.

If you do not get this page, you must check the server settings or read the error log.

If you use my nginx.conf configuration file, an error log file / var / log / nginx / error.log. If you have your nginx.conf file, please check your command log path:

If the error.u log command is not specified in nginx.conf, you can directly specify the virtual server file in our website, in / etc / nginx / sites available mysite.conf, for example:

After that, don't forget to check and restart the program configuration:

On this basis, nginx + php-fpm installation is completed in the quick meeting.

If you have any questions, or you want me to help you, you can contact me in various ways.