---
title: "How to deploy static files"
version: 5.0
locale: el
source: https://docs.djangoproject.com/el/5.0/howto/static-files/deployment/
canonical: https://djangodocs.dev/el/5.0/howto/static-files/deployment/
---
# How to deploy static files

> **See also**
>
> Για μια εισαγωγή στη χρήση του module [`django.contrib.staticfiles`](/el/5.0/ref/contrib/staticfiles/#module-django.contrib.staticfiles), δείτε στο άρθρο [Διαχειρίζοντας τα static files (πχ εικόνες, JavaScript, CSS κλπ)](/el/5.0/howto/static-files/).

## Εξυπηρετώντας τα static files στην παραγωγή

The basic outline of putting static files into production consists of two
steps: run the [`collectstatic`](/el/5.0/ref/contrib/staticfiles/#django-admin-collectstatic) command when static files change, then
arrange for the collected static files directory ([`STATIC_ROOT`](/el/5.0/ref/settings/#std-setting-STATIC_ROOT)) to be
moved to the static file server and served. Depending the `staticfiles`
[`STORAGES`](/el/5.0/ref/settings/#std-setting-STORAGES) alias, files may need to be moved to a new location
manually or the [`post_process`](/el/5.0/ref/contrib/staticfiles/#django.contrib.staticfiles.storage.StaticFilesStorage.post_process) method of
the `Storage` class might take care of that.

As with all deployment tasks, the devil’s in the details. Every production
setup will be a bit different, so you’ll need to adapt the basic outline to fit
your needs. Below are a few common patterns that might help.

### Εξυπηρετώντας το site και τα static files σας από τον ίδιο server

Αν θέλετε να εξυπηρετήσετε τα static files σας από τον ίδιο server ο οποίος εξυπηρετεί ήδη το site σας, η διαδικασία θα μοιάζει κάπως έτσι:

- Ανεβάστε τον κώδικα σας στον deployment server.
- Στον server, τρέξτε την εντολή [`collectstatic`](/el/5.0/ref/contrib/staticfiles/#django-admin-collectstatic) για να αντιγραφτούν όλα τα static files μέσα στο φάκελο [`STATIC_ROOT`](/el/5.0/ref/settings/#std-setting-STATIC_ROOT).
- Παραμετροποιήστε τον Web server σας για να εξυπηρετεί τα αρχεία του φακέλου [`STATIC_ROOT`](/el/5.0/ref/settings/#std-setting-STATIC_ROOT) στο URL [`STATIC_URL`](/el/5.0/ref/settings/#std-setting-STATIC_URL). Για παράδειγμα, δείτε [πως μπορείτε να το κάνετε αυτό με τον Apache και το mod\_wsgi](/el/5.0/howto/deployment/wsgi/modwsgi/#serving-files).

You’ll probably want to automate this process, especially if you’ve got
multiple web servers.

### Εξυπηρετώντας τα static files από έναν dedicated server

Most larger Django sites use a separate web server – i.e., one that’s not also
running Django – for serving static files. This server often runs a different
type of web server – faster but less full-featured. Some common choices are:

- [Nginx](https://nginx.org/en/)
- [Μια stripped-down έκδοση του Apache](https://httpd.apache.org/)

Η παραμετροποίηση αυτών των servers είναι εκτός του πεδίου εφαρμογής του παρόντος άρθρου. Συμβουλευτείτε το εγχειρίδιο καθενός από τους παραπάνω servers για λεπτομέρειες και οδηγίες.

Εφόσον ο static file server δεν θα τρέχει το Django, θα χρειαστεί να αλλάξετε τη στρατηγική του deployment για να μοιάζει κάπως έτσι:

- Όταν τα static files αλλάζουν, τρέξτε την εντολή [`collectstatic`](/el/5.0/ref/contrib/staticfiles/#django-admin-collectstatic) τοπικά στον υπολογιστή σας.
- Ανεβάστε τον τοπικό σας φάκελο [`STATIC_ROOT`](/el/5.0/ref/settings/#std-setting-STATIC_ROOT) στον static file server μέσα στο φάκελο όπου εξυπηρετείται. Η εντολή [rsync](https://rsync.samba.org/) είναι μια κοινή λύση για αυτό το βήμα καθώς δεν αντιγράφει κάθε φορά όλο το φάκελο, παρά μόνο τις αλλαγές που έγιναν.

### Εξυπηρετώντας τα static files από μια υπηρεσία cloud ή CDN

Another common tactic is to serve static files from a cloud storage provider
like Amazon’s S3 and/or a CDN (content delivery network). This lets you
ignore the problems of serving static files and can often make for
faster-loading web pages (especially when using a CDN).

Όταν χρησιμοποιείτε αυτές τις υπηρεσίες, η βασική διαδικασία θα μοιάζει λίγο-πολύ με την παραπάνω, εκτός του ότι αντί να χρησιμοποιείτε την εντολή `rsync` για να μεταφέρετε τα static files στον server, θα χρειαστεί να μεταφέρετε τα static files στον πάροχο αποθήκευσης αρχείων ή στο CDN.

There’s any number of ways you might do this, but if the provider has an API,
you can use a [custom file storage backend](/el/5.0/howto/custom-file-storage/)
to integrate the CDN with your Django project. If you’ve written or are using a
3rd party custom storage backend, you can tell [`collectstatic`](/el/5.0/ref/contrib/staticfiles/#django-admin-collectstatic) to use
it by setting `staticfiles` in [`STORAGES`](/el/5.0/ref/settings/#std-setting-STORAGES).

Για παράδειγμα, αν έχετε γράψει ένα σύστημα αποθήκευσης S3 στο αρχείο `myproject.storage.S3Storage`, μπορείτε να το χρησιμοποιήσετε ως εξής:

```
STORAGES = {
    # ...
    "staticfiles": {"BACKEND": "myproject.storage.S3Storage"}
}
```

Once that’s done, all you have to do is run [`collectstatic`](/el/5.0/ref/contrib/staticfiles/#django-admin-collectstatic) and your
static files would be pushed through your storage package up to S3. If you
later needed to switch to a different storage provider, you may only have to
change `staticfiles` in the [`STORAGES`](/el/5.0/ref/settings/#std-setting-STORAGES) setting.

For details on how you’d write one of these backends, see
[How to write a custom storage class](/el/5.0/howto/custom-file-storage/). There are 3rd party apps available that
provide storage backends for many common file storage APIs. A good starting
point is the [overview at djangopackages.org](https://djangopackages.org/grids/g/storage-backends/).

> **Changed in Django 4.2**
>
> The [`STORAGES`](/el/5.0/ref/settings/#std-setting-STORAGES) setting was added.

## Μάθετε περισσότερα

Για πλήρεις λεπτομέρειες πάνω σε όλες τις ρυθμίσεις, εντολές, template tags και άλλα κομμάτια που περιέχονται στο [`django.contrib.staticfiles`](/el/5.0/ref/contrib/staticfiles/#module-django.contrib.staticfiles), δείτε στο άρθρο [αναφορά στα staticfiles](/el/5.0/ref/contrib/staticfiles/).
