Linux Cloud Server Configuration Handbook

On October 23, 2016, in Other Online Technology, by James Liu

Cloud computing is famous since early 2000. Now it becomes to be necessary for any companies who want to host a website, run an online service, or start e-commerce business. To cut the cost, Linux will be the first choice, just because it is powerful but free. However, for people like me who don’t have any experience with Linux server, it could be a little bit hard to handle. I think it will be helpful to share my 3 days experience on Linux cloud server.

Linux Cloud Sever Howto

Linux cloud server is different from local hosting Linux which we are using on our desktop. Usually, the Linux cloud server doesn’t provide any graphic terminal. Therefore, we only have one option: ssh. It is an important command line tool used for administering remote Linux. To be able to administer a Linux remote server through SSH, remembering some Linux command will be necessary. Here are some basic Linux commands which I have used in the past 3 days.

How to know what processes are running on Linux cloud server?
This is my first question when I get conntect with the server. Bascially, I want to setup a web server with PHP support. But I don’t know which web server software is running on the cloud Linux server. So I run the following command to get a list of running processes:

# ps aux | less

If there are too many processes and you want to search a certain process, you can use “grep” to filter the result. In my case, I want to know if the Apache is running, I am using following command:

# ps aux | grep "apache"

How to copy file from Windows to Linux cloud computing server?
Copy files from Windows to Linux cloud server remotely is always a problem. Some people will setup a FTP server in Linux cloud server, but it requires more jobs to setup the server and take care the security issue. If we just want to upload server files, we can following command:

pscp C:\wamp64\www\index.html root@

PSCP is an SCP client for secure file copy. It also supports to upload a set of files with wildcard. Here is the example:

pscp C:\wamp64\www\*.html root@

PSCP also supports to upload a folder with all files inside recursively. Check this example:

pscp C:\wamp64\www -r root@

When we run pscp command, we are asked to type the password for uploading file each time. Sometimes, it is quite irritating. In windows, we can write a batch file (bat file) to automatically doing the job. Here is any example:

Echo password| pscp C:\wamp64\www -r root@

Please note that there is no “space” between the password and pipe symbol “|”. Otherwise, the “space” will be considered as password to pass to the remote Linux cloud server.

How to download file from Linux cloud computing server to Windows
We can also use pscp command to download file from remote linux server to local Windows computer. Here is the example:

pscp root@ ./

I don’t know if pscp can recursively download a folder from remote server. If I wanna download a folder, I will use following command to make a tar file and download it by above command. Here is the example to tar a folder:

tar -czf backup.tar.gz ./backup

Amazon EC2 Performance Tuning

I am working on migrating my wordpress website from normal shared hosting to Amazon EC2 server. After all the jobs are done, I direct my website domain to the new host. However, the new site is suffering from serious performance issue. By the way, I am using the t2.micro model.

Amazon EC2 is easy to scale but it is quite not suitable for people who don’t have server configuration experience. To configure a LAMP (Linux, Apache2, MySQL and PHP) properly is not easy job.

First, how to configure my server secure is a tough job. When I am using share hosting, the administrator will be watching my server all the time. He will send me email if there are any security issue, especially for HTTP attack, for example, wp-login.php brute force attack. But in the Amazon host, I have to watch it by myself.

All following information are from Internet. I search and use them in my Amazon EC2 configuration. I have to admit that all these may be basic skills for a sophisticated web admin. But all of them are quite useful for me.

Configure Apache Log Format to Log Request IP

In Amazon CE2 host, the incoming IP address are logged by because of Amazon Balance mechanism. To get the real ip from request, we need to change the log format in apache server configuration file. In my Amazon CE2 host, I am using Ubuntu Linux. My Apache2 configuration file is located at:


Find the following line:

LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined

Replace with:

LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined

Actually, it is simply change %h into %{X-Forwarded-For}.

Configure MySQL Server improve the Performance

After install MySQL in my Amazon EC2 host, I have to configure MySQL for better performance. The mysql configuration file is located at:


I have changed following options:

query_cache_size: from 16M to 256M
table_cache: from 64 to 1024

Because my table engine is innodb, I also add following option in the configuration file:


Here is one post which is quite useful:

There are also other cache engines or proxies which may help to improve the website performance in Amazon EC2:
Scaling Memcache at Facebook


Leave a Reply

WordPress Themes

Free WordPress Themes