開發與維運

Debian9 安裝 PHP7.4 Nginx MySQL8.0

步驟1,必須update:

apt update;

步驟2,安裝sury:

wget -q -O /etc/apt/trusted.gpg.d/php.gpg https://mirror.xtom.com.hk/sury/php/apt.gpg;

wget -q -O /etc/apt/trusted.gpg.d/nginx.gpg https://mirror.xtom.com.hk/sury/nginx/apt.gpg;

步驟3,安裝dirmngr、lsb-release、apt-transport-https,如果沒有安裝lsb-release,在後面用到的命令裡,$(lsb_release -sc) 無法識別出Debian的系統名稱。

apt -y install dirmngr lsb-release apt-transport-https;

步驟4,添加sury軟件源:

sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list';

sh -c 'echo "deb https://packages.sury.org/nginx/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/nginx.list';

步驟5,update:

apt update;

步驟6,查看軟件版本號:

apt-cache show php | grep -i version;

apt-cache show nginx | grep -i version;

步驟7,安裝指定版本:

apt -y install package-name=version

apt -y install php7.4-fpm;

apt -y install php7.4-common php7.4-json php7.4-gd php7.4-cli php7.4-mbstring php7.4-xml php7.4-curl php7.4-opcache php7.4-mysql php7.4-bcmath php7.4-zip

apt -y install nginx=1.18.0-4+0~20200707.11+debian9~1.gbp4f5835

步驟8,重啟服務:

systemctl restart php7.4-fpm;

systemctl restart nginx;

步驟9,安裝MySQL:

第一步 添加mysql軟件源

下載mysql的配置文件:

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

或者

wget https://repo.mysql.com/mysql-apt-config_0.8.16-1_all.deb

安裝下載好的deb軟件包:

dpkg -i mysql-apt-config*

安裝完成後更新apt:

apt update

第二步 安裝mysql

apt -y install mysql-server

安裝完成後檢查是否安裝成功:

systemctl status mysql

安全加固:

mysql_secure_installation

版本查看:

mysqladmin -u root -p version

第三步 啟動mysql

mysql -u root -p

Leave a Reply

Your email address will not be published. Required fields are marked *