<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Linux Optimization &#8211; VeriTeknik</title>
	<atom:link href="https://www.veriteknik.net.tr/en/category/knowledge_base/linux/linux-optimization/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.veriteknik.net.tr/en/</link>
	<description>VeriTeknik Bilişim &#124; VeriTeknik Bilişim</description>
	<lastBuildDate>Thu, 31 Oct 2013 19:56:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Compile and build Apache + MySQL + PHP from the source</title>
		<link>https://www.veriteknik.net.tr/en/compiling-apache-mysql-php-source/</link>
					<comments>https://www.veriteknik.net.tr/en/compiling-apache-mysql-php-source/#respond</comments>
		
		<dc:creator><![CDATA[ckaraca]]></dc:creator>
		<pubDate>Thu, 31 Oct 2013 19:56:47 +0000</pubDate>
				<category><![CDATA[httpd]]></category>
		<category><![CDATA[LINUX]]></category>
		<category><![CDATA[Linux Optimization]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Centos6]]></category>
		<category><![CDATA[CentOS6.4]]></category>
		<category><![CDATA[compile]]></category>
		<category><![CDATA[httpd-2.2.25]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql-5.6.14]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[PHP 5.5.5]]></category>
		<category><![CDATA[phpmyadmin]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[stratch]]></category>
		<guid isPermaLink="false">http://www.plugged.in/?p=896</guid>

					<description><![CDATA[<p>This is a complete working solution to build Apache (httpd-2.2.25), MySQL (MySQL-5.6.14) and PHP (PHP-5.5.5) from the sources. Article tested many times on CentOS 6.4 and you can directly copy &#38; paste the commands below to build the lastest releases. We advise you to use a freshly installed OS as compiling may corrupt or delete [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.veriteknik.net.tr/en/compiling-apache-mysql-php-source/">Compile and build Apache + MySQL + PHP from the source</a> appeared first on <a rel="nofollow" href="https://www.veriteknik.net.tr/en/">VeriTeknik</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This is a complete working solution to build Apache (httpd-2.2.25), MySQL (MySQL-5.6.14) and PHP (PHP-5.5.5) from the sources. Article tested many times on CentOS 6.4 and you can directly copy &amp; paste the commands below to build the lastest releases. We advise you to use a freshly installed OS as compiling may corrupt or delete your existing structure or data. The solution both tested on a clean dedicated server and a KVM virtualized VPS.</p>
<p>Before you begin your compilation you should need additional header files and libraries required, please use the following code to install pre-requisities, don&#8217;t delete them as you would definitely need them when you upgrade to new releases also:</p>
<pre class="brush: shell; gutter: true; first-line: 1">yum install make gcc automake zlib-devel bison cmake libtool wget gcc-c++ unzip ncurses-devel openssl-devel pcre-devel libxml2-devel curl-devel gd-devel libxslt-devel</pre>
<h2>Building &amp; Installing Apache prefork</h2>
<p>download the latest release of Apache Web Server and unpack:</p>
<pre class="brush: shell; gutter: true; first-line: 1">wget http://ftp.itu.edu.tr/Mirror/Apache//httpd/httpd-2.2.25.tar.gz
tar zxvf httpd-2.2.25.tar.gz 
cd httpd-2.2.25</pre>
<p>We advise you to configure with the options below as this form is widely used:</p>
<pre class="brush: shell; gutter: true; first-line: 1">./configure \
        "--prefix=/etc/httpd" \
        "--exec-prefix=/etc/httpd" \
        "--bindir=/usr/bin" \
        "--sbindir=/usr/sbin" \
        "--sysconfdir=/etc/httpd/conf" \
        "--enable-so" \
        "--enable-dav" \
        "--enable-dav-fs" \
        "--enable-dav-lock" \
        "--enable-suexec" \
        "--enable-deflate" \
        "--enable-unique-id" \
        "--enable-mods-static=most" \
        "--enable-reqtimeout" \
        "--with-mpm=prefork" \
        "--with-suexec-caller=apache" \
        "--with-suexec-docroot=/" \
        "--with-suexec-gidmin=100" \
        "--with-suexec-logfile=/var/log/httpd/suexec_log" \
        "--with-suexec-uidmin=100" \
        "--with-suexec-userdir=public_html" \
        "--with-suexec-bin=/usr/sbin/suexec" \
        "--with-included-apr" \
        "--with-pcre=/usr" \
        "--includedir=/usr/include/apache" \
        "--libexecdir=/usr/lib/apache" \
        "--datadir=/var/www" \
        "--localstatedir=/var" \
        "--enable-logio" \
        "--enable-ssl" \
        "--enable-rewrite" \
        "--enable-proxy" \
        "--enable-expires" \
        "--with-ssl=/usr" \
        "--enable-headers"</pre>
<p>to build and install source distro, type:</p>
<pre class="brush: shell; gutter: true; first-line: 1">make
make install</pre>
<h2>Build &amp; Install MySQL</h2>
<p>Since we need headers and libraries of mysql for compiling PHP, we will first install MySQL server before PHP compilation.</p>
<pre class="brush: shell; gutter: true; first-line: 1">wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.14.tar.gz/from/http://cdn.mysql.com/
tar zxvf mysql-5.6.14.tar.gz 
cd mysql-5.6.14
groupadd mysql
useradd -g mysql mysql
cmake .  -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock
make
make install</pre>
<p>If you encounter problems while running cmake, you have to delete <strong>CmakeCache.txt</strong> before re-compiling with cmake</p>
<pre class="brush: shell; gutter: true; first-line: 1">#log in to newly created mysql dir
cd /usr/local/mysql/
#change owner and group
chown -R mysql:mysql .
scripts/mysql_install_db --user=mysql --datadir=/var/lib/mysql
#add service command
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
#start mysql server
service mysqld start</pre>
<p>change your mysql password by typing:</p>
<pre class="brush: shell; gutter: true; first-line: 1">./bin/mysqladmin -u root password 'new-password' 
./bin/mysqladmin -u root -h change.this.hostname password 'new-password'</pre>
<h2>Build libmcrypt from the source</h2>
<p>libmcypt repo is not included in the main yum repo, so better install it from the source:</p>
<pre class="brush: shell; gutter: true; first-line: 1">wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download?use_mirror=garr
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
make install</pre>
<h2>Building PHP-5.5.5 from the source</h2>
<p>PHP configuration is also given with the mostly used modules &amp; functionality, download unpack &amp; configure as stated below:</p>
<pre class="brush: shell; gutter: true; first-line: 1">wget http://us2.php.net/get/php-5.5.5.tar.gz/from/this/mirror
tar zxvf php-5.5.5.tar.gz
cd php-5.5.5
./configure \
        --with-apxs2 \
        --with-curl=/usr \
        --with-gd \
        --with-gettext \
        --with-jpeg-dir=/usr \
        --with-freetype-dir=/usr \
        --with-kerberos \
        --with-openssl \
        --with-mcrypt=/usr/local/lib \
        --with-mhash \
        --with-mysql=mysqlnd \
        --with-mysqli=mysqlnd \
        --with-pcre-regex \
        --with-pear \
        --with-png-dir=/usr \
        --with-xsl \
        --with-zlib \
        --with-zlib-dir=/usr \
        --with-iconv \
        --enable-bcmath \
        --enable-calendar \
        --enable-exif \
        --enable-ftp \
        --enable-gd-native-ttf \
        --enable-soap \
        --enable-sockets \
        --enable-mbstring \
        --enable-zip \
        --enable-wddx
make
make install
libtool --finish /root/php-5.5.5/libs
cp php.ini-production /usr/local/lib/php.ini
sed -i 's/;date.timezone =.*/  date.timezone \= "Europe\/Istanbul"/' /usr/local/lib/php.ini</pre>
<h3>Download phpMyAdmin and install it to webroot:</h3>
<pre class="brush: shell; gutter: true; first-line: 1">wget http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.0.8/phpMyAdmin-4.0.8-all-languages.tar.gz
tar zxvf phpMyAdmin-4.0.8-all-languages.tar.gz 
mv phpMyAdmin-4.0.8-all-languages /var/www/
mv /var/www/phpMyAdmin-4.0.8-all-languages/ /var/www/phpMyAdmin</pre>
<p>create a test page to see if everything went well:</p>
<pre class="brush: shell; gutter: true; first-line: 1">echo "&lt;?PHP phpInfo();?&gt;" &gt; /var/www/index.php</pre>
<p>If you cannot see a PHP info page, you need to add httpd directives to your httpd.conf:</p>
<pre class="brush: shell; gutter: true; first-line: 1">echo "AddType application/x-httpd-php .php" &gt;&gt; /etc/httpd/conf/extra/httpd-php.conf
echo "AddType application/x-httpd-php-source .phps" &gt;&gt; /etc/httpd/conf/extra/httpd-php.conf

echo "Include conf/extra/httpd-php.conf" &gt;&gt; /etc/httpd/conf/httpd.conf</pre>
<p>restart apache by typing: <strong>apachectl restart</strong></p>
<p>The post <a rel="nofollow" href="https://www.veriteknik.net.tr/en/compiling-apache-mysql-php-source/">Compile and build Apache + MySQL + PHP from the source</a> appeared first on <a rel="nofollow" href="https://www.veriteknik.net.tr/en/">VeriTeknik</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.veriteknik.net.tr/en/compiling-apache-mysql-php-source/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">896</post-id>	</item>
		<item>
		<title>Building PHP 5.4.3 on CentOS</title>
		<link>https://www.veriteknik.net.tr/en/building-php-5-4-3-on-centos/</link>
					<comments>https://www.veriteknik.net.tr/en/building-php-5-4-3-on-centos/#respond</comments>
		
		<dc:creator><![CDATA[Mustafa Emre Aydın]]></dc:creator>
		<pubDate>Fri, 01 Jun 2012 10:31:42 +0000</pubDate>
				<category><![CDATA[httpd]]></category>
		<category><![CDATA[LINUX]]></category>
		<category><![CDATA[Linux Optimization]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[php]]></category>
		<guid isPermaLink="false">http://www.plugged.in/?p=525</guid>

					<description><![CDATA[<p>Even though it&#8217;s easier to use yum, sometimes we need to compile PHP from source code. Below I&#8217;ll describe a method for compiling PHP 5.4.3 on CentOS, this works both on 5.x and 6.x and all the dependencies (except for PHP itself, of course ) will be retrieved via yum. After a fresh install of [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.veriteknik.net.tr/en/building-php-5-4-3-on-centos/">Building PHP 5.4.3 on CentOS</a> appeared first on <a rel="nofollow" href="https://www.veriteknik.net.tr/en/">VeriTeknik</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Even though it&#8217;s easier to use yum, sometimes we need to compile PHP from source code. Below I&#8217;ll describe a method for compiling PHP 5.4.3 on CentOS, this works both on 5.x and 6.x and all the dependencies (except for PHP itself, of course ) will be retrieved via yum.</p>
<p>After a fresh install of CentOS, we will need the wget binary, if you don&#8217;t already have it, get it with yum.</p>
<pre class="brush: bash; gutter: true; first-line: 1">yum install wget -y</pre>
<p>For some of the dependencies to get installed, we&#8217;ll need the rpmforge repository, so let&#8217;s add it.</p>
<pre class="brush: bash; gutter: true; first-line: 1">wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm -K rpmforge-release-0.5.2-2.el5.rf.*.rpm
rpm -i rpmforge-release-0.5.2-2.el5.rf.*.rpm</pre>
<p>Now let&#8217;s install the dependencies for our PHP compilation. Keep in mind that these are only for the configuration I&#8217;ll describe below, if you use a different compilation, you&#8217;ll need to get different packages. Also keep in mind that here I&#8217;ll only download the x86_64 packages, if you&#8217;re using a different architecture, just delete the x86_64 on every package name that contains it. The reason I specifically used that notation is to avoid downloading i386 packages, which is unnecessary but yum insists on downloading anyway.</p>
<pre class="brush: bash; gutter: true; first-line: 1">yum install gcc make automake autoconf perl.x86_64 httpd-devel.x86_64 libxml2-devel.x86_64 openssl-devel.x86_64 pcre-devel.x86_64 bzip2-devel.x86_64 curl-devel.x86_64 enchant-devel.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 libXpm-devel.x86_64 freetype-devel.x86_64 gmp-devel.x86_64 libicu-devel.x86_64 gcc-c++ libmcrypt-devel.x86_64 postgresql-devel.x86_64 aspell-devel.x86_64 libedit-devel.x86_64 recode-devel.x86_64 net-snmp-devel.x86_64 libtidy-devel.x86_64 libxslt-devel.x86_64 libcurl-devel.x86_64 libtool-ltdl-devel.x86_64 -y</pre>
<p>Now let&#8217;s download the php 5.4.3 source code.</p>
<pre class="brush: bash; gutter: true; first-line: 1">wget http://tr.php.net/get/php-5.4.3.tar.gz/from/this/mirror
tar xvzf php-5.4.3.tar.gz
cd php-5.4.3</pre>
<p>We can start the configure-make-make install trio now.</p>
<pre class="brush: bash; gutter: true; first-line: 1">./configure  --with-apxs2=/usr/sbin/apxs --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --target=x86_64-redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --cache-file=../config.cache --with-libdir=lib64 --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --disable-debug --with-pic --disable-rpath --with-bz2 --with-freetype-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr --enable-gd-native-ttf --without-gdbm --with-gettext --with-gmp --with-iconv --with-jpeg-dir=/usr --with-openssl --with-pcre-regex=/usr --with-zlib --with-layout=GNU --enable-exif --enable-ftp --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --with-kerberos --enable-shmop --enable-calendar --with-libxml-dir=/usr --enable-xml --enable-pcntl --with-imap-ssl --enable-mbregex --enable-bcmath=shared --enable-dba=shared --with-db4=/usr --with-xmlrpc=shared --with-mysql --with-mysqli --enable-dom=shared --with-pgsql --enable-wddx=shared --with-snmp=shared,/usr --enable-soap=shared --with-xsl=shared,/usr --enable-xmlreader=shared --enable-xmlwriter=shared --with-curl --enable-json --enable-zip=shared --without-readline --with-libedit --with-pspell=shared --enable-phar=shared --with-tidy=shared,/usr --enable-sysvmsg=shared --enable-sysvshm=shared --enable-sysvsem=shared --enable-posix=shared --enable-fileinfo=shared --enable-intl=shared --with-icu-dir=/usr --with-enchant=shared,/usr --with-recode=shared,/usr --enable-mbstring --with-mcrypt --with-gd
make
make install</pre>
<p>Now we have php installed.</p>
<p>Further we can configure the basic steps of Apache.<br />
Edit your httpd.conf file : /etc/httpd/conf/httpd.conf<br />
Find the line that says <em>AddType application/x-tar .tgz </em>Append these two lines below it.</p>
<p><strong>AddType application/x-httpd-php .php</strong><br />
<strong>AddType application/x-httpd-php-source .phps </strong></p>
<p>Also we should tell apache that index.php is an index file (or whatever index you want), so update your <em>DirectoryIndex</em> as following :</p>
<p><strong>DirectoryIndex index.html index.html.var index.php index.htm</strong></p>
<p>copy php.ini-production to /etc/php.ini and edit the file based on your performance requirements, please have a look at our security pages to secure your php configuration from the <a title="Web Hosting Security premier" href="http://www.plugged.in/linux/web-hosting-security/web-hosting-security-premier.html" target="_blank">link</a>.</p>
<p>Some suggestions: Increase upload limit, raise memory_limit to 256M and set date.timezone to your location, in our case it is:</p>
<p>date.timezone = Europe/Istanbul</p>
<p>After saving and exiting the httpd.conf file, restart your Apache services. ( <strong>service httpd restart</strong> )</p>
<p>Now you have <strong>/var/www/html</strong> as your default web home root, and PHP 5.4.3 running on it.</p>
<p>The post <a rel="nofollow" href="https://www.veriteknik.net.tr/en/building-php-5-4-3-on-centos/">Building PHP 5.4.3 on CentOS</a> appeared first on <a rel="nofollow" href="https://www.veriteknik.net.tr/en/">VeriTeknik</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.veriteknik.net.tr/en/building-php-5-4-3-on-centos/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">525</post-id>	</item>
		<item>
		<title>System Control Over Python With Pipes</title>
		<link>https://www.veriteknik.net.tr/en/system-control-over-python-with-pipes/</link>
					<comments>https://www.veriteknik.net.tr/en/system-control-over-python-with-pipes/#respond</comments>
		
		<dc:creator><![CDATA[Mustafa Emre Aydın]]></dc:creator>
		<pubDate>Tue, 22 May 2012 12:12:21 +0000</pubDate>
				<category><![CDATA[LINUX]]></category>
		<category><![CDATA[Linux Optimization]]></category>
		<category><![CDATA[Programmin]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[pipe]]></category>
		<category><![CDATA[popen]]></category>
		<category><![CDATA[python]]></category>
		<guid isPermaLink="false">http://www.plugged.in/?p=422</guid>

					<description><![CDATA[<p>Even though major system scripting is usually done via bash (or other shell) scripting, it&#8217;s almost as common to see Python as a system administration scripting platform. Today, most major installers, daemons and package management software are written in Python. While using Python as a system scripting tool, it&#8217;s essential to keep using the standard [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.veriteknik.net.tr/en/system-control-over-python-with-pipes/">System Control Over Python With Pipes</a> appeared first on <a rel="nofollow" href="https://www.veriteknik.net.tr/en/">VeriTeknik</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Even though major system scripting is usually done via bash (or other shell) scripting, it&#8217;s almost as common to see Python as a system administration scripting platform. Today, most major installers, daemons and package management software are written in Python.</p>
<p>While using Python as a system scripting tool, it&#8217;s essential to keep using the standard gnu tools if possible, since these tools are reliable, fast and have been tested for years by thousands of other system administrators as well.</p>
<p>The best way to keep using your good old fashioned gnu tools via Python is opening pipes to such tools. Even though it is possible to use the <strong>os</strong> module to do such tasks, the <strong>subprocess</strong> module is more reliable and you have more control over the tasks.</p>
<p>Below you&#8217;ll see two different methods to approach the &#8220;echo&#8221; tool via Python.</p>
<pre class="brush: python; gutter: true; first-line: 1">&gt;&gt;&gt; import os, subprocess
&gt;&gt;&gt; os.system("echo bla")
bla
0
&gt;&gt;&gt; subprocess.Popen(["echo","bla"],stdout=subprocess.PIPE).communicate()[0]
'bla\n'</pre>
<p>As you can see, both give us more or less the same output, but the subprocess module gives us a lot more control. First of all it has pipe support, universal newline support, better handling of exceptions etc.</p>
<p>Below is a method I use to determine the number of processor on the system. Using this, you can find out if you have multiple cores on the system.</p>
<pre class="brush: python; gutter: true; first-line: 1">cpu_num=subprocess.Popen(["grep","-c","processor","/proc/cpuinfo"],stdout=subprocess.PIPE).communicate()[0]</pre>
<p>As you can see, what is does is very very simple, it just counts the number of word &#8220;processor&#8221; in the <strong>/proc/cpuinfo</strong> file using grep.</p>
<p>Don&#8217;t forget that it is very easy to pipe commands through each other with popen, here&#8217;s an example.</p>
<pre class="brush: python; gutter: true; first-line: 1">&gt;&gt;&gt; import subprocess
&gt;&gt;&gt; p1=subprocess.Popen(["cat","/proc/cpuinfo"],stdout=subprocess.PIPE)
&gt;&gt;&gt; p2=subprocess.Popen(["grep","-B","2","-A","2","processor"],stdin=p1.stdout,stdout=subprocess.PIPE)
&gt;&gt;&gt; output = p2.communicate()[0]
&gt;&gt;&gt; print output
processor : 0
vendor_id : GenuineIntel
cpu family : 15</pre>
<p>Using the popen, it is very easy to get information on processes via the pgrep and ps tools. Below is a script when run with the valid parameters, checks if any of it&#8217;s processes uses more (or equal) to the percentage of the CPU specified, if true, kills the process and tries to send a message to the affiliated terminal window.</p>
<p>To accomplish this, we get the pid&#8217;s of the processes via pgrep, send it to ps so to check the cpu percentage and which tty (or pts) it&#8217;s running on. After the check, if necessary, the PID is killed and a message is sent to the terminal it was running on.</p>
<pre class="brush: python; gutter: true; first-line: 1">#!/usr/bin/python
import subprocess, sys, string

if len(sys.argv) != 3 :
    print "Usage : cpukiller.py &lt;process-to-kill&gt; &lt;max-cpu-percentage&gt;"
    raise SystemExit

proc_to_kill = sys.argv[1]
cpu_to_kill = sys.argv[2]

for i in cpu_to_kill :
    if i not in string.digits :
        print "max-cpu-percentage must consist of only digits."
        raise SystemExit

cpu_to_kill = int(cpu_to_kill)

try :
	a=subprocess.Popen(["pgrep",proc_to_kill],stdout=subprocess.PIPE).communicate()[0]
	if a == '' :
		raise SystemExit
	else :
		procc = subprocess.Popen(["ps --no-headers -o pid,pcpu,tname -p $(pgrep %s)"%proc_to_kill],shell=True,stdout=subprocess.PIPE).communicate()[0]
		procc=procc.strip()
except : raise SystemExit 
for lines in procc.split('\n') :
    if lines != '' :
        l=lines.split()
        if int(l[1].split('.')[0]) &gt;= cpu_to_kill :
            if l[2] != '?' :
                try :
                    terminal = open('/dev/'+l[2],'a')
                    subprocess.Popen(["echo","You have exceeded your CPU limit, process with PID %s will be terminated"%l[0]],stdout=terminal).communicate()[0]
                except :
                    print "Couldn't tell the user."
                    pass
            try :
                killer = subprocess.Popen(["kill","-9",l[0]],stdout=subprocess.PIPE).communicate()[0]
            except :
                print "Couldn't kill the process."
                pass
        else : pass</pre>
<p>Try to use it, understand it, and expand it!</p>
<p>The post <a rel="nofollow" href="https://www.veriteknik.net.tr/en/system-control-over-python-with-pipes/">System Control Over Python With Pipes</a> appeared first on <a rel="nofollow" href="https://www.veriteknik.net.tr/en/">VeriTeknik</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.veriteknik.net.tr/en/system-control-over-python-with-pipes/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">422</post-id>	</item>
		<item>
		<title>Linux Optimization from the scratch</title>
		<link>https://www.veriteknik.net.tr/en/linux-optimization-from-the-scratch/</link>
					<comments>https://www.veriteknik.net.tr/en/linux-optimization-from-the-scratch/#respond</comments>
		
		<dc:creator><![CDATA[ckaraca]]></dc:creator>
		<pubDate>Thu, 28 Apr 2011 13:25:17 +0000</pubDate>
				<category><![CDATA[Linux Optimization]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[logrotate]]></category>
		<category><![CDATA[optimization]]></category>
		<guid isPermaLink="false">http://www.plugged.in/?p=141</guid>

					<description><![CDATA[<p>Using LINUX as a server?, if so please read below Most of the Linux distros released as CD or DVD media for installing and if you install Linux with defualy options you get a nice user interface and a bunch of applications that you will never use in a server environment. Also default installation will [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.veriteknik.net.tr/en/linux-optimization-from-the-scratch/">Linux Optimization from the scratch</a> appeared first on <a rel="nofollow" href="https://www.veriteknik.net.tr/en/">VeriTeknik</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Using LINUX as a server?, if so please read below</h2>
<p style="text-align: justify;">Most of the Linux distros released as CD or DVD media for installing and if you install Linux with defualy options you get a nice user interface and a bunch of applications that you will never use in a server environment. Also default installation will require second, third CDs or all of seven CDs in one installation. But Linux, especially CentOS could be install with the first CD and the rest of the packages could be install with the installer &#8220;YUM&#8221;.  For more security and reservation of resources the system must be installed with only base packages described below.</p>
<p style="text-align: justify;">You don&#8217;t need to select the services that you will use in a server at the installation. The best choice is to unselect all the ticks you see on the installation screen as follows, we will install the necessay packages after the installation.</p>
<div id="attachment_142" style="width: 310px" class="wp-caption aligncenter"><a href="http://www.plugged.in/wp-content/uploads/centos-sunucu-kurulum.png"><img fetchpriority="high" decoding="async" aria-describedby="caption-attachment-142" class="size-medium wp-image-142" title="centos-server-installation" src="http://www.plugged.in/wp-content/uploads/centos-sunucu-kurulum-300x226.png" alt="CentOS Install first step" width="300" height="226" /></a><p id="caption-attachment-142" class="wp-caption-text">CentOS Install first step</p></div>
<p style="text-align: justify;">You won&#8217;t need any GUI in server mode or you should better get used to using terminal for better performance &amp; security. Click Next when you done in this step and uncheck all prechecked items on all tabs. This way you should be able to install the OS with only one CD.</p>
<p><strong>Install base packages after the reboot, most of the packages install dependencies, never mind installing them alone</strong></p>
<blockquote><p>yum install vixie-cron bind-utils jwhois which</p></blockquote>
<p>If you need other packages instal them also. If you know the application but not the package containing it, you can always search it with the following command. For example, to install <strong>locate</strong>, you should.</p>
<blockquote><p>yum whatprovides */locate</p></blockquote>
<p>Yum will find the package (mlocate) for you easily.</p>
<p><strong>Close IPv6 if you don&#8217;t use it </strong>(depreciated)</p>
<blockquote>
<div>echo &#8220;alias net-pf-10 off&#8221; &gt;&gt; /etc/modprobe.conf<br />
echo &#8220;alias ipv6 off&#8221; &gt;&gt; /etc/modprobe.conf</div>
</blockquote>
<div><strong>Setup Logrotate to shrink log sizes</strong></div>
<p>If you have your own log files in your custom directory and you want to rotate them daily, follow the directions below to create a custom logrotate script. In our example we will rotate the log files in folder /home/user/logs/ ending with *log:</p>
<blockquote>
<div>vi /etc/logrotate.d/custom</div>
</blockquote>
<p>and add the lines below to keep 8 days of log and compress them</p>
<blockquote>
<div>/hsphere/user/logs/*log {<br />
daily<br />
rotate 8<br />
missingok<br />
compress<br />
delaycompress<br />
postrotate<br />
/usr/sbin/apachectl graceful<br />
endscript<br />
}</div>
</blockquote>
<div><strong>Using SSD Disks? use EXT2</strong></div>
<p>For better performance you should use SSD disks, but you must take into account that SSD disks could be damaged if written all the time. Since EXT3 file system makes more utilization on disks more than EXT2, your disks might have a shorten life than expected. EXT3 makes journal of disks and some kind of defragmentation that you will never need in SSDs. Also Linux default file system uses <strong>atime</strong> to store last access time to a file, thus every read on a file makes a write and we will close this option as you rearly use it or you can find severeal other ways to see last access time if you need so. Also note that, do not try to convert EXT3 to EXT2 on a production server, edit /etc/fstab to disable atime:</p>
<blockquote><p>/dev/sda1 / ext2 defaults 0 0</p></blockquote>
<p>add noatime after all <strong>defaults</strong>:</p>
<blockquote><p>/dev/sda1 / ext2 defaults,<strong>noatime </strong>0 0</p></blockquote>
<p>You can remount the disks by typing &#8220;mount -o remount,rw,noatime /dev/sda1&#8221; (sda1: replace with your appropriate disks) without writing to fstab (the changes will be lost on any reboot if you don&#8217;t write to fstab). To test the disk speeds you can call:</p>
<blockquote><p>hdparm -tT /dev/sda1 # use df to see your disks instead of sda1</p></blockquote>
<p>If you get less than 30 MB/s in &#8220;Timing buffered disk reads&#8221; part try to enable DMA or simply dispose your old disk and buy a new one.<br />
<strong>Set 32 bit transfers and Interrupt mask in your disk.</strong></p>
<p>New SATA disks, while promising huge speeds they came with minimum speed configurations in order to work on all type of systems including new and legacy. Such SATA3 devices promise to reach up to 6 Gbps (715 MB/s) but you can never see those results in your server. To see what your disk can do type the following command:</p>
<blockquote><p>hdparm -I /dev/sda # use &#8220;df&#8221; to see your disks instead of sda</p></blockquote>
<p>Commands/Features part of the result shows the options of your disk. the ones marked with (*) shows the options that you can set/unset. We will only show 32 bit transfers and interrupt masking here as an example, it is your own risk to set these features:</p>
<blockquote><p>hdparm -tT /dev/sda # test speed before applying<br />
hdparm -u1 -c3 /dev/sda<br />
hdparm -tT /dev/sda</p></blockquote>
<p>The post <a rel="nofollow" href="https://www.veriteknik.net.tr/en/linux-optimization-from-the-scratch/">Linux Optimization from the scratch</a> appeared first on <a rel="nofollow" href="https://www.veriteknik.net.tr/en/">VeriTeknik</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.veriteknik.net.tr/en/linux-optimization-from-the-scratch/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">141</post-id>	</item>
		<item>
		<title>Run /tmp from memory for faster performance</title>
		<link>https://www.veriteknik.net.tr/en/run-tmp-from-memory-for-faster-performance/</link>
					<comments>https://www.veriteknik.net.tr/en/run-tmp-from-memory-for-faster-performance/#respond</comments>
		
		<dc:creator><![CDATA[ckaraca]]></dc:creator>
		<pubDate>Wed, 27 Apr 2011 15:10:54 +0000</pubDate>
				<category><![CDATA[Linux Optimization]]></category>
		<category><![CDATA[/tmp]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[ramfs]]></category>
		<category><![CDATA[session]]></category>
		<guid isPermaLink="false">http://www.plugged.in/?p=138</guid>

					<description><![CDATA[<p>Running /tmp partition makes great performance enhancements as soon as you store temprorary information, please be aware that you mustn&#8217;t store valuable data as a reboot will flush all the data inside. /tmp &#38; /var/tmp runs faster from RAM, to do so: vi /etc/fstab Switch to Insert mode by pressing I or INSERT button on [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.veriteknik.net.tr/en/run-tmp-from-memory-for-faster-performance/">Run /tmp from memory for faster performance</a> appeared first on <a rel="nofollow" href="https://www.veriteknik.net.tr/en/">VeriTeknik</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p style="text-align: justify;">Running <strong>/tmp</strong> partition makes great performance enhancements as soon as you store temprorary information, please be aware that you mustn&#8217;t store valuable data as a reboot will flush all the data inside.</p>
<p style="text-align: justify;"><strong>/tmp &amp; /var/tmp runs faster from RAM, </strong>to do so:</p>
<blockquote>
<div>vi /etc/fstab</div>
</blockquote>
<div style="text-align: justify;">Switch to Insert mode by pressing I or INSERT button on keyboard and comment out /tmp partition if you already have one with a # and enter the information below:</div>
<blockquote>
<div>tmpfs                   /tmp                    tmpfs   defaults,noatime,mode=1777 0 0<br />
tmpfs                   /var/tmp                tmpfs defaults,noatime,mode=1777 0 0</div>
</blockquote>
<p style="text-align: justify;">save the file by pressing<strong> ESC and SHIFT ZZ</strong> or <strong>ESC + wq</strong> and type &#8220;<strong>mount -a</strong>&#8221; to apply the changes immediately. You can check the results by typing &#8220;<strong>df -h</strong>&#8221; and you will see something similar to below one:</p>
<blockquote>
<div>Filesystem            Size  Used Avail Use% Mounted on<br />
/dev/hdb5              50G  5.0G   43G  11% /<br />
/dev/hdb1              99M   24M   71M  25% /boot<br />
tmpfs                 1.5G     0  1.5G   0% /dev/shm<br />
<strong>tmpfs                 1.5G     0  1.5G   0% /tmp</strong><br />
<strong>tmpfs                 1.5G     0  1.5G   0% /var/tmp</strong></div>
</blockquote>
<div>Please note that, all your data and sessions will be gone when you switch to/from ramfs.</div>
<div><strong><span style="color: #ff0000;"><strong>IMPORTANT NOTE:</strong></span> </strong>This document is prepared for CentOS 5.6 and ment to work with other versions and distros.Never assume the directory structures exist in your system as written in the document. Never blindly follow security instructions — read, review, compare, apply as it fits your system.<strong><br />
</strong></div>
<p>The post <a rel="nofollow" href="https://www.veriteknik.net.tr/en/run-tmp-from-memory-for-faster-performance/">Run /tmp from memory for faster performance</a> appeared first on <a rel="nofollow" href="https://www.veriteknik.net.tr/en/">VeriTeknik</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.veriteknik.net.tr/en/run-tmp-from-memory-for-faster-performance/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">138</post-id>	</item>
	</channel>
</rss>
