vi /etc/nginx/sites-available/default
server{}
中加入:
location ~ ^/~(.+?)(/.*)?$ {
alias /home/$1/public_html$2;
index index.html index.htm index.php;
autoindex on;
}
adduser somebody
mkdir /home/somebody/public_html
vi /home/somebody/public_html/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
網頁已開通!
</body>
</html>
vi /etc/nginx/sites-available/default
server{}
中的location ~ ^/~(.+?)(/.*)?$ {
上方加入:
location ~* ^/~(.+?)(/.*\.php)$ {
alias /home/$1/public_html$2;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
location ~ ^/~(.+?)(/.*)?$ {
alias /home/$1/public_html$2;
index index.html index.htm index.php;
autoindex on;
}
systemctl restart nginx