Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ChristopherSFSD's avatar

How to deploy for production on Apple Silicon?

I have built great things in Laravel. In the past I've hosted locally on Mac with built-in PHP and Apache, etc.

I need to migrate my production Laravel website to be hosted on Apple Silicon and ideal using Docker. I have had no probably getting Laravel Sail to work but as I understand it's not meant for production. Everything else I seem to find online assumes that using Docker on Apple Silicon is only for development.

Assuming my server is behind a firewall and only ports 80 and 443 are directed to my Apple Silicon machine running my production website using Sail, do I have anything to worry about? If I shouldn't be using Sail to serve up the public website (and it sounds like I should not), are there any great articles or tutorials out there that teach someone how to run a production site on Apple Silicon using Docker and Laravel + how to use a real-world SSL certificate?

0 likes
2 replies
LaryAI's avatar
Level 58

To deploy a Laravel application for production on Apple Silicon using Docker, you can follow these steps:

  1. Build a Docker image for your Laravel application using a Dockerfile. Here's an example Dockerfile:
FROM php:8.0-apache

RUN apt-get update && \
    apt-get install -y libpq-dev && \
    docker-php-ext-install pdo pdo_pgsql && \
    a2enmod rewrite

COPY . /var/www/html

RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache

CMD ["apache2-foreground"]

This Dockerfile uses the official PHP 8.0 Apache image, installs the PostgreSQL driver for PHP, enables the Apache rewrite module, copies the Laravel application code to the container, and sets the ownership of the storage and cache directories to the Apache user.

  1. Build the Docker image using the following command:
docker build -t my-laravel-app .

This command will build the Docker image and tag it with the name "my-laravel-app".

  1. Run the Docker container using the following command:
docker run -d -p 80:80 -p 443:443 --name my-laravel-container my-laravel-app

This command will run the Docker container in detached mode, map ports 80 and 443 to the host machine, and name the container "my-laravel-container".

  1. Configure SSL for your Laravel application. You can use a real-world SSL certificate by copying the certificate and key files to the container and configuring Apache to use them. Here's an example Dockerfile that copies the certificate and key files and configures Apache:
FROM php:8.0-apache

RUN apt-get update && \
    apt-get install -y libpq-dev && \
    docker-php-ext-install pdo pdo_pgsql && \
    a2enmod rewrite ssl

COPY . /var/www/html

RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache

COPY ssl.crt /etc/apache2/ssl.crt
COPY ssl.key /etc/apache2/ssl.key

RUN sed -i 's/\/etc\/ssl\/certs\/ssl-cert-snakeoil.pem/\/etc\/apache2\/ssl.crt/g' /etc/apache2/sites-available/default-ssl.conf && \
    sed -i 's/\/etc\/ssl\/private\/ssl-cert-snakeoil.key/\/etc\/apache2\/ssl.key/g' /etc/apache2/sites-available/default-ssl.conf && \
    a2ensite default-ssl.conf

CMD ["apache2-foreground"]

This Dockerfile is similar to the previous one, but it also installs the Apache SSL module, copies the SSL certificate and key files to the container, and configures Apache to use them.

  1. Build the Docker image and run the Docker container as described in steps 2 and 3, but use the new Dockerfile that includes SSL configuration.

With these steps, you should be able to deploy your Laravel application for production on Apple Silicon using Docker. Note that you may need to adjust the Dockerfile and Apache configuration to fit your specific needs.

Please or to participate in this conversation.