How can I move my old sites from shared host server to VPS? - linux

I'm sure a lot of you guys used to be in the same situation as I am at right now.
Before
I used to owned shared hosting for about 2 years.
I kind of get used to it, whenever I create a new site.
I just need to upload my entire new folder including : index.html , styles, scripts, and other assets via FTP into the root directory to my shared host server. Then, I go to the url of that folder, I will see the site loaded, that's how I normally do it.
Now
I upgrade the way I host my site. I just recently purchased a VPS on Digital Ocean, and run Laravel application on it. Now, the site is way faster, and I have more control.
Unfortunately, I'm not sure what to do with all my old sites that I used to have.
How do move them into my new VPS ?
How do I go to them ? How is that work ?
Should I create a public_html folder or something ?
How can I achieve something like this ?
Any direction on this will be much appreciated !

Depending on your setup (single domain, multi-domain). If you're dealing with a single domain environment you'll just move everything over like normal. If you're in a multi-domain environment you'll need to point all your domains to the new server and setup different apache sites (config files) that point to their respective locations on disk.
In my experience with multi-domain environments and Apache 2.4 it's best to have /var/www/ be your center where you can store your .htpasswd or any other files like that, and a folder named public which has your outward facing websites in their subfolders.
Example:
web1.com would exist in /var/www/public/web1.com/...
web2.com would exist in /var/www/public/web2.com/...
You could alternatively have another public folder, but if you're specifically asking about laravel you'd want to point the apache config to the public directory as if you go any higher people have access to your .env file.
If you have everything in your single domain environment (public_html) and you now have a laravel site at your root you could alias a specific path to act as your "old site" data that points to a different folder than your laravel install.

Related

Cpanel is not giving me option to change the root directory for one of my domains

I need to change the root directory for one of my domains,
But in my cpanel i dont find any options, just hard cores of system, but i have very basic knowledge about systems and servers.
How i can change that directory as easy as possible? I just need to change something because im gonna install laravel, and i want to change the public html to the public of laravel.
I was looking for the file that has the apache config, but it says like "the current config doesnt need to be changed or updated, bacause can be overryde", so i tought in Cpanel maybe i got an option for this.
Thanks, By the way i got an VPS, not shared. Using CENTOS 7.9.
Thanks and good night ^^
In cPanel, you can't change main domain directory/document root. If you want to change the document root, just change the main domain to another/random domain. Then add the domain that you want to change the root directory as addon domain
It's not recommended overriding Apache config. It's may break your system. WHM/cPanel exists to manage domains without a system admin knowledge
Do you try change this using console in Centos?
maybe will be better using console and open the file that contain the directory root

Creating .htpasswd file outside webpage files

I'm working with a webpage that uses a content management system. The webpage belongs my university. We want create a private file with .htaccess and htpasswd.
The problem is I can't figure out how to place the htpasswd file outside the webpage files because I don't have access to the server machine. I need to do that because someone told me it is unsafe to place it within the webpage files. Any ideas?
If you have a shared hosting account for your website, I suggest you connect to it through FTP. In Directadmin as example, you have to put the file in your public_html folder (which is the root directory of your site).
In case you want to put it outside of the root (as you were asking), place it 1 directory lower (so not in the public_html but before that), and then link it to it.
In case you lack the permissions to do so, contact your hosting provider, cause he should be able to do it for you (and ask him for the direct path).

Possible to use Virtual Path to an external disk on Plesk Managed Windows server?

After getting a helpful answer from this post I want to store media on a separate harddrive on the windows server. Is it possible to make those files available via http?
I soon discovered that Plesk does not allow me to create a virtual path that points to a location outside of my website root. I want the virtual path to point to a folder on D: (an extra disk, not the same as the website root directory)
Only two possible solutions I could think of, although I can't find them any where.
1) Maybe plesk has an advanced configuration file that prevents it from overwriting certain things in IIS when it runs its maintenance jobs or updates, specifically the Virtual Path I created directly in IIS outside of plesk.
2) Maybe there is a third party component available that offers this functionality, setting virtual paths outside of web root or the config file I just mentioned in #1.
Any other solutions are also welcome.
cd "%plesk_vhosts%\"domain.tld\httpdocs
mklink /J point c:\outOfSpace
Now provide permissions to "psacln" group to c:\outOfSpace and that's it.
Also you can create "point" not in httpdocs but in web space root and than from Plesk create Virtual Folder inside /httpdocs with needed access permissions.
There is issue that your custom permissions may lost after Plesk upgrade, this KB article describe how your can avoid it kb.sp.parallels.com/111194

Linode + Debian + Apache, a private folder for development work

I'm very new to Linux, please bear with me.
I have a linode with a LAMP stack running and I managed to configure my main site and a couple of subdomains and it's working great.
However, I want to have a dir called "dev" where I can put projects that I'm still working on. I need to be able to access this folder from my browser's address bar, and I don't want it to be through a DNS, but directly from my server's IP. For example:
http://218.42.42.42/dev/someproject
Since the document root is set to /var/www, placing the "dev" folder there isn't really an option - I want it to be in my ~ folder, for easier backups.
So what's the best way to make this work? A redirect, or should I move my doc root to the "dev" folder?
Thanks!
First, this would probably be more appropriate for Serverfault. With that in mind...
If I had to keep my dev environment in my home folder, I'd create a symlink in /var/www that ties to the dev folder.
As far as securing it, I don't know if this is still a recommended or viable way of handling secure access, but it seems like http://www.codinglogs.com/blog/server-management/vps-setup-guide/nginx-password-protect-web-directory might be the way to go as long as you feel secure using a username/password combination. Another valid answer (also on stackoverflow) would be password protect /backoffice folder in nginx.
If you want something more secure, the next step would probably firewall rules.

How do you do A/B switching in a web app? (for deploying updates)

I currently have a mysite.com (A) which points to /public_html/ and a dev.mysite.com (B) which I created a /dev_html/ for that. I cloned the site but now I need a way of switching between them without having to copy all the files from one dir to another and without bringing the site down. I just want to switch the live site to B and then work on A, and when I finish, switch the live site to A and work on B. Is there a simple way? I'm using cPanel X and cPanel 11 (WHM VPS). Also, both can interact with the same database so that's not an issue as I'm not changing any database structure. Only the php/js/img files need to switch.
Not sure if you have options to map domains, sub domains to folders in CPANEL as Im not a huge cpanel fan. The hosting company that I use allows mapping folders to domains and subdomains that I create so I have two folders too.
One of my folders in v1 and other folder is v2.
I point the live domain to v1 when Im working on enhancements on the version in v2 and point the domain to v2 when I have to do enhancements on v1 (but when switch happens I have to copy the files anyway- the advantage is that the beta website throws errors while Im copying over and not the main website)
vhost file
Edit your vhosts file to point to the other directory.
Currently you will have a container that states that the site files are located at public_html
Change that to dev_html and run the following command to see if it all went ok.
apache configtest
If there are no errors, run
apache restart

Resources