What to do if ubuntu doesn't have php-fpm

藏色散人
Release: 2023-03-17 21:24:01
Original
3533 people have browsed it

Solution for ubuntu without php-fpm: 1. Add the source address of php by executing the "sudo apt-get" command; 2. Check whether there is a php7 package; 3. Through "sudo apt-get install" " command to install PHP; 4. Modify the configuration to listen on port 9000 to handle nginx requests; 5. Start "php7.2-fpm" through "sudo service php7.2-fpm start".

What to do if ubuntu doesn't have php-fpm

The operating environment of this tutorial: ubuntu16.04 system, php7.2 version, DELL G3 computer

ubuntu does not have php-fpm what to do?

ubuntu installs php7.2, php-fpm [ubuntu deployment]

Add source address

Execute three commands to add php Source address, update, installation

sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2
Copy after login

Check if there is a php7 package

sudo apt list | grep php
Copy after login

Install PHP

If nginx uses php, php7.2 is required -fpm, so you need to install

sudo apt-get install php7.2-mysql php7.2-fpm php7.2-curl php7.2-xml php7.2-gd php7.2-mbstring php-memcached php7.2-zip
Copy after login

Configure php-fpm

Modify the configuration to listen to port 9000 to handle nginx requests (this method is generally used on windows),

Another method is to use the sock method under Linux, which will be faster. You don’t need to modify this place. If you really use the path like /run/php/php7.2->fpm.sock, nginx will be used later. Also set it to this format fastcgi_pass unix:/run/php/php7.2-fpm.sock;

Open the /etc/php/7.2/fpm/pool.d/www.conf file and find the following location Comment the first line and add the second line

;listen = /run/php/php7.2-fpm.sock
listen = 127.0.0.1:9000
Copy after login

Modify permissions

chmod 777 /run/php/php7.2-fpm.sock
Copy after login

Open the nginx configuration file /etc/nginx/sites-available/default (you can also add the configuration file elsewhere, This place is the default configuration place)

server {
    listen       80; #监听80端口,接收http请求
    server_name  www.example.com; #就是网站地址
    root /usr/local/etc/nginx/www/your_project; # 准备存放代码工程的路径
    #路由到网站根目录www.example.com时候的处理
    location / {
        index index.php; #跳转到www.example.com/index.php
        autoindex on;
    }  
    #当请求网站下php文件的时候,反向代理到php-fpm
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;#nginx fastcgi进程监听的IP地址和端口
        #fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }
}
Copy after login

Start php7.2-fpm

Sometimes after the installation is completed, you don’t know where to install it. You can use the following command to find it. Next

whereis php-fpm
Copy after login

Start php-fpm

sudo service php7.2-fpm start
Copy after login

Check whether the startup is successful

netstat -lnt | grep 9000
Copy after login

Restart

sudo service php7.2-fpm restart
Copy after login

Recommended study: "PHP Video Tutorial

The above is the detailed content of What to do if ubuntu doesn't have php-fpm. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!