{"id":18,"date":"2017-04-28T09:29:48","date_gmt":"2017-04-28T09:29:48","guid":{"rendered":"https:\/\/hostry.com\/blog\/?p=18"},"modified":"2017-04-28T09:29:48","modified_gmt":"2017-04-28T09:29:48","slug":"how-to-set-up-vps-to-host-websites","status":"publish","type":"post","link":"https:\/\/hostry.com\/blog\/how-to-set-up-vps-to-host-websites\/","title":{"rendered":"How to set up VPS to host websites"},"content":{"rendered":"<p>Setting up a VPS to host a website can be real challenge, because there are so many aspects that should be taken into account: Apache, PHP, Perl\/cgi, and MySQL. The instructions mentioned in this article will be useful for both WordPress and other websites. You will find out how to prevent some common dangers and improve your skills.<\/p>\n<h3>Choose VPS provider<\/h3>\n<p>This is the first, and a very important step. Select a reliable VPS provider with consistent customer support. It should provide basic VPS options at affordable prices. As soon as you have signed up for the service and paid, VPS will be implemented immediately, and you will receive your login information with an email letter.<\/p>\n<h3>SSH to the VPS<\/h3>\n<p>As soon as you get a new VPS system you will need to log in. Use SSH as the user \u201croot\u201d to the provided IP address. Replace ssh root@X.X.X.X with your IP address.<\/p>\n<h3>Change the root password<\/h3>\n<p>Experts recommend changing your root password as soon as possible. You have default initial password in your email, but it\u2019s not secure until you change it. If you do everything correctly, you will receive a message: \u201cpasswd: all authentication tokens updated successfully\u201d.<\/p>\n<h3>Update System Packages<\/h3>\n<p>Now you can go further and update all basic OS packages before installing Apache or PHP. You can use Yum program for that: this default package manager works for Linux and CentOS. Then install web server (Apache), code interpreters (PHP &amp; Perl\/CGI), and Database Server (MySQL) \u2013 all that can be done by one command in Yum.<\/p>\n<h3>Configure Apache<\/h3>\n<p>If you need to host only one website, you can store files in \/var\/www, but there\u2019s no point in wasting the power of VPS. You can simply specify settings of multiple websites on VPS using Apache Virtual Hosts.<\/p>\n<p>Create a user per website and host data for every single website in user\u2019s \u2018public_html\u2019 folder within their home folder. This way, files can be easily managed, and you ensure extra security. If one websites appears to be compromised, others won\u2019t suffer. Perform the following steps:<\/p>\n<ol>\n<li>Create a user called \u2018example\u2019, create their \u2018public_html\u2019 folder, specify permissions for it.<\/li>\n<li>Next you need to edit \u2018\/etc\/httpd\/conf\/httpd.conf\u2019.<\/li>\n<li>Change the X.X.X.X with your server\u2019s IP address and anywhere you see example.com to your domain name. Don\u2019t forget to alter the home directory paths for your username instead of \/home\/example\/. If you need to host another domain, just add another virtual host section.<\/li>\n<li>Clear your local DNS cache or wait a bit after changing DNS A record. You will get a default apache webpage in domain. This will be a default page as you have not placed any files in the public_html directory.<\/li>\n<\/ol>\n<h3>Configure MySQL<\/h3>\n<p>MySQL provides a root account separate from the system and a password that you will get. Launch MySQL and ensure it is set to start automatically. Then connect with MySQL server to specify root password. Create a MySQL user and specify user access to the database for every site that will need a database. Change \u2018example\u2019 and \u2018NEWPASSWORD\u2019 for your username and password (remember it). You will use them when setting up a website.<\/p>\n<p>Additionally, you can enable a firewall on your VPS. IPTables Firewall is available by default on CentOS, but is disabled, so specify firewall rules and enable it. Edit \/etc\/sysconfig\/iptables only when the firewall is stopped. If you haven\u2019t used IPTables before, this file may not exist, so you will need to create it.<\/p>\n<h3>Setup WordPress on a VPS<\/h3>\n<p>When you have configured Apache and MySQL, it\u2019s time to upload your website in public_html directory. You can do with any CMS you use, for instance, WordPress. Installation guides are the same for most common blogging platforms. First, you will need to download the freshest version of CMS from its website and a SFTP client. Unzip the \u2018latest.zip\u2019 and open SFTP client to establish connection between your server and the user created for the website. Change example.com with your website and username.<\/p>\n<p>Select all files in WordPress directory and upload them into the public_html directory. Then open the browser and insert your URL. Follow instructions to finish the setup of WordPress. Now you\u2019re ready to use your website as usually. Repeat these steps for every domain you want to host on the VPS.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Setting up a VPS to host a website can be real challenge, because there are so many aspects that should be taken into account: Apache, PHP, Perl\/cgi, &#8230;<\/p>\n","protected":false},"author":1,"featured_media":19,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[6,5,2],"class_list":["post-18","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-virtual-private-server","tag-mysql","tag-ssh","tag-vps"],"read_time":3,"_links":{"self":[{"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/posts\/18","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/comments?post=18"}],"version-history":[{"count":1,"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/posts\/18\/revisions"}],"predecessor-version":[{"id":20,"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/posts\/18\/revisions\/20"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/media\/19"}],"wp:attachment":[{"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/media?parent=18"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/categories?post=18"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostry.com\/blog\/wp-json\/wp\/v2\/tags?post=18"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}