Skip to content

Instantly share code, notes, and snippets.

@GussRw
Last active February 1, 2022 14:56
Show Gist options
  • Save GussRw/9e8af5a04c21bf1a3e7fda8d34cc1c3e to your computer and use it in GitHub Desktop.
Save GussRw/9e8af5a04c21bf1a3e7fda8d34cc1c3e to your computer and use it in GitHub Desktop.

cd /etc/apache2/sites-available

cp 000-default.conf project-name.conf

nano project-name.conf

<VirtualHost *:80>
        ServerAdmin soporte@trailock.mx
        DocumentRoot /var/www/project/public
        ServerName project.mx
        ServerAlias project.mx
        DirectoryIndex index.php

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


        <Directory "/var/www/project/public">
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
                Require all granted
        </Directory>

        RewriteEngine on
        RewriteCond %{SERVER_NAME} =www.project.mx [OR]
        RewriteCond %{SERVER_NAME} =project.mx
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>
<IfModule mod_ssl.c>
        <VirtualHost *:443>
                ServerAdmin supporte@trailock.mx
                ServerName project.mx
                ServerAlias project.mx
                DocumentRoot /var/www/project/public
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined

                <Directory "/var/www/project/public">
                        Options Indexes FollowSymLinks MultiViews
                        AllowOverride All
                        Order allow,deny
                        allow from all
                        Require all granted
                </Directory>

                SSLEngine on
                SSLCertificateKeyFile /etc/apache2/ssl-certificate/private-key.pem
                SSLCertificateFile /etc/apache2/ssl-certificate/csr.pem
                SSLCertificateChainFile /etc/apache2/ssl-certificate/bundle.crt
        </VirtualHost>
</IfModule>

a2ensite project-name sudo service apache2 restart

cd /path/to/project/ sudo chown -R www-data storage public

If your application is on another port, you must add the following line to ports.conf

    Listen 80
    Listen 8085
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment