HOW TO INSTALL APACHE, PHP 7, AND PHP

      114

When using PHP-FPM, a dedicated service designed for processing PHP scripts handles the task.

Bạn đang xem: How to install apache, php 7, and php

Sometimes, PHP FPM may not work as we expect due lớn the bad configuration in web hệ thống settings.

At thietkewebhcm.com.vn, we often get requests from our customers to fix PHP FPM errors while installing it on centos hệ thống as part of our vps Management Services.

Today, we’ll see how our tư vấn Engineers PHP FPM install on Centos and fix related errors.

How lớn install PHP-FPM on CentOS

PHP-FPM is easier khổng lồ use & configure. Also, it is more efficient than FastCGI. Again, it needs fewer server resources than other PHP handlers lượt thích CGI, DSO.

Let’s see how our tư vấn Engineers configure PHP-FPM on CentOS 7 with Nginx.

1. Initially, we log into the vps as a root user.

2. Then, we turn on EPEL repo & Remi repo by following commands.

yum install epel-releaseyum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm 3. Also, we Install yum-utils packages too:

yum install yum-utils 4. Then, we enable Remi repo by using the following commands.

yum-config-manager --enable remi-php72yum update 6. Again, we installed PHP7.2 on the vps with the following commands.

yum install php72 7. After that, we installed php72-php-fpm along with commonly used modules:

yum install php72-php-fpm php72-php-gd php72-php-json php72-php-mbstring php72-php-mysqlnd php72-php-xml php72-php-xmlrpc php72-php-opcache 8. Next, we turn on PHP fpm for Nginx.

systemctl enable php72-php-fpm.service 9. At last, we start, stop and restart the service.

systemctl start php72-php-fpm.servicesystemctl stop php72-php-fpm.servicesystemctl restart php72-php-fpm.service

Moreover, the customers can customize PHP FPM parameters through a control panel like cPanel. Cpanel has a feature like MultiPHP manager that allows changing the PHP FPM parameters with few clicks. This interface looks like.

*

How we fixed errors after installing PHP fpm on CentOS

From our experience in managing server, we’ve seen that customers facing problems after installing PHP fpm on Centos. Let’s take a closer look at how our tư vấn Engineers fixed the problems.

Wrong User and Group names

Recently one of our customers had a problem with his php-fpm. His php-fpm didn’t work after installing it on the server. He got an internal hệ thống error (500) Nginx.

Xem thêm: Tài Liệu Học C# Dành Cho Người Mới Bắt Đầu, Tài Liệu Học Tập Ngôn Ngữ Lập Trình C

Then our support Engineers took the following steps to lớn solve the issue.

1. We logged into the hệ thống as a root user.

2. Then, we used info,php tệp tin to kiểm tra whether the php-fpm enabled or not on the server.

3. It was enabled but the settings in the Nginx configuration was wrong.

We used the following command to find out hệ thống user & group names. We found it was set to lớn apache instead of nginx.

egrep "^(user|group)" /etc/nginx/nginx.conf 4. Then, we edited vi /etc/php-fpm.d/www.conf. And, phối user & group to lớn nginx:

user = nginxgroup = nginx 5. Next, we saved the file. Restarted php-fpm service.

systemctl restart php72-php-fpm.service That fixed the issue.

Bad configuration settings

Often improper settings in the configuration tệp tin create problem after installing PHP FPM on the server. One of our customers got an Nginx 502 Bad Gateway Error on his website.

This is how our tư vấn Engineers fixed it.

1. Initially, we checked the error log /var/log/nginx/error.log. And, we found the following entry.

3. So, we updated the Nginx config file, /etc/nginx/conf.d/default.conf and edited the following lines too.

try_files $uri =404;fastcgi_pass unix:/var/run/php/php7.0-fpm.sockfastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params; 4. Finally, we restarted the Nginx server.

systemctl restart nginx This is how we fixed the issue.

Conclusion

In short, While installing PHP FPM on centos, customers may face errors due khổng lồ the bad configuration in web server settings. Today, we saw how our tư vấn Engineers installed PHP FPM on CentOS fixed related errors.

hotlive |

Hi88