Start building your config

I have put this together for those like me who have setup their own webhost on a private server or VPS.

My aim is to help people setting up their Laravel Applications on there own server (but this will translate to other frameworks).

I will be adding more to this generator as time goes on, so please sign up to the newsletter to keep informed.

SSL Certificate & HTACCESS Information

SSL Information

There is a few things which need to happen in order for your certificates and apache configuration to work.


Enable SSL

Seems like a simple one, but when i first set my server up i forgot.... and spent a few hours trying to figure out why it wasn't working, To enable SSL on your server simply type sudo a2enmod rewrite in your terminal and your done.


Enable mod_rewrite

To enable mod_rewrite on your server simply type sudo a2enmod rewrite in your terminal and your done.


Certificate Location

The SSL Certificates can be stored anywhere on the system, however you will need to ensure the right user priviges are supplied so Apache2 can get to them. As standard the location for certificates (On ubuntu) is '/usr/local/share/ca-certificates/', and id recommend using this location for ease.


Make your Apache2 config

If you have followed the information in this tool you should have no issues at all. Create the Apache2 config file by running the following command in your servers terminal sudo nano /etc/apache2/sites-enabled/raspada-blog.co.uk.conf, Substituting raspada-blog.co.uk for your website URL


Enable your site config

If you have followed the information in this tool you should have no issues at all. Create the Apache2 config file by running the following command in your servers terminal sudo nano /etc/apache2/sites-enabled/raspada-blog.co.uk.conf, Substituting raspada-blog.co.uk for your website URL. Paste the generated config into this file and exit out of nano by pressing "CTRL-X", Selecting Yes to Save and Enter to confirm.
Now type a2ensite raspada-blog.co.uk and then sudo systemctl restart apache2. After that you should be able to navigate to your website.


.htaccess Information

You only need to Replace the .htaccess in laravel if your adding an SSL Certificate. If your not, leave it alone :)

In your Laravel Project you will find the HTACCESS file under /public/.htaccess

Replace the existing Laravel .htaccess content with the information below. this will make sure the connections are all correct.


<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>


            

                
            <VirtualHost *:80>

                ServerAdmin 
                ServerName 
                ServerAlias 

                DocumentRoot 

            <Directory >

                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all

            </Directory>

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

            </VirtualHost>


            
        

Apache Conf

Built With Laravel, Tailwind, Livewire and of course... Love. Please follow me on Twitter   Skino2020  or if you fancy it buy me a coffee  here