Install Laravel di Alpine Linux Server
Posted on
Install Package yang Dibutuhkan
# apk add vim \
zip \
unzip \
nginx \
php-fpm \
composer \
php-session \
php-tokenizer \
php-xml \
php-dom \
php-xmlwriter \
php-fileinfo
Install Laravel
# cd /var/www/
# composer create-project laravel/laravel mylaravel
# chown -R nginx:nginx mylaravel
Ganti User Proses Pool PHP-FPM
# vim /etc/php81/php-fpm.d/www.conf
;user = nobody
;group = nobody
user = nginx
group = nginx
Bikin Vhost Nginx
# cat /etc/nginx/http.d/laravel.conf
server {
listen 80;
listen [::]:80;
server_name sub.domain.tld;
root /var/www/mylaravel/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
#fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
Restart nginx dan php-fpm
/etc/init.d/php-fpm81 restart
/etc/init.d/nginx restart