Currently Viewing Posts Tagged Centos

Remove Old Kernels on CentOS

I know how to remove old Kernels on Ubuntu. But, I don’t know how to do it on CentOS. After googling, I found answer.

Go through and see how many kernels here.

[root@juntixiao ~]# rpm -q kernel
kernel-2.6.32-573.3.1.el6.x86_64
kernel-2.6.32-573.7.1.el6.x86_64
kernel-2.6.32-573.8.1.el6.x86_64

Three kernels in machine.

Delete, remove old kernels.

Continue reading “Remove Old Kernels on CentOS”

How to use Sphinx Search Engine on phpBB 3.1.6

This how-to is made on Centos6.7 64bit. It is a phpBB forum in Chinese with more than 680K posts. If I use phpBB native Fulltext or MySQL Fulltext search, the search tables are over 1.4GB. Too big. And it is very slow when do the search.

Now, my solution is use Sphinx Search Engine.

Step 1)

SSH to VPS as root

yum install sphinx

Step 2)

Sign in with Administrator account in phpBB 3.1.6, and sign in again to ACP

General >> Search settings

Choose Sphinx Fulltext from the Search backend list. Save.

Step 3)

In SSH window, edit /etc/sphinx/sphinx.conf

Add following into sphinx.conf to replace the original sample content. These content is copied from the Step 2 screen.


source source_phpbb_669b8066d06af641_main
{
type = mysql # mysql or pgsql
sql_host = localhost # SQL server host sphinx connects to
sql_user = [dbuser]
sql_pass = [dbpassword]
sql_db = fromchinatousa31x
sql_port =  # optional, default is 3306 for mysql and 5432 for pgsql
sql_query_pre = SET NAMES 'utf8'
sql_query_pre = UPDATE phpbb_sphinx SET max_doc_id = (SELECT MAX(post_id) FROM phpbb_posts) WHERE counter_id = 1
sql_query_range = SELECT MIN(post_id), MAX(post_id) FROM phpbb_posts
sql_range_step = 5000
sql_query = SELECT \
p.post_id AS id, \
p.forum_id, \
p.topic_id, \
p.poster_id, \
p.post_visibility, \
CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post, \
p.post_time, \
p.post_subject, \
p.post_subject as title, \
p.post_text as data, \
t.topic_last_post_time, \
0 as deleted \
FROM phpbb_posts p, phpbb_topics t \
WHERE \
p.topic_id = t.topic_id \
AND p.post_id >= $start AND p.post_id <= $end
sql_query_post =
sql_query_post_index = UPDATE phpbb_sphinx SET max_doc_id = $maxid WHERE counter_id = 1
sql_query_info = SELECT * FROM phpbb_posts WHERE post_id = $id
sql_attr_uint = forum_id
sql_attr_uint = topic_id
sql_attr_uint = poster_id
sql_attr_uint = post_visibility
sql_attr_bool = topic_first_post
sql_attr_bool = deleted
sql_attr_timestamp = post_time
sql_attr_timestamp = topic_last_post_time
sql_attr_string = post_subject
}
source source_phpbb_669b8066d06af641_delta : source_phpbb_669b8066d06af641_main
{
sql_query_pre =
sql_query_range =
sql_range_step =
sql_query = SELECT \
p.post_id AS id, \
p.forum_id, \
p.topic_id, \
p.poster_id, \
p.post_visibility, \
CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post, \
p.post_time, \
p.post_subject, \
p.post_subject as title, \
p.post_text as data, \
t.topic_last_post_time, \
0 as deleted \
FROM phpbb_posts p, phpbb_topics t \
WHERE \
p.topic_id = t.topic_id \
AND p.post_id >=  ( SELECT max_doc_id FROM phpbb_sphinx WHERE counter_id=1 )
}
index index_phpbb_669b8066d06af641_main
{
path = /home/admin/sphinx-forum/index_phpbb_669b8066d06af641_main
source = source_phpbb_669b8066d06af641_main
docinfo = extern
morphology = none
stopwords =
min_word_len = 2
charset_type = utf-8
charset_table = U+FF10..U+FF19->0..9, 0..9, U+FF41..U+FF5A->a..z, U+FF21..U+FF3A->a..z, A..Z->a..z, a..z, U+0149, U+017F, U+0138, U+00DF, U+00FF, U+00C0..U+00D6->U+00E0..U+00F6, U+00E0..U+00F6, U+00D8..U+00DE->U+00F8..U+00FE, U+00F8..U+00FE, U+0100->U+0101, U+0101, U+0102->U+0103, U+0103, U+0104->U+0105, U+0105, U+0106->U+0107, U+0107, U+0108->U+0109, U+0109, U+010A->U+010B, U+010B, U+010C->U+010D, U+010D, U+010E->U+010F, U+010F, U+0110->U+0111, U+0111, U+0112->U+0113, U+0113, U+0114->U+0115, U+0115, U+0116->U+0117, U+0117, U+0118->U+0119, U+0119, U+011A->U+011B, U+011B, U+011C->U+011D, U+011D, U+011E->U+011F, U+011F, U+0130->U+0131, U+0131, U+0132->U+0133, U+0133, U+0134->U+0135, U+0135, U+0136->U+0137, U+0137, U+0139->U+013A, U+013A, U+013B->U+013C, U+013C, U+013D->U+013E, U+013E, U+013F->U+0140, U+0140, U+0141->U+0142, U+0142, U+0143->U+0144, U+0144, U+0145->U+0146, U+0146, U+0147->U+0148, U+0148, U+014A->U+014B, U+014B, U+014C->U+014D, U+014D, U+014E->U+014F, U+014F, U+0150->U+0151, U+0151, U+0152->U+0153, U+0153, U+0154->U+0155, U+0155, U+0156->U+0157, U+0157, U+0158->U+0159, U+0159, U+015A->U+015B, U+015B, U+015C->U+015D, U+015D, U+015E->U+015F, U+015F, U+0160->U+0161, U+0161, U+0162->U+0163, U+0163, U+0164->U+0165, U+0165, U+0166->U+0167, U+0167, U+0168->U+0169, U+0169, U+016A->U+016B, U+016B, U+016C->U+016D, U+016D, U+016E->U+016F, U+016F, U+0170->U+0171, U+0171, U+0172->U+0173, U+0173, U+0174->U+0175, U+0175, U+0176->U+0177, U+0177, U+0178->U+00FF, U+00FF, U+0179->U+017A, U+017A, U+017B->U+017C, U+017C, U+017D->U+017E, U+017E, U+0410..U+042F->U+0430..U+044F, U+0430..U+044F, U+4E00..U+9FFF
min_prefix_len = 0
min_infix_len = 0
}
index index_phpbb_669b8066d06af641_delta : index_phpbb_669b8066d06af641_main
{
path = /home/admin/sphinx-forum/index_phpbb_669b8066d06af641_delta
source = source_phpbb_669b8066d06af641_delta
}
indexer
{
mem_limit = 40M
}
searchd
{
compat_sphinxql_magics = 0
listen = 127.0.0.1:9312
log = /home/admin/sphinx-forum/log/searchd.log
query_log = /home/admin/sphinx-forum/log/sphinx-query.log
read_timeout = 5
max_children = 30
pid_file = /home/admin/sphinx-forum/searchd.pid
max_matches = 20000
binlog_path = /home/admin/sphinx-forum/
}

Continue reading “How to use Sphinx Search Engine on phpBB 3.1.6”

Problem opening package openssl-1.0.1e-30.el6_6.5.x86_64.rpm

I have a CentOs server. There is an error when I try to update the system.

openssl-error

error: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: BAD
Problem opening package openssl-1.0.1e-30.el6_6.5.x86_64.rpm

The server version is 64bit CentOs 6.6.
The way to solve this problem is here:

Continue reading “Problem opening package openssl-1.0.1e-30.el6_6.5.x86_64.rpm”

How to solve “Cannot retrieve metalink for repository: epel” Error in Centos 6

The server is CentOS 6.6 64bit. When I try ot run yum update the error shown as below:

Loaded plugins: fastestmirror, security
Determining fastest mirrors
Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again

The way to solve the problem is to edit

/etc/yum.repos.d/epel.repo

Modify https and replace them by http
Save it then run yum update.

Install Crontab on CentOS 5.11

Now I have a old CentOS distribution installation on one of my VPS. It is CentOS 5.11.

I use Crontab for schedule jobs. When I install this VPS and try to config crontab, I can not find it in Webmin. crontab is installed.

After google it and finally found the answer.

I have to install vixie-cron package. So run following command as root.

 

1) Install vixie-cron

yum install vixie-cron

2)Start Crond service

service crond start

3) Make it auto start on boot

chkconfig crond on

At last, I refresh the modules in Webmin. The link of configuration shows:
scheduled-cron-jobs

Install Multiple Version of PHP on CentOS 6.5 as Fastcgi

It is a guide of how to install multiple version of PHP on CentOS 6.5 64bit. All different PHP as fastcgi.
It is works on Apache, one web server, each virtualhost has its own different php version support.

0) Prepare the testing environment

Disable SELinux and stop iptables. It is for testing environment. For production machine, you should implement firewall carefully.

setenforce 0
service iptables stop

1) Enable rpmforge and epel yum repository

wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm

2) Install required dev packages and Apache, mod_fcgid

yum install gcc libxml2-devel bzip2-devel zlib-devel \
    curl-devel libmcrypt-devel libjpeg-devel \
    libpng-devel gd-devel mysql-devel
yum install httpd mod_fcgid 

3) Create the system startup links for Apache and start it:

chkconfig --levels 235 httpd on
/etc/init.d/httpd restart 

4) Compile and install php 5.5.12

wget http://us1.php.net/get/php-5.5.12.tar.gz/from/this/mirror
tar -xvzf mirror
cd php-5.5.12
./configure --prefix=/usr/local/php55 \
    --with-config-file-path=/etc/php55 \
    --with-config-file-scan-dir=/etc/php55/php.d \
    --with-libdir=lib64 \
    --with-mysql \
    --with-mysqli \
    --enable-mbstring \
    --disable-debug \
    --disable-rpath \
    --with-bz2 \
    --with-curl \
    --with-gettext \
    --with-iconv \
    --with-openssl \
    --with-gd \
    --with-mcrypt \
    --with-pcre-regex \
    --with-zlib \
    --enable-cgi
make 
make install
mkdir /etc/php55
cp php.ini-production /etc/php55/php.ini

Edit php.ini

vi /etc/php55/php.ini

Add the following in the end of the file

cgi.fix_pathinfo = 1

Restart Apache

service httpd restart

5) Creating Vhosts For web1.example.com

5.1) Create user and group

groupadd web1
useradd -s /bin/false -d /var/www/web1 -m -g web1 web1
chmod 755 /var/www/web1

5.2) Then we create the document roots and make them owned by the users/groups web1:

mkdir -p /var/www/web1/web
chown web1:web1 /var/www/web1/web

5.3) We will run PHP using suExec; suExec’s document root is /var/www, as the following command shows:

[root@localhost ~]# /usr/sbin/suexec -V
 -D AP_DOC_ROOT="/var/www"
 -D AP_GID_MIN=100
 -D AP_HTTPD_USER="apache"
 -D AP_LOG_EXEC="/var/log/httpd/suexec.log"
 -D AP_SAFE_PATH="/usr/local/bin:/usr/bin:/bin"
 -D AP_UID_MIN=500
 -D AP_USERDIR_SUFFIX="public_html"

5.4) create the wrapper scripts in subdirectories of /var/www/php-fcgi-scripts

mkdir -p /var/www/php-fcgi-scripts/web1
vi /var/www/php-fcgi-scripts/web1/php-fcgi-starter

Enter following into php-fcgi-starter

#!/bin/sh
PHPRC=/etc/
export PHPRC
export PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_CHILDREN=8
exec /usr/local/php55/bin/php-cgi

5.5) The php-fcgi-starter scripts must be executable, and they (and the directories they are in) must be owned by the web site’s user and group:

chmod 755 /var/www/php-fcgi-scripts/web1/php-fcgi-starter
chown -R web1:web1 /var/www/php-fcgi-scripts/web1

5.6) Create Vhost for web1.example.com

vi /etc/httpd/conf/httpd.conf
[...]
NameVirtualHost *:80

&lt;VirtualHost *:80&gt;
  ServerName web1.example.com
  DocumentRoot /var/www/web1/web/

  &lt;IfModule mod_fcgid.c&gt;
    SuexecUserGroup web1 web1
    &lt;Directory /var/www/web1/web/&gt;
      Options +ExecCGI
      AllowOverride All
      AddHandler fcgid-script .php
      FCGIWrapper /var/www/php-fcgi-scripts/web1/php-fcgi-starter .php
      Order allow,deny
      Allow from all
    &lt;/Directory&gt;
  &lt;/IfModule&gt;

  # ErrorLog /var/log/apache2/error.log
  # CustomLog /var/log/apache2/access.log combined
  ServerSignature Off

&lt;/VirtualHost&gt;

Restart Apache

service httpd restart

5.7) Now we create a small PHP test file

vi /var/www/web1/web/info.php

Add following content into it.

<?php
phpinfo();
?>

6) In Browser, you can see following infomation page.
web1-php55-fastcgi

 

7) Compile and install php 5.4.28 and php 5.3.28

Repeat the step 4, 5, and 6. Just change something respect to php 5.4.28 and php5.3.28.

7.1) php 5.4.28

http://us1.php.net/get/php-5.4.28.tar.gz/from/this/mirror

web2.example.com

/usr/local/php54

/etc/php54

user web2

group web2

web2-php54-fastcgi

 

7.2) php 5.3.28

http://us1.php.net/get/php-5.3.28.tar.gz/from/this/mirror

web3.example.com

/usr/local/php53

/etc/php53

user web3

group web3

web3-php53-fastcgi

Then, I have three hosts on the same one Apache web server at CentOS 6.5 64bit server.

Each host has its own php version installed, from 5.3 to 5.5.

So, you can use the above as a template.

Install multiple version of php on CentOS 6.5

This is a how-to of install php 5.3 an dphp 5.5 on one server, CentOS and use them simultaneously.

It is based on CentOS 6.5, 64bit for Apache only.

1) Enable rpmforge and epel yum repository


wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm

 

2) Install php 5.3

CentOS has php 5.3 built-in-box, simply install it with yum


yum install php php-mysql php-mbstring php-mcrypt

3) Compile and install php 5.5 from source

For php 5.5, we prefer to install it from source, the point is to install php at different location, which does not conflict with the php 5.3.

PHP 5.3 is installed as an apache module, we can only use one version of php at the same time. If we need to run different version of php at the same time, fastcgi and php-fpm works on it.

Build and install php 5.5 with fpm enabled, the latest version of php 5.5 is php 5.5.12.

3.1) Install required dev packages

yum install gcc libxml2-devel bzip2-devel zlib-devel \
	curl-devel libmcrypt-devel libjpeg-devel \
	libpng-devel gd-devel mysql-devel

3.2) Compile and install


wget http://ca2.php.net/get/php-5.5.12.tar.bz2/from/this/mirror

tar -xjf mirror

cd php-5.5.12
./configure --prefix=/usr/local/php55 \
	--with-config-file-path=/etc/php55 \
	--with-config-file-scan-dir=/etc/php55/php.d \
	--enable-fpm \
	--with-fpm-user=apache \
	--with-fpm-group=apache \
	--with-libdir=lib64 \
	--with-mysql \
	--with-mysqli \
	--enable-mbstring \
	--disable-debug \
	--disable-rpath \
	--with-bz2 \
	--with-curl \
	--with-gettext \
	--with-iconv \
	--with-openssl \
	--with-gd \
	--with-mcrypt \
	--with-pcre-regex \
	--with-zlib

make -j4 && sudo make install
mkdir /etc/php55
cp php.ini-production /etc/php55/php.ini
sed -i -e 's#php_fpm_CONF=\${prefix}/etc/php-fpm.conf#php_fpm_CONF=/etc/php55/php-fpm.conf#' \
	sapi/fpm/init.d.php-fpm
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod a+x /etc/init.d/php-fpm
/sbin/chkconfig --add php-fpm
/sbin/chkconfig php-fpm on
cp sapi/fpm/php-fpm.conf /etc/php55/

3.3) Configure php-fpm
Edit /etc/php55/php-fpm.conf, change some settings. This step is mainly to uncomment some settings.

vi /etc/php55/php-fpm.conf
pid = run/php-fpm.pid
listen = 127.0.0.1:9000
pm.max_children = 20
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 15

Then, start php-fpm

/etc/init.d/php-fpm start

3.4) Install and setup mod_fastcgi

yum install libtool httpd-devel apr-devel
wget http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz
tar -xzf mod_fastcgi-current.tar.gz
cd mod_fastcgi-2.4.6
cp Makefile.AP2 Makefile
make top_dir=/usr/lib64/httpd/ install
sh -c "echo 'LoadModule fastcgi_module modules/mod_fastcgi.so' > /etc/httpd/conf.d/mod_fastcgi.conf"

4) Prepare hosts and add web sites settings
4.1) Add the following line to /etc/hosts

127.0.0.1 php53.example.com php55.example.com

4.2) Create web document root and drop and index.php under it to show php information.

mkdir /var/www/fcgi-bin
for i in {1..2}; do
	web_root=/var/www/web$i
	mkdir $web_root
	echo "<?php phpinfo(); ?>" > $web_root/index.php
done

4.3) Create Apache config file(append it to httpd.conf)

vi /etc/httpd/conf/httpd.conf

Modify httpd.conf Per below

NameVirtualHost *:80

# module settings
# mod_fastcgi with php-fpm

<IfModule mod_fastcgi.c>
        FastCgiExternalServer /var/www/fcgi-bin/php-fpm -host 127.0.0.1:9000
</IfModule>

# virtual hosts...

#################################################################
#1st virtual host, use mod_php, run php-5.3.3
#################################################################
<VirtualHost *:80>
        ServerName php53.example.com
        DocumentRoot "/var/www/web1"

        <ifmodule mod_php5.c>
                <FilesMatch \.php$>
                        AddHandler php5-script .php
                </FilesMatch>
        </IfModule>

        <Directory "/var/www/web1">
                DirectoryIndex index.php index.html index.htm
                Options -Indexes FollowSymLinks
                Order allow,deny
                Allow from all
        </Directory>

</VirtualHost>

#################################################################
#2nd virtual host, use mod_fastcgi + php-fpm, run php-5.5.12
#################################################################
<VirtualHost *:80>
        ServerName php55.example.com
        DocumentRoot "/var/www/web2"


        <IfModule mod_fastcgi.c>
                ScriptAlias /fcgi-bin/ /var/www/fcgi-bin/
                AddHandler php5-fastcgi .php
                Action php5-fastcgi /fcgi-bin/php-fpm
        </IfModule>

        <Directory "/var/www/web2">
                DirectoryIndex index.php index.html index.htm
                Options -Indexes FollowSymLinks +ExecCGI
                Order allow,deny
                Allow from all
        </Directory>

</VirtualHost>

4.4) Restart apache. Visit these two sites and view phpinfo page.

service httpd restart

http://php53.example.com
php53-example
http://php55.example.com
php55-example

You can use the one of the virtual host as a template to create new virtual host.

Stop using Varnish Cache Server for the time being

I just disabled Varnish Server on this VPS. The varnish server version is v3.0.5.

The performance on my blog is improved, but not that much. And also sometimes it return 503 error.

There are a lot of other Varnish user said same 503 issues.

So, I stop using Varnish server for the time being.

 

And at the same time, I noticed that Varnish 4.0 released. I tried to install it on my Centos testing machine, Installation is fine. but I can not make it work. When I try to start varnish, it failed.

There are not many documents about Varnish 4.0. I will wait and see if I can use it later.

Varnish official site.

How to install Crontab in CentOS 6.5 64bit

Linode default CentOS 6.5 64bit deployment does not include Crontab or Cron Job. Here is a reference for the people like me.

Install the package and dependencies

#yum install vixie-cron

Enable the package on boot and start

# /sbin/chkconfig crond on
# /etc/init.d/crond start

crontab command option:

crontab: usage error: unrecognized option
usage:  crontab [-u user] file
crontab [-u user] [ -e | -l | -r ]
(default operation is replace, per 1003.2)
-e      (edit user’s crontab)
-l      (list user’s crontab)
-r      (delete user’s crontab)
-i      (prompt before deleting user’s crontab)
-s      (selinux context)

How to resolve yum update errors at CentOS 6.5

I have a CentOS installation on a VPS. When I try to update it through Webmin, it always give me some error looks like below:

Multilib version problems found, balabala..

libxml2-update-error

This error kept coming. There are always four updates can not be done. Actually two with two different version.

  • libxml2 i386 2.7.6-14.el6
  • libxml2 x86_64 2.7.6-14.el6
  • nss-softokn-freebl i386 3.14.3-9.el6
  • nss-softokn-freebl x86_64 3.14.3-9.el6

four-updates-not-done

The solution I googled as below:

rpm --nodeps -e nss-softokn-freebl.{i686,x86_64}

But, when I update with yum update command, yum is not working any more.

It said, libfreebl3.so is missing. I have to go to my another VPS with same version of CentOS 6.5. Found the file libfreebl3.so at /lib64/

Pages: 1 2

  • Archives