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.
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
2. Install ppa source
apt install software-properties-common python-software-properties
3.
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
4. Update the source
apt update
5. Upgrade source
apt upgrade -y
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
7. Configure Nginx to support PHP extension
vim /etc/nginx/fastcgi_params # 在文档最后添加一下代码: fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
8. Create site files and php test files
1 , mkdir -p /www/test
2. vim /www/test/info.php
Enter the content
<?php phpinfo();
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; } } # 改完之后保存
10. File access permissions
vim /etc/nginx/nginx.conf
Modify a line [user nginx;] to [user www-data;]
11. Restart the Nginx service
/etc/init.d/nginx restart
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!