<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Herman Ceaser</title>
    <description>The latest articles on Forem by Herman Ceaser (@hermanceaser).</description>
    <link>https://forem.com/hermanceaser</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F746185%2F8f9c94df-35d6-4aac-8a6f-960ae08c3e58.jpeg</url>
      <title>Forem: Herman Ceaser</title>
      <link>https://forem.com/hermanceaser</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/hermanceaser"/>
    <language>en</language>
    <item>
      <title>Creating Virtual Hosts and configuring Apache2 to serve from there.</title>
      <dc:creator>Herman Ceaser</dc:creator>
      <pubDate>Fri, 19 May 2023 21:08:41 +0000</pubDate>
      <link>https://forem.com/hermanceaser/creating-virtual-hosts-and-configuring-apache2-to-serve-from-there-11o3</link>
      <guid>https://forem.com/hermanceaser/creating-virtual-hosts-and-configuring-apache2-to-serve-from-there-11o3</guid>
      <description>&lt;p&gt;This is a detailed explanation of how to configure apache2 server on Linux to serve website (Laravel) from virtual host. It aroused due to a problem i faced when converting a laravel 8 app to serve from local host instead of the public folder of laravel.&lt;/p&gt;

&lt;p&gt;After multiple attempts, i managed to hack a clean way to do this without changing the Apache config files: &lt;em&gt;Virtual Hosts is the answer.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Apache2 web server&lt;/li&gt;
&lt;li&gt;PHP installed&lt;/li&gt;
&lt;li&gt;A laravel App.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Steps
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Add domain name for your site to &lt;code&gt;/etc/hosts&lt;/code&gt; file.
&lt;/h3&gt;

&lt;p&gt;I tend to call my local sites &lt;code&gt;.test&lt;/code&gt;  for example &lt;code&gt;demo.test&lt;/code&gt; and Point your site to localhost (127.0.0.1)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```bash
$ sudo nano /etc/hosts

# add the following line to the file
127.0.0.1          demo.test
```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create a virtual host for your site.
&lt;/h3&gt;

&lt;p&gt;Assuming your site is hosted in the &lt;code&gt;/var/www/html/demo&lt;/code&gt; folder which is true in my case; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Change directory to sites-available folder&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; `$ cd /etc/apache2/sites-available`
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Copy the default configuration sites file to a new file, in my case which would be ‘&lt;em&gt;demo.conf’&lt;/em&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`$ sudo cp 000-default.com.conf demo.conf`. 
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add the following lines to newly created configuration file. &lt;code&gt;sudo nano demo.conf&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```bash
&amp;lt;VirtualHost *:80&amp;gt;
    ServerAdmin admin@demo.test
    ServerName demo.test
    ServerAlias www.demo.test
    DocumentRoot /var/www/html/demo
    &amp;lt;Directory /var/www/html/demo&amp;gt;
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    &amp;lt;/Directory&amp;gt;
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    &amp;lt;IfModule mod_dir.c&amp;gt;
        DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
    &amp;lt;/IfModule&amp;gt;
&amp;lt;/VirtualHost&amp;gt;
```
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Note that my site is located at &lt;code&gt;/var/www/html/demo&lt;/code&gt;, and I use that as my &lt;code&gt;DocumentRoot&lt;/code&gt; in the above configuration. Replace it accordingly. Also, the server name &lt;code&gt;demo.test&lt;/code&gt; is the one I added to my &lt;code&gt;/etc/hosts&lt;/code&gt; file&lt;/p&gt;

&lt;p&gt;Just to clarify, in step 2 you will need to create a new file named &lt;code&gt;demo.conf&lt;/code&gt; and add the configuration lines to it. The command you provided &lt;code&gt;$ sudo cp 000-default.com.conf demo.conf&lt;/code&gt; will not work, it should be &lt;code&gt;$ sudo cp 000-default.conf demo.conf&lt;/code&gt; instead&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Enable the Configuration file.
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`a2ensite` enables the specified site within the `apache2` configuration. It creates a symlink within `/etc/apache2/sites-enabled` (not sites-available).

`$ sudo a2ensite demo.conf`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Restart apache2 service
&lt;/h3&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`$ sudo systemctl restart apache2`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Open your project in  Vs code and change the root &lt;code&gt;.htaccess&lt;/code&gt; file to:
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```xml
&amp;lt;IfModule mod_rewrite.c&amp;gt;
    &amp;lt;IfModule mod_negotiation.c&amp;gt;
        Options -MultiViews -Indexes
    &amp;lt;/IfModule&amp;gt;

    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]

&amp;lt;/IfModule&amp;gt;
```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Clear laravel cache using &lt;code&gt;php artisan config:clear&lt;/code&gt; and open your browser and type &lt;code&gt;demo.test&lt;/code&gt;.
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;As the final step in this process, it's important to test your website and ensure everything is functioning as expected.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Open your browser and type in the domain name you specified in the previous steps, in this case "demo.test". If everything has been configured correctly, your website should now be live and accessible through this domain.&lt;/p&gt;

&lt;p&gt;If you encounter any issues or errors, double check each step of the process to ensure everything has been properly executed. Additionally, consult online resources or seek help from a professional if needed.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Good luck with your virtual hosting and Apache configuration!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>virtualhosts</category>
      <category>apache2</category>
      <category>laravel</category>
      <category>linux</category>
    </item>
    <item>
      <title>How to create a custom styled radio button group</title>
      <dc:creator>Herman Ceaser</dc:creator>
      <pubDate>Thu, 16 Jun 2022 13:07:17 +0000</pubDate>
      <link>https://forem.com/hermanceaser/how-to-create-a-custom-styled-radio-button-group-4l4b</link>
      <guid>https://forem.com/hermanceaser/how-to-create-a-custom-styled-radio-button-group-4l4b</guid>
      <description>&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/hermanceaser/embed/MWQxpmr?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
      <category>css</category>
      <category>html</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
