Linux

error removing addon domain from cpanel

Friday, October 22nd, 2010 | Linux | Comments Off

Recently I was unable to remove a domain from cpanel after firstly I deleted the dns zone for that domain (using whm)

The error was: “There was a problem removing the Addon Domain” and details of the error explained: “Error from park wrapper: Sorry, you do not control the domain exampledomain.com”

I used the following steps to remove the domain:

1. Remove domain.com from /var/cpanel/users/username
2. Run /scripts/updateuserdomains as root user on the server.
3. Remove /var/named/exampledomain.com.db
4. Remove the virtualhost for domain.com on /usr/local/apache/conf/httpd.conf
5. Remove exampledomain.com from /etc/named.conf

Simple as that!

Centos add additional repositories

Tuesday, October 12th, 2010 | Linux | Comments Off

yum install yum-priorities
edit all .repo files from /etc/yum.repos.d/ and add bellow:
[base], [addons], [updates], [extras], [centosplus]
priority=1

bellow [contrib]
priority=2

download RPMforge and check the file
rpm –import http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm -K rpmforge-release-0.5.1-1.el5.rf.*.rpm

install and check the installation
rpm -i rpmforge-release-0.5.1-1.el5.rf.*.rpm
yum check-update

done

Cpanel: change ssl port for apache

Friday, July 16th, 2010 | Linux | Comments Off

The title it’s choosen to have cpanel word in it because changing ssl port from 443 to something else directly in http.conf will bring trouble when you create a new account for instance (cpanel rebuilds http.conf automatically)

so keeping things short go to /var/cpanel and:

sudo vi cpanel.config

change apache_ssl_port=0.0.0.0:443 to apache_ssl_port=0.0.0.0:new_port
then:

sudo /usr/local/cpanel/whostmgr/bin/whostmgr2 --updatetweaksettings

protect server from high load

Friday, June 25th, 2010 | Linux | Comments Off

Bellow is a bash script that will save you a lot of energy and headaches when your server gets a high load. For instance if some of your clients / websites is going in an infinite loop because of a php programming bug it’s not worth waiting until your server crashes, you can use the script bellow to restart apache and all the php-cgi processes. (I use fastcgi on my server)

#!/bin/bash
MAXLOAD=”5″
L05=”$(uptime | gawk -F”load average: ” ‘{ print $2 }’ | gawk -F”, ” ‘{ print $1 }’)”
if [ $(echo "$L05 > $MAXLOAD"|bc) -eq 1 ]
then
unlink /tmp/message.txt
MESAJ=”/tmp/message.txt”
echo “I have restarted apache and all php-cgi processes” >> $MESAJ
/bin/mail -s “load mare $L05″ “mail@mymailserver.com” < $MESAJ
kill -9 `ps -ef |grep php-cgi |grep -v grep | awk ‘{print $2}’`
/etc/init.d/httpd restart
fi

Optimize your hosting server

Saturday, December 19th, 2009 | Linux | 1 Comment

A quick info of how you can optimize your hosting server if you are using a LAMP (Linux Apache Mysql PHP) environment.

I am keeping the info for reference, I will also try to update it but please not that’s not a complete list. Please comment if you have any opinions

1. use php as a fcgi module not as a dso module for apache
2. compile apache with mpm (Multi-Processing Module) worker that is capable to serve a large number of requests with less system resources than a process-based server.
3. use php eaccelerator it’s proven to be faster than apc and other cache systems
tweak it based on http://eaccelerator.net/wiki/Settings

that’s basically it :)

now some configuration parameters:
1. don’t use SymLinksIfOwnerMatch in your httpd.conf a lstat system call is made for each directory and it’s not cached
2. Tune MinSpareServers and MaxSpareServers so that Apache need not spawn more than 4 child processes per second (Apache can spawn a maximum of 32 child processes per second). When more than 4 children are spawned per second, a message will be logged in the ErrorLog.

to be continued…

Error while loading shared libraries: libmm.so.14

Saturday, December 19th, 2009 | Linux | Comments Off

As the title say, that’s an error message which I received when trying to compile a php version with mm as a ./configure option.

fixing it is as easy as checking debug.log in your php source directory, searching where the php is looking for libraries (mine was in /usr/local/lib64) and than just creating a symlink for libmm.so.14 to /usr/local/lib64

Don’t have libmm at all? Go to http://www.ossp.org/pkg/lib/mm/ and install the library.

Update: apparently in php.ini you need to uncomment the session save path directive as otherwise the default path is / which triggers a permission error. Because of this the mm session handler does not get registered with php

An apache php fastcgid suexec cpanel story

Sunday, December 13th, 2009 | Linux | Comments Off

I wanted to get fastcgid running on cpanel/whm, so I went to easyApache and selected to compile apche with fastcgid support and php with fastcgi support, but guess what – it wasn’t working! they just ignored the settings and php was compiled without fastcgi in it.

So back to the beggining, dreaming of my lost time figuring out what the heck was wrong with whm/cpanel/easyapache I turned to plan B.

I recompiled apache still with easyapache from whm but without php. Further more I also choosed MPM worker module to improve the way static content is served. (!!! mpm worker is not compatible with PHP as an apache module)

Next step I compiled php from source – see my other article regarding compiling php from source and checking what I used as ./configure command.

Note: if you don’t have mod_fcgid module installed do this command in the directory you extracted the mod_fcgid archive that you got from apache website:
./configure.apxs
make
make install

I went to httpd.cnf -> on my system was on /usr/local/apache/conf and added the following lines:


AddHandler fcgid-script .php
Options +ExecCGI
FcgidWrapper /home/user/php-wrapper .php
Order allow,deny
Allow from all

Now I create the wrapper that will execute the php:

cd /home/user
sudo vi php-wrapper

add this inside the file:

#!/bin/sh
exec /usr/local/php-5.3.2-fcgi/bin/php-cgi

then, some security aspects (it’s required by suexec and it’s nice organizing things a little):

sudo chown user.nobody php-wrapper
sudo chmod 550 php-wrapper
cd ..
sudo chown -R user.nobody user/public_html
sudo chmod -R 0750 user/public_html

as a real world example:
chown alex.nobody /home/alex/php-wrapper
chmod 550 /home/alex/php-wrapper
chown -R alex.nobody /home/alex/public_html
chmod -R 0750 /home/alex/public_html
chmod -R g+s /home/alex/public_html

!Make sure you change the path of the fcgid wrapper to fit your php directory you have just compiled.

make sure suexec is enabled (it’s installed by default in whm, and you can enabled from php&sexec configuration section)
Restart apache and that’s it, or should I say… good luck :)

Note: you need to learn how to optimize fcgid config variables and because mpm worker was also installed, it’s corresponding configuration variables as well. But till you do, the default will be just fine.

Please study the instructions and make sure you understand them before breaking a live server

Install php from source – custom path

Sunday, December 13th, 2009 | Linux | Comments Off

Hey guys,

Recently I wanted to give php 5.3.1 a go but without interferring with my current setup, so I choosed to run it as fcgi.
In order to do that I wanted to compile php from source, enabling the modules I needed (gd with jpg support), bmath, pdo, pdo_mysql (for magento) and so on

here we go:
1. go to php site and download your version
2. upload to your server and unarchive it somewhere :)
3. go using putty or something similar to where are the files extracted, enter the source directory
4. I used this command, change it per your needs:
./configure –enable-bcmath –enable-calendar –enable-fastcgi –disable-cli –enable-ftp –enable-gd-native-ttf –enable-libxml –enable-magic-quotes –enable-mbstring –enable-soap –enable-sockets –prefix=/usr/local/php-5.2.13-fcgi –with-curl=/opt/curlssl/ –with-jpeg-dir=/usr/lib –with-jpeg –with-png-dir=/usr/lib –with-libdir=lib64 –with-gd –with-mm –with-mcrypt=/opt/libmcrypt/ –with-mysql=/usr –with-mysql-sock=/var/lib/mysql/mysql.sock –with-mysqli=/usr/bin/mysql_config –with-openssl=/usr –with-openssl-dir=/usr –with-zlib –with-zlib-dir=/usr –enable-pdo –with-pdo-sqlite –with-sqlite –with-pdo-mysql=/usr –with-pdo-sqlite –enable-zend-multibyte –with-freetype-dir=/usr –with-gettext –with-ttf –enable-force-cgi-redirect –enable-sysvsem –enable-sysvshm
5. make
6. make install

make sure you rename and copy the development php.ini to the lib/php.ini

Install pdo_mysql – no recompiling php

Sunday, December 13th, 2009 | Linux | 1 Comment

I googled till 4 AM to check how can I enable/install pdo_mysql for magento without the need to reinstall php – as all posts pointed I should do
finally I get it working

From here I started:
1. I already had pdo
2. I hadn’t pdo_mysq;

so back to work (as root):
1. Download PDO_MYSQL from http://pecl.php.net/package/PDO_MYSQL
2. upload it to your server
3. run export PHP_PREFIX="/usr/local/php/"
4. run $PHP_PREFIX/bin/phpize
4. run ./configure '--with-pdo-mysql=shared,/usr' !! /usr was where my mysql was installed (not where the data of mysql are!)
5. make
6. make install
7. in your php.ini
8. add
extension_dir = "/usr/local/php/extensions/no-debug-non-zts-20060613"
extension=pdo_mysql.so

9. restart apache

Install eaccelerator from scratch – Centos

Sunday, December 13th, 2009 | Linux | Comments Off

1. download the source code and upload it to your server
2. execute
export PHP_PREFIX="/usr/local/php/"
where /usr/local/php/ is my path to where php is installed
3. $PHP_PREFIX/bin/phpize
4. ./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
5. make
6. make install
7. now go to php.ini and include this code:
zend_extension="/usr/local/php5.2.12-fcgi/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/tmp/eacc-php5.2.12-fcgi"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter="*.php"
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="7200"
eaccelerator.shm_prune_period="7200"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="8"
eaccelerator.keys = "shm"
eaccelerator.sessions = "shm"
eaccelerator.content = "shm"

make sure you change the extension path above to fit your php extension directory
8. restart apache