点击这里给我发消息QQ客服

Ubuntu 20.04 server LTS LNMP mysql5.7 php7.4

云之渝 2020-09-17

## Ubuntu 20.04 LTS
## Nginx 1.18.0
## Mysql 5.7
## PHP 7.4
## Author ddkxiaobai
## Date 2020.8.26



备份/etc/apt/sources.list
#备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
/etc/apt/sources.list文件前面添加如下条目
#添加阿里源
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

 

apt update

apt upgrade

 

查看nginx

sudo apt list nginx

install001.png 

 

sudo apt install nginx

install002.png 

 

显示自动启动项

sudo systemctl list-unit-files


 install003.png

 

 

 关闭系统防火墙

sudo systemctl disable ufw

sudo service ufw stop


 install004.png

 

 

安装mysql5.7

删除mysql 相关信息

 

sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*

 

sudo rm -rf /etc/mysql /var/lib/mysql

 

sudo apt-get autoremove

sudo apt-get autoclean

 

 

wget https://dev.mysql.com/get/mysql-apt-config_0.8.15-1_all.deb

sudo dpkg -i mysql-apt-config_0.8.15-1_all.deb

 

sudo dpkg-reconfigure mysql-apt-config

 

sudo apt update

 install006.png

问题


 install005.png

 

 

 

sudo apt-key list

sudo apt-key del A4A9 4068 76FC BD3C 4567  70C8 8C71 8D3B 5072 E1F5

 

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 8C718D3B5072E1F5

 

sudo apt update

sudo apt upgrade

 

 

 

 

sudo apt-cache policy mysql-server


 install008.png

 

sudo mkdir -p /etc/mysql/conf.d

 

 

 

 

 

 

sudo apt install -f mysql-client=5.7.31-1ubuntu16.04

 

install009.png 

 install010.png

sudo apt install -f mysql-community-server=5.7.31-1ubuntu16.04

install011.png 

 

sudo apt install -f mysql-server=5.7.31-1ubuntu16.04


 install012.png

 

 

sudo service mysql start

 

mysql -uroot -p    登陆mysql


 install013.png

 

 

安装php

sudo apt list php

install014.png 

 

 

 

sudo apt install php php-fpm php-curl php-gd php-xml php-mbstring  php-xmlrpc php-zip php-soap php-intl

 

 

systemctl status php7.4-fpm


 install015.png

 

 

默认安装会安装apache2

 

查看systemctl list-unti-files  apache2

停止apache2

systemctl stop apache2

 

修改nginx 支持php

/etc/nginx/sites-enabled/default


 install016.png

 

重启php-fpm

systemctl restart php7.4-fpm

 

重启nginx

systemctl restart nginx

 

根目录添加php测试页

cd /var/www/html

touch index.php

<?php

phpinfo();

?>

 

http://x.x.x.x/index.php

 

 install017.png