Configuring subdomain in Laragon - apache

I'm using Laragon on Windows 10, and I want to create a subdomain for a new project,
The current structure is:
https://management.test
https://management.test/includes
https://management.test/client
I want to access the client folder using this URL:
https://client.management.test
But I don't want to have https://includes.management.test
I want the configuration to be only on the client folder.
I've tried playing with the Apache sites-enabled file but didn't get the result,
Can anyone share a working example with me or a simple solution to achieve this?
Thank you.

I just figured this out.
This "manual" solution worked for me
I edited drivers\etc\hosts and added my subdomain like
127.0.0.1 sub.project.test
Enable mod_vhost_alias.so in laragon\bin\apache[version]\conf\httpd.conf
Create a new file like {laragon folder}\etc\apache2\sites-enabled\sub.project.test.conf"
Add the following code in the file you just created
define ROOT "C:/laragon/htdocs/project/sub/"
define SITE "sub.project.test"
<VirtualHost *:80>
DocumentRoot ${ROOT}
ServerName ${SITE}
ServerAlias *.${SITE}
<Directory "${ROOT}">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "${ROOT}"
ServerName ${SITE}
ServerAlias *.${SITE}
<Directory "${ROOT}">
AllowOverride All
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile C:/laragon/etc/ssl/laragon.crt
SSLCertificateKeyFile C:/laragon/etc/ssl/laragon.key
</VirtualHost>
Replace ROOT to the path to the subdomain folder
Finally reload apache and visit the subdomain
References :
https://forum.laragon.org/topic/1705/help-subdomain-laragon/3
https://github.com/leokhoa/laragon/issues/90

Related

Make all subdomains point to on single file/folder using ".conf" file

I wanted to redirect all my subdomain to a single file/folder I done the pointing thing before using .conf files in apache but I did it for a specific domain.
this is the conf file that I use for pointing the domain.
listen 80
<VirtualHost *:80>
ServerName subdomain.domain.com
DocumentRoot /var/www/html/project/dist
<Directory /var/www/html/project/dist>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
but what I want is to redirect all the subdomain to redirect to the same project which has some domain for example:-
currently, the upper conf file will redirect to my project folder but what I want is that if I have domain-like
sd1.domain.com
sd2.domain.com
sd3.domain.com
they should also point to the same project directory. but I am not sure how to do it
thx in advance
I solved my problem by doing a slight change into my .conf file here is my new file
listen 80
<VirtualHost *:80>
ServerName domain.com
ServerAlias *.domain.com
DocumentRoot /var/www/html/project/dist
<Directory /var/www/html/project/dist>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
what I did I add the server alias to (*) which let me allow to redirect all my subdomain to single project.

Hosting another website on linux AMAZON EC2 intance running bitnami wordpress

I have an EC2 instance created with Bitnami wordpress, I am trying to host my other website on the same instance website.tld
I followed the steps on this guide
https://docs.bitnami.com/aws/components/apache/#how-to-create-a-virtual-host
Then I went to "/opt/bitnami/apps/wordpress/conf/httpd-vhosts.conf" and changed it to
<VirtualHost *:80>
ServerName mywordpress.com
ServerAlias mywordpress.com
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
</VirtualHost>
<VirtualHost *:80>
ServerName website.tld
ServerAlias www.website.tld
DocumentRoot "/opt/bitnami/apps/website/htdocs"
ErrorLog "logs/website-error_log"
CustomLog "logs/website-access_log" common
</VirtualHost>
<VirtualHost *:443>
ServerName mywordpress.com
ServerAlias www.mywordpress.com
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
SSLEngine on
SSLCertificateFile "/opt/bitnami/apps/wordpress/conf/certs/server.crt"
SSLCertificateKeyFile "/opt/bitnami/apps/wordpress/conf/certs/server.key"
Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
</VirtualHost>
I created the empty folders "/opt/bitnami/apps/website/htdocs" for my new website then added an index.html inside htdocs
Then I restarted the apache server
sudo /opt/bitnami/ctlscript.sh restart apache
mywordpress.com works fine as before, but when i try to open website.tld I get this error
Forbidden
You don't have permission to access / on this server.
Am i doing it wrong? is there any other configurations i missed?
What is more confusing is there are httpd-vhosts.conf files inside the apache2 server and inside each folder in the apps/ folder, I am not sure which of all I should be adding my new domain tag into? Following the bitnami docs I edited the one inside apps/wordrpess/config
I am not a server side guy, is there a UI for the apache server that can help me setup the virtual host?
Thank you in advance.
You have to set the permissions for this directory in apache2.conf/ httpd.conf.
<Directory [your path]>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
And set the permissions with chmod 755

Unexpected virtual host behavior of Drupal sites on Apache

I'm running an Apache server on a CentOS 7 machine.
A month ago I created a new Drupal site (let's call it site1) under /var/www/html/site1.
Visiting http://<server-ip>/site1 yielded site1 correctly.
Today, in order to provide a test environment for a new customer, I had to create a virtual host for a new Drupal site (let's call it site2).
So I created the following vhost rule:
<VirtualHost *:80>
ServerAdmin test#email.com
ServerName site2.dev
DocumentRoot /var/www/html/site2
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
After that I created the site's folder /var/www/html/site2 and installed Drupal. Visiting http://site2.dev yields site2 correctly.
The problem is, if I now visit http://<server-ip>/site1, site2 is shown.
I can't figure out what might be the problem. The two sites are on completely different paths and different databases, so one shouldn't affect the other in my opinion.
Since I literally defined my first vhost today, I was wondering if someone might help me explain the issue. Thanks in advance!
Ok I missunderstood your problem and thought you had 2 domains.
Was your site1 accessed by the IP with no sub directory? In this case :
Change the DocumentRoot to point to /var/www/html then both sites will be accessed by IP/site1 and IP/site2.
If you were allready accessing site1 by the url IP/site1 then you had nothing to change and could access IP/site2 without your new virtualhost wich point only to site2 directory... .
Based on Laurent's answer, this is the configuration I ended up using:
# So all IP only paths continue to work
<VirtualHost *:80>
DocumentRoot /var/www/html/
ServerName 10.10.10.10 # Server's IP
<Directory /var/www/html/>
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
# So site2.dev points to its folder
<VirtualHost *:80>
DocumentRoot /var/www/html/site2
ServerName site2.dev
<Directory /var/www/html/site2>
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>

How I can setup main directory instead web directory to my website in Symfony?

Actually I make a clone of a previous site that I have on symfony. I copy all directory and files on a same server and assign other domain. I can not access to this clone thru the www.domain.com. To view my site I need to do this: wwww.domain.com/proyect/web/app.php.
My question is: What I need to do to load my site on principal directory?.
Change Your config of the webpage, e.g.
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName www.domain.com
ServerAlias domain.com
DocumentRoot /var/www/proyect/web/
<Directory /var/www/proyect/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
and restart apache

Name Based Virtual Hosting url not found

I am trying to set up a website with name based virtual hosting. Now when I visit the website, lukej.us, I get a url not found error. Here is the conf file
<VirtualHost *:80>
ServerName www.lukej.us
ServerAlias lukej.us *.lukej.us
DocumentRoot /vars/www/html/lukej.html
</VirtualHost>
<Directory /vars/www/html/>
AllowOverride All
Order allow,deny
Allow from all
</directory>
DocumentRoot is supposed to be a directory. It is the root folder from which all files will be served. You attempted to specify a file, which then gets interpreted as a directory, since it expects a directory. So its trying to serve from the directory /vars/www/html/lukej.html/ which probably doesn't exist.
You probably wanted something like this:
<VirtualHost *:80>
ServerName www.lukej.us
ServerAlias lukej.us *.lukej.us
DocumentRoot /vars/www/html/
DirectoryIndex lukej.html
</VirtualHost>
This will serve files from the /vars/www/html/ directory, and will show the lukej.html as the index file (when you access the path / from the web).