1. Ubuntu 22.04
2. PhP 4.0
3. nginx
4. MySQL 5.7
#1. 更新系统
sudo apt update && sudo apt upgrade -y
#2. 安装nginx
sudo apt install nginx -y
apt list -a mysql-server
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php
sudo apt update
安装 PHP 7.4 以及与 Nginx 和 MySQL 相关的一些常用扩展:
sudo apt install php7.4 php7.4-fpm php7.4-mysql php7.4-cli php7.4-fpm php7.4-json php7.4-common php7.4-mbstring php7.4-zip php7.4-gd php7.4-mysqli -y
弃用php并设置自启动
sudo systemctl start php7.4-fpm
sudo systemctl enable php7.4-fpm
说明:
server {
listen 80;
server_name xxx.test.com;
root /project/www;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}