I got a laravel project uploaded on a vps, I can't understand how to configure all things to have:
more than one site(laravel project) on the vps; (that is is tricky, because all configuration examples that i've found talking about pointing the root of the server to the public laravel's folder)
having .env and .composer and all the system folders not accesible directly;
wich are the right user and permission to set on the various folders;
In my system ive :
www-data classic apache group with standard privileges;
a non root user, used even to access to mysql and ftp service;
a root user;
I'm using apache2 over ubuntu server 16.04.
According to the Question, I assume that you want to host multiple Laravel Sites on the VPS without messing anything up!Here we go!
Let's Assume that you create the Directories of your site in /var/www directory because it's where your Basic Apache directory will be.Configuration for Site 1:
->Virtual Host for Site 1
<VirtualHost *:80>
DocumentRoot "var/www/site1/public"
ServerName www.site1.com
# Other directives here
</VirtualHost>
-> Directory for Site 1 (Upload your Project here): /var/www/site1
Configuration for Site 2:
->Virtual Host for Site 2
<VirtualHost *:80>
DocumentRoot "var/www/site2/public"
ServerName www.site2.com
# Other directives here
</VirtualHost>
-> Directory for Site 2 (Upload your Project here): /var/www/site2
Here is the Trick! As Laravel have its index.php file in the Public Folder of the Project, Your Domains will point to /var/www/site-x/public folder for the specific site! They will have their own composer and config files in /var/www/site-x/ directories of their own! So, This is how you can host multiple Laravel sites on the same VPS without messing anything up! I am using the same technique! I think it's the only one trick to do so! Let me know if that works!
Related
I have installed a the following Drupal distribution on an Ubuntu virtual machine at /var/www/html.
https://www.drupal.org/project/social
The Composer script installs the project at /var/www/html/project-folder and index.php can be found in /var/www/html/project-folder/html.
Within the file /etc/apache2/sites-available/000-default.conf I have changed the document root to `/var/www/html/project-folder/html'.
Now when I visit the IP Address for the server, it does load the homepage of the PHP based website, but all of the links to other pages are broken, and none of the images can be found.
What is the correct way to add a new site to the Apache web server? Should a VirtualHost be used, or is it better to change the document root?
/etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/project-folder/html
</VirtualHost>
I am trying to setup a multisite for an existing drupal 7 site.
What I've done is
Created a db and imported the existing sites db to use with the new site
Created a folder inside sites directory called mysite.local and copied settings.ph and changed the db configurations with the new one.
Added an entry in /etc/hosts file.
127.0.0.1 mysite.local
Added a file mysite.local.conf in /etc/apache2/sites-available and added the following lines.
DocumentRoot "/var/www/html/drupal/sites/mysite.local"
ServerName mysite.local
ServerAlias mysite.local
`
and enabled the site.
Then added a symbolic link to this directory
ln -s /var/www/html/drupal /var/www/html/drupal/sites/mysite.local
But I am getting 403 while accessig mysite.local.
Can any one help me to figure out what is going wrong here
Even if it is a multisite you need to point it to the root directory. Drupal will figure out based off the domain name where to pull the settings.php from. Change your DocumentRoot back to /var/www/html/drupal
I'm brand new to VPS hosting, so bear with me.
I recently purchased a VPS through inmotion hosting. It has Apache, cPanel and WHM installed out of box. I'm not sure if this is important, but at the top right of the WHM root login it shows: CENTOS 7.3 x86_64
I'm working on developing a system where users can sign up with me and be provided with a sub domain like so: theirUsername.mydomain.com. This will point to a directory on my server where their files will be located. People should also be allowed to have a domain name with my nameservers. I need the system to automatically detect their domain name and point it to where their directory is. It's just like if I were to manually log into cPanel and create an addon domain, but I need this process to be automated. I also need the sub domain to remain and I need to be able to install SSL certs for these domains.
My system would be VERY similar to how Squarespace works.
I've read into mass virtual hosting but cannot for the life of me figure out how to get it working or if it would even be what I'm looking for.
I've tried configuring the virtual hosting but have had no luck. Just for testing purposes I was trying a single domain. Here is my code:
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# SSL name based virtual hosts are not yet supported, therefore no
# NameVirtualHost statement here
Listen 443
</IfModule>
<VirtualHost *:80>
DocumentRoot "/home/username/www/domain.com"
ServerName www.domain.com
ServerAlias domain.com
ErrorLog "/home/username/www/domain.com/error.log"
CustomLog "/home/username/www/domain.com/requests.log" common
</VirtualHost>
The log files are making it to that directory but visiting the domain gives me a "This site can’t be reached" error in Chrome.
Any tips would be greatly appreciated.
Thanks!
First of all, apologies for my English.
I've been reading and reading guides last week a lot hours with no success. I bought a domain + hosting but due bad performance I've got a cheap vps to use as hosting. Currently my setup is:
A domain .com with an A record pointed to my vps ip.
A unmanaged vps with Ubuntu 14.04.2 64 bits to use as hosting for my wordpress with LAMP stack with default setup (I didn't changed any setting on apache, using default virtualhost).
My site works fine but I'm don't know how create subdomains with different directories. For example, my website.com files are in /var/www/html and I'd like to create subdomain.website.com with the files in other directory, let's say /var/www/subdomain.
I checked a lot tutorials and they say to create a virtual server on apache (I use webmin) and then an A record for the subdomain pointing to the server ip.
The problem is that when I enter to subdomain.website.com I see the content from main domain (/var/www/html) and not from "/var/www/subdomain"
I don't want ask you for a full guide step by step, I just need know where I need to start for achieve a subdomain with a different directory because usually I always used hosting services with tools like cpanel to create subdomains pointed to directories in 2 clicks.
I'm a full newbie with Apache/dns management.
Thanks a lot for your time!
Create a virtual host in Apache by creating a file at /etc/apache2/sites-available/subdomain.website.com.conf
In that file, add the following
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName subdomain.website.com
DocumentRoot /var/www/subdomain.website.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Now place your subdomain.website.com files at
/var/www/subdomain.website.com/public_html
Then enable the new virtual host by sudo a2ensite subdomain.website.com
After placing the files, if you get a 403 forbidden error, check for permissions of the DocumentRoot folder.
Refer: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts
My problem is simple and i think the solution also.
I search the forums about 2-3 hours and didnt my answer... -_-' .
I got "space" in a host provider. So they gave me a "www" directory.
I have multiple folders in this directory so it's like:
www--
|
/Folder1
/Folder2
/Folder3 etc.etc.....
Each folder represents a website.
So i want to redirect each website to each folder e.g. :
www.example1.com -> Folder1
www.example2.com -> Folder2
www.example3.com -> Folder3 etc....
-BUT- without showing the subfolder of each ...
So this is NOT a solution: www.example1.com/Folder1
This IS a solution: www.example1.com .
How can i modify my .htaccess file in root WWW ?
Thanks in advance !
This has to be done through your http server configuration (like apache).
VirtualHosts is how you split multiple domains across one computer, and their respective .htaccess configuration will give you protection for your site (username/password).
If you just want to split the computer into multiple hosts, you don't need to use .htaccess.
See the following links
Here are some VirtualHost Configuration Examples
Apache HTTP Server Tutorial
Server Config Files
Excerpt from the "example's" link on "Name-Based Virtual Hosts":
<VirtualHost 172.20.30.50>
DocumentRoot /www/example1
ServerName www.example.com
# Other directives here ...
</VirtualHost>
<VirtualHost 172.20.30.50>
DocumentRoot /www/example2
ServerName www.example.org
# Other directives here ...
</VirtualHost>
The configuration file is usually located in /etc/apache2/apache2.conf which then reads from /etc/apache2/sites-enabled/*.conf which are essentially symbolic links to /etc/apache2/sites-available/*.conf - those files are used with the above code to accomplish the results you describe.
You may also be interested looking into nginx, an alternative to apache2.
.htaccess is not what you're looking for. Instead, read up on Name-based Virtual Host Support. You will need to add some entries to your httpd.conf file to point each domain to the correct folder in the www directory. It should be pretty straight forward.
http://httpd.apache.org/docs/2.2/vhosts/name-based.html