I run several PHP websites in Jooma and WordPress on Ubuntu VPS using Nginx as the web server with PHP-FPM for processing PHP. In most cases all the sites work fast enough, but sometimes (probably once a couple days) I got a message from Yandex (Russian search engine like Google) telling that one of my websites did not respond within 5 seconds. I set up Nginx slowlog and detected that sometimes HTTP requests are processed for more than 5 seconds:
Category Archives: Operating Systems
Monitoring CPU Steal Time with command line in Ubuntu
Bash command that writes CPU Steal Time along with other CPU usage statistics from top command header once in a second to MySQL database:
top -b -d 1 | ts ‘%Y-%m-%d %H:%M:%S’ | sed -rn “s/(.{19} )Cpu\(s\):\s+([0-9]+\.[0-9]+)%us,\s+([0-9]+\.[0-9]+)%sy,\s+([0-9]+\.[0-9]+)%ni,\s+([0-9]+\.[0-9]+)%id,\s+([0-9]+\.[0-9]+)%wa,\s+([0-9]+\.[0-9]+)%hi,\s+([0-9]+\.[0-9]+)%si,\s+([0-9]+\.[0-9]+)%st(.*)/INSERT INTO m_perf_stat (CDate, cpu_us, cpu_sy, cpu_ni, cpu_id, cpu_wa, cpu_hi, cpu_si, cpu_st) VALUES (‘\1′, \2, \3, \4, \5, \6, \7, \8, \9);/p” | mysql -u <username> -p<password> <database>
that’s the longest bash command I ever written in my life ![]()
Configuring Firewall to enable FTP, SSH and HTTP on Ubuntu
Check your currently implemented firewall rules with the following command:
iptables -L
Examine the output. On a clean Ubuntu installation you will see an empty ruleset:
Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination
How to encrypt swap on Ubuntu 12.04
Without going into particulars, it suffices to say that Ubuntu 12.04 has the following script that sets up encrypted swap:
ecryptfs-setup-swap
How to start Apache OFBiz demo under Ubuntu Server 12.04
Install JDK 6 with the following command:
apt-get install default-jdk
Download the latest OFBiz version, extract it in your home directory and do the following steps described in the README file.
Having apache-ofbiz-XX.XX.XX as the current directory execute the following command:
./ant load-demo
How to install Apache Tomcat 7 on Ubuntu Server 12.4 LTS
Today I successfully installed Tomcat 7 on Ubuntu Server 12.4 LTS with the following commands (executed as root):
apt-get install default-jdk apt-get install tomcat7 apt-get install tomcat7-admin apt-get install tomcat7-examples
Basic Git commands
Git installs as a normal package on Ubuntu:
sudo apt-get install git |
Configuring Git user is an optional step:
git config --global user.email "you@example.com"git config --global user.name "Your Name" |
Type the following command to create an empty repository wherever your code is:
cd ~git init |
Setting up Shared Hosting with Nginx on Ubuntu – step by step guide
This is a draft version of the post. It’ll be revised.
Installing Ubuntu Server
- Download the latest version of Ubuntu Server. Note that it is not possible to convert Ubuntu 32 bit to 64 bit. The only way is to do a clean install.
- Create a bootable USB stick using Pen Drive Linux’s USB Installer.
- Boot up from USB and install Ubuntu Server. During the installation you can switch to terminal mode by pressing Alt+F2 and switch back by pressing Alt+F1.
Update the server:
aptitude update aptitude safe-upgrade
How to configure IIS to host an FTP site on Windows 7
Go to Control Panel->Programs and Features->Turn Windows features on or off, select FTP Service and IIS Management Console under Internet Information Services and press OK button:
Installing and configuring FTP server on Ubuntu
Install FTP server:
apt-get install proftpd
To jail all users in their home directories uncomment line
DefaultRoot ~
in /etc/proftpd/proftpd.conf. To jail all but one users modify this line as follows:
DefaultRoot ~ !<user1>
note that there is a space after ‘~’.
