1. Use PuTTY to connect to the server remotely;

2. The current operating system is CentOS 6.5 64-bit.

3. Check disk space usage with the command:
df -h

4. Check disk space usage, including unmounted data disks, with the command:
fdisk -l
Friendly reminder: If you run the fdisk -l command and do not see /dev/xvdb, it means your cloud server has no data disk, so you do not need to mount it. In this case, this tutorial does not apply to you.

5. Partition the data disk
Run:
fdisk /dev/xvdb
to partition the data disk;
Following the prompts, enter
n
p
1
press Enter twice
wq
The partitioning will start and finish quickly.

6. View the new partition
Use the
fdisk -l
command to see that the new partition xvdb1 has been created.

7. You can use the
mkfs.ext4 /dev/xvdb1
command to format the new partition. The formatting time varies depending on the disk size.

8. Add partition information
If you want to mount the new partition to the /var/www directory, you can use the following command. Note: If the /var/www directory does not exist, first run the command:
mkdir /var/www
to create the directory.
echo “/dev/xvdb1 /var/www ext4 defaults 0 0” >> /etc/fstab
Run the command to write the new partition information. Then use the
cat /etc/fstab
command to check. If the following information appears, the write was successful.

9. Mount the new partition
Use the
mount -a
command to mount the new partition, then use the
df -h
command to check. If the following information appears, the mount is successful and you can start using the new partition.

10. Use the
yum install httpd
y
commands to install Apache.

11. Run the command:
service httpd start
to start Apache immediately.
Verify the httpd service status:
service httpd status
Run the command:
chkconfig –levels 235 httpd on
to enable Apache to start automatically.
Check the startup levels of this service:
chkconfig –list httpd
Just make sure it is set to on for runlevels 3 or 5.

12. Open the following in your local browser:
http://Public IP address
If “Apache 2 Test Page powered by CentOS” appears, the httpd service has been installed and started successfully;

13. Set the website’s publish directory and create a virtual host
cd /etc/httpd/conf
ls
Create a backup of the configuration file
cp httpd.conf httpd.bak
ls
vim httpd.conf

?DocumentRoot
Press the n key to view the next match;

Press the i key to enter edit mode, and change the default website root directory to: /var/www/wwwroot
Press the Esc key to exit edit mode, then press :wq to save and exit;

Create the website root directory with the command:
mkdir -p /var/www/wwwroot
Reload the configuration file
service httpd reload
Create a virtual host
vim /etc/httpd/conf/httpd.conf
Press the i key to enter edit mode, and remove the # sign from NameVirtualHost *:80 to enable virtual host support;
Go to the /etc/httpd/conf.d directory
cd /etc/httpd/conf.d
Create a new virtual host configuration file named vhosts.conf
vim vhosts.conf

service httpd reload
14. Install and configure PHP
yum install php
y

Install packages like php-mysql to enable PHP support for MySQL. Run the command
yum search php
to find available PHP module packages, select the required packages, and run the command
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-cli php-common php-devel php-mbstring php-mcrypt php-soap php-bcmath php-mysqli
to install them (you are not limited to the packages in this example)
y

service httpd restart
echo “<?php phpinfo(); ?>” >> /var/www/wwwroot/phpinfo.php
Verify whether PHP was installed successfully

15. Install and configure the FTP server
yum install vsftpd
y
vim /etc/vsftpd/vsftpd.conf
Configure vsftpd:
To disallow anonymous users from logging into the FTP server, use:
anonymous_enable=NO
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list


chkconfig –levels 235 vsftpd on
useradd -d /var/www/wwwroot/phpMyAdmin -s /sbin/nologin phpMyAdmin
passwd phpMyAdmin
ftp%$fg65DFlM43$3
ftp%$fg65DFlM43$3
Add the created user to the configuration file, one user per line
vim /etc/vsftpd/chroot_list
service vsftpd restart
Change the owner of all phpMyAdmin files to phpMyAdmin:
chown -R phpMyAdmin /var/www/wwwroot/phpMyAdmin
chmod -R 755 /var/www/wwwroot/phpMyAdmin
Grant permissions to the apache user for directories that require apache operations, such as the image upload directory
chown -R apache directory
Test whether the connection is successful using FTP client software

Because the database uses the cloud database RDS, there is no need to configure it on the ECS. The configuration ends here.
