1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Nginx で Laravel を動かす

Last updated at Posted at 2021-02-15

まず、
/var/www/html 以下に Laravel のプロジェクトを作成します。

例えば
/var/www/html/helloworld というプロジェクトだとすると、
/var/www/html/helloworld/public を Nginx の root にします。

/etc/nginx/sites-available/default
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html/helloworld/public;
        index index.html index.htm index.php;

        server_name _;

        location / {
                try_files $uri $uri/ /index.php?$query_string;
        }

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

}

設定ファイルが正しいか確認

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Nginx の再起動

sudo systemctl restart nginx

次のバージョンで確認しました。

$ nginx -v
nginx version: nginx/1.18.0 (Ubuntu)
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?