How to install the php environment under ubuntu: first install Apache and MySQL; then install the new version of php through the command "sudo apt-get install php"; finally install other modules and restart the service.

Recommended: "PHP Video Tutorial"
1. Install Apache
sudo apt-get install apache2
测试:浏览器访问 http://localhost //会出现网页。
查看状态: service apache2 status/start/stop/restart Web目录: /var/www 安装目录: /etc/apache2/ 全局配置: /etc/apache2/apache2.conf 监听端口: /etc/apache2/ports.conf 虚拟主机: /etc/apache2/sites-enabled/000-default.conf
2, Install MySQL, skip it if installed. If it is not installed, click here to install mysql.
3. Install PHP
Check the local php version, run
php -v
to install the latest version of php, use the command
sudo apt-get install php
4. Install other modules
sudo apt-get install libapache2-mod-php sudo apt-get install php7.0-mysql
Restart the service
service apache2 restart service mysql restart
Test whether Apache can parse PHP
vim /var/www/html/phpinfo.php 文件代码为:<?php echo phpinfo();?> 浏览器访问:http://localhost/phpinfo.php //会出现PHP Version网页,如果是云服务器,则将 localhost 改为你云服务器IP
5. Modify permissions
sudo chmod 777 /var /www
6. Install phpMyAdmin
sudo apt-get install phpmyadmin
During installation: (space to enter) select apache2, click Confirm (Enter).
If the following error occurs

sudo mv /var/lib/dpkg/info /var/lib/dpkg/info_old //现将info文件夹更名 sudo mkdir /var/lib/dpkg/info //再新建一个新的info文件夹 sudo apt-get update && apt-get -f install //重新下载 sudo mv /var/lib/dpkg/info/* /var/lib/dpkg/info_old //执行完上一步操作后会在新的info文件夹下生成一些文件,现将这些文件全部移到info_old文件夹下 sudo rm -rf /var/lib/dpkg/info //把自己新建的info文件夹删掉 sudo mv /var/lib/dpkg/info_old /var/lib/dpkg/info //把以前的info文件夹重新改Restart and test
//测试 service php7.0-fpm restart //注意版本 service apache2 restart //测试 http://localhost/phpmyadmin //远程侧修改 localhost
7. Configure Apache
vim /etc/apache2/apache2.conf
末尾添加:
include /etc/phpmyadmin/apache.conf
AddType application/x-httpd-php .php .htm .html
AddDefaultCharset UTF-8
Restart the Apache serviceservice apache2 restartNote: Enter http://localhost/phpmyadmin/ in the browser to enter the console.
The above is the detailed content of How to install php environment under ubuntu. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

Dreamweaver CS6
Visual web development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

WebStorm Mac version
Useful JavaScript development tools

Notepad++7.3.1
Easy-to-use and free code editor







