Deployment Laraknife Projekt: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(→nginx) |
|||
Zeile 57: | Zeile 57: | ||
server { | server { | ||
listen 443 ssl http2; | listen 443 ssl http2; | ||
listen [::]: | listen [::]:443 ssl http2; | ||
server_name $DOMAIN; | server_name $DOMAIN; | ||
root /srv/www/$DOMAIN/public; | root /srv/www/$DOMAIN/public; |
Version vom 19. November 2024, 13:47 Uhr
Links
Zielsetzung
Ein Projekt ist lokal erstellt und soll jetzt auf einen Server migriert werden.
Auf dem lokalen System
- Datenbankinhalt speichern:
PROJ=taskx
mkdir -p resources/db
cd resources/db
sudo mysqldump lrv$PROJ | gzip > lrv$PROJ.sql.gz
Auf dem Server
- Als User root:
PROJ=taskx
REPO=$PROJ.git
cd /srv/www
git config --global --add safe.directory /home/git/repo/$REPO
git clone /home/git/repo/$REPO
sudo chown -R www-data:www-data $PROJ
cd $PROJ
sudo -u www-data git checkout main
dbtool create-db-and-user lrv$PROJ lrv$PROJ TopSecret
DOMAIN=$PROJ.hamatoma.de
DB=lrv$PROJ
PW=TopSecret
dbtool create-webapp-configuration $DOMAIN $(pwd) $DB $DB $PW
gzip -d resources/db/lrv$PROJ.sql.gz | mysql -u root lrv$PROJ
mkdir -pv storage/logs storage/framework/{cache,sessions,views} storage/app/public
chown -R www-data:www-data storage
cp .env.example .env
# .env anpassen!
chown www-data .env
sudo -u www-data php artisan key:generate
sudo -u www-data php artisan config:cache
nginx
PROJ=oo4f
DOMAIN=$PROJ.hamatoma.de
cd /etc/nginx/sites-available
cat <<EOS >$DOMAIN
server{
listen 80;
server_name $DOMAIN;
include snippets/letsencrypt.conf;
root /srv/www/$DOMAIN;
location / {
return 301 https://\$server_name\$request_uri; # enforce https
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name $DOMAIN;
root /srv/www/$DOMAIN/public;
ssl_certificate /etc/letsencrypt/live/latest/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/latest/privkey.pem;
#ssl_certificate /etc/ssl/certs/$DOMAIN.pem;
#ssl_certificate_key /etc/ssl/private/$DOMAIN.key;
client_max_body_size 1G;
access_log /var/log/nginx/a_$PROJ.log;
error_log /var/log/nginx/e_$PROJ.log;
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.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME \$realpath_root\$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
EOS
cd ../sites-enabled
ln -sv ../sites-available/$DOMAIN .