by

Subhomay

09 Nov 2016, 02:41 pm

about the author

Website: https://designs.codes
About Subhomay

How to Guide: Create Google Cloud Platform Shared Hosting Interface

Create Google Cloud Platform Shared Hosting

Cloud computing is getting big. Like really big. AWS has become the biggest cash cow for Amazon and other biggies right from Google to Microsoft are trying to catch up. Having been with Amazon for most of our cloud requirements for more than last two years, we thought of trying out Google Cloud Platform. While use cases and features of Google Cloud Platform are seemingly endless and could be discussed for days, here we will discuss specifically about how to create Google Cloud Platform shared hosting interface step-by-step.

While it’s not difficult to create Google Cloud Platform shared hosting interface, we hope this will be a handy guide to get up and running faster. This will be specially helpful for web agencies who provide integrated solution to their clients including hosting apart from design, development and marketing services.  To be able to create Google Cloud Platform shared hosting interface will help you provide better solution to the price sensitive SME sector while having full control and access to resolve server issues real time.

To createGoogle Cloud Platform shared hosting interface first login to your Google Cloud Console. Create a desirable instance with proper configuration. Choice of instances should be based on calculated and average usage. Choose CentOS 7 as boot OS.

Now install LAMP by logging in to the instance via ssh.

1. Install HTTPD

yum upgrade -y

yum install httpd -y

systemctl start httpd.service

Enable auto start of HTTPD at system reboot

systemctl enable httpd.service

2. Install MySQL 5.7

wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

yum localinstall mysql57-community-release-el7-7.noarch.rpm

yum install mysql-community-server -y

systemctl start mysqld.service

systemclt enable mysqld.service

Get a temporary password to setup MySQL

grep ‘temporary password’ /var/log/mysqld.log

mysql_secure_installation

Create your MySQL password and choose the setup options as your requirement are. In our case it’s: Y|N|Y|Y

3. Install PHP

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum -y install php55w php55w-opcache

yum -y install php55w-xml php55w-mcrypt php55w-gd php55w-devel php55w-mysql php55w-intl php55w-mbstring

echo ‘<?php phpinfo(); ?>’  >> /var/www/html/info.php

systemctl restart httpd.service

Check on browser with IP/info.php to check the installation. Here, IP will be the IP that you get from Google Cloud Computing.

4. Install PHPMYADMIN

rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm

rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

yum –enablerepo=remi install phpmyadmin -y

Edit your phpMyAdmin.conf and config.inc.php, refer here for more info on how to do it.

Check your phpMyAdmin installation in your browser and login with your MySQL login credentials.

IP/phpMyAdmin

ID – root

Password – As set by you while setting up MySQL.

To increase the upload file size if required in PHPMYADMIN

Find and change the following attributes in your php.ini file.

post_max_size = 8M

upload_max_filesize = 2M

max_execution_time = 30

max_input_time = 60

memory_limit = 8M

Here sizes are mentioned in MB and time in Seconds so you can change it as based on your requirement.

systemctl restart httpd.service

5. Creating USER in PHPMYADMIN for MySQL use of a specific website

login using “root”

create user with “Database for User”

Check “Grant all privileges on wildcard name (username\-%)”

Do not grant Global Privilege because in that case an user can see and edit any database those are there in the MySQL server.Click the Edit “Privilege” in the User section and Grant all privilege on the “Database-specific privileges”

If you want to restrict an user from creating a database then create the user with “Create a database with the user name.”

6. Install VSFTPD

yum install vsftpd -y

Configure the IPTable with allowing Port 20-21 and 1024-1048

vi /etc/sysconfig/iptables

Paste the following lines

-A INPUT -m state –state NEW -m tcp -p tcp –dport 20:21 -j ACCEPT

-A INPUT -m state –state NEW -m tcp -p tcp –dport 1024:1048 -j ACCEPT

Save and Exit. Restart the IPTable.

Create FTP with multiple user with specific directory permission by editing vsftpd.conf file.

vi /etc/vsftpd/vsftpd.conf

Set anonymous_enable=YES to NO

Paste at the bottom.

pam_service_name=vsftpd

userlist_enable=YES

tcp_wrappers=YES

pasv_enable=YES

pasv_min_port=1024

pasv_max_port=1048

pasv_address=<IP>

port_enable=YES

user_sub_token=$USER

local_root=/var/www/html/$USER

allow_writeable_chroot=YES

Save and Exit.

Set FTP HOME DIRECTORY On.

chmod 777 /var/www/html

chmod a-w /home/‘ftp user’

Here ‘ftp-user’ are the users created.

setenforce 0

setsebool -P ftp_home_dir on

systemctl restart vsftpd

systemctl restart httpd.service

Now create users and they will login to their specific directory while logging in with their login credentials.

7. Limit FTP File Transfer Rate

i. Limit the transfer rate universally

edit the vsftpd.conf file and place this line

local_max_rate=500000    <This means the ftp will allow 500kbps transfer rate>

ii. Limit User specific transfer rate

Place this line at the end

user_config_dir=/etc/vsftpd/limit <name of the folder can be anything>

Now create a file in the limit folder with the name of the ftpuser and edit it with

local_max_rate=500000

8.Domain For every user

Say we have 2 users with two websites.

i. www.abc.com

ii. www.def.com

We have to create a hosting zone for the domain in Google Cloud Computing with the same IP or else we can point domain to the IP from Domain Control Panel where it was bought. Next is to point the specific directory from the httpd.conf by creating a virtual host. eg is given below.

We have two website ‘abc’ place in abc directory and ‘def’ placed in def directory. We are creating virtual host to point.

<VirtualHost *:80>

    ServerAdmin webmaster@abc.com

    DocumentRoot /var/www/html/abc

    ServerName www.abc.com

    ServerAlias abc.com

    ErrorLog /var/www/html/abc/error_log

</VirtualHost>

<VirtualHost *:80>

    ServerAdmin webmaster@def.com

    DocumentRoot /var/www/html/def

    ServerName www.def.com

    ServerAlias def.com

    ErrorLog /var/www/html/def/error_log

</VirtualHost>

Save and Exit. Restart httpd.

systemctl restart httpd.service

Your shared server is ready for execution. You can host multiple websites and users will only be able to login to their specific directory and mysql server without having root access. Create Google Cloud Platform shared hosting interface easily and use better technology for your clients and in-house requirements with full control on the server. Got questions or need help? Feel free to connect if you require assistance with setting up your Shared Server on Google Cloud Computing Interface. Feedbacks welcome.

 We will discuss Postfix configuration for mail configuration after we create Google Cloud Platform shared hosting in the next post. Stay tuned.

Videos