Install Nginx + PHP-fpm on Ubuntu
  • 2,380 views,
  • 2021-08-25,
  • 上傳者: Kuann Hung,
  •  0
2d22f67b436458034f238a0f0dd00b40.png
步驟
1.
Update apt-get
apt-get update -y && apt-get upgrade -y
2.
Install php-fpm
add-apt-repository ppa:ondrej/nginx-mainline
apt install -y software-properties-common
apt -y update


apt install -y php7.4 php7.4-fpm php7.4-cgi php7.4-mysql php7.4-common php7.4-mbstring php7.4-xml php7.4-curl
3.
Setup Nginx
vi /etc/nginx/sites-available/example.com
 
server {
        listen 80;
        root /var/www/html;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name example.com;

        location / {
                try_files $uri $uri/ =404;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        }

        location ~ /\.ht {
                deny all;
        }
}
 
 ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
 
remove the default configuration
unlink /etc/nginx/sites-enabled/default
4.
Setup folder permission
cd /var/www
chown -R www-data. *
5.
轉換 .htaccess
如果需要轉換的話,可以透過這邊的工具
Facebook 討論區載入中...
資料夾 :
發表時間 :
2021-08-25 22:54:54
觀看數 :
2,380
發表人 :
Kuann Hung
部門 :
老洪的 IT 學習系統
QR Code :