Install dependencies on the web host. This lab use Alibaba Cloud ECS instance with CentOS 7 system. You can use any web host, or host the website on your local machine. Be sure to install php version 7 as required by the hosted website.
yum -y install httpd httpd-manual mod_ssl mod_perl mod_auth_mysql mysql epel-release git
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y install yum-utils
yum-config-manager --enable remi-php74
yum -y update
yum -y install php php-mysql gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap
1. Go to PolarDB console, select Clusters section
2. Go to the instance page by clicking on Cluster ID link
3. You will need a public cluster endpoint to access PolarDB. In Cluster Endpoints block, click Apply to apply for a public endpoint. apply for public endpoint
4. Select Accounts on the left, and click Create Account to create a new standard account for website to use
5. Select Databases on the left, and click Create Database to create a database for the website and authorize user to read and write.
6. In order to connect to Polar, whitelist incomming IP address. Select Whitelists on the left, and add IP whitelist or modify the existing default whitelist to allow the web host to access the database left column
7. You and verify if PolarDB is running by logging in to the database with the public endpoint and user account just created.
mysql -h<endpoint> -P<port> -p<password> -u<user> -D<database>
option | explanation |
endpoint:port | address to the database from step 3 |
user & passwsord | user account created in step 4 |
database | database created in step 5 |
This lab uses open source project PbootCMS (in Chinese)
1. Clone the project and set up necessary files
cd ~ && git clone https://gitee.com/hnaoyun/PbootCMS.git
cp -r PbootCMS/* /var/www/html/
chmod -R a+w /var/www/html
2. Import sample data for the website
mysql -h<endpoint> -P<port> -u<user> -p<password> -D<database> < $(ls /var/www/html/static/backup/sql/pbootcms*)
you can checkout imported data by connecting to the database from command line, or going to instance overview and click Log On to Database. From Home tab, select the database. You can see database is already populated with website data.
3. Configure website to connect to PolarDB
Use this command to quickly setup the website, or manually edit /var/www/html/config/database.php
cat > /var/www/html/config/database.php << EOF
<?php
return array(
'database' => array(
'type' => 'mysqli',
'host' => '<endpoint>',
'user' => '<user name>',
'passwd' => '<password>',
'port' => '<endpoint port>',
'dbname' => '<database name>'
)
);
EOF
4. Make sure port 80 is open to public network on the web host, and restart httpd systemctl restart httpd
5. Now the website should be up and running, go to http://<web host IP address>/
to checkout the sample website
Suppose you are hosting a service with global audience, your database will receive connection from around the world. In order to imporve latency, you can setup a GDN (Global Data Network) to serve a network of databases in multiple locations.
All data and modifications to the database is available on all clusters, so you can connect your web hosts to nearest PolarDB cluster, greatly reduce database access latency.
For a more detailed introduction and instruction on GDN, checkout GDN hands on.
This lab hosts a simple website using PolarDB for MySQL as database backend, demostrates basic usage of PolarDB, like basic management steps and how to connect to the database.
PolarDB Hands-on | PolarDB for MySQL: Automatic Interval Partitioning
ApsaraDB - April 27, 2023
ApsaraDB - May 30, 2023
ApsaraDB - May 29, 2023
ApsaraDB - April 26, 2023
ApsaraDB - April 27, 2023
ApsaraDB - April 27, 2023
Explore Web Hosting solutions that can power your personal website or empower your online business.
Learn MoreExplore how our Web Hosting solutions help small and medium sized companies power their websites and online businesses.
Learn MoreAlibaba Cloud PolarDB for PostgreSQL is an in-house relational database service 100% compatible with PostgreSQL and highly compatible with the Oracle syntax.
Learn MoreAlibaba Cloud PolarDB for Xscale (PolarDB-X) is a cloud-native high-performance distributed database service independently developed by Alibaba Cloud.
Learn MoreMore Posts by ApsaraDB