How to install php5.6 on ubuntu

藏色散人
Release: 2023-03-08 18:44:02
Original
4841 people have browsed it

How to install php5.6 on ubuntu: first install the ppa source; then update the source through the "apt update" command; then install php5.6 through the install command; and finally configure Nginx to support PHP extensions.

How to install php5.6 on ubuntu

The operating environment of this article: ubuntu 16.04 system, PHP5.6 version, DELL G3 computer

Ubuntu installation php5.6

1.

apt install python-software-properties -y
Copy after login

2. Install ppa source

 apt install software-properties-common python-software-properties
Copy after login

3.

LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
Copy after login

4. Update the source

apt update
Copy after login

5. Upgrade source

apt upgrade -y
Copy after login

6. Install php

apt install php5.6 php5.6-fpm php5.6-mysql php5.6-gd php5.6-mbstring php5.6-curl php5.6-soap php5.6-redis php5.6-xml php5.6-apcu php5.6-mcrypt -y
Copy after login

7. Configure Nginx to support PHP extension

vim /etc/nginx/fastcgi_params 
    # 在文档最后添加一下代码:
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
Copy after login

8. Create site files and php test files

1 , mkdir -p /www/test

2. vim /www/test/info.php

Enter the content

   <?php phpinfo();
Copy after login

9. Modify the site configuration file

vim /etc/nginx/conf.d/default.conf 
    # 清空文档,把以下内容复制到文档中:
    server {
        listen  80;
        # server_name  localhost;
        root  /www/test;
        index  index.php index.html index.htm;
        location ~ \.php$ {
            fastcgi_pass  unix:/var/run/php/php5.6-fpm.sock;
            include  fastcgi_params;
        }
            location ~ /\.ht {
            deny  all;
        }
    }
    # 改完之后保存
Copy after login

10. File access permissions

 vim /etc/nginx/nginx.conf
Copy after login

Modify a line [user nginx;] to [user www-data;]

11. Restart the Nginx service

 /etc/init.d/nginx restart
Copy after login

12. External network access: http://host IP/info.php

13. If the phpinfo content is displayed, it will be successful, otherwise it will fail.

Recommended learning: " PHP video tutorial

The above is the detailed content of How to install php5.6 on ubuntu. 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