存档在 ‘【技术】’ 分类

怎样部署安装Sphinx

2017年3月7日

参考:http://amon.org/dedecms-sphinx

参考:https://www.zybuluo.com/lxjwlt/note/141406
参考:https://www.jiloc.com/?s=sphinx

怎样开启QQ在线状态

2017年2月28日

参考:http://admin.54kefu.net/qqset.html

QQ在线服务规则改了,导致点击之后,出现提示:

亲爱的用户:

对方“QQ在线状态”服务尚未启用,您需要添加对方为好友后才能与其进行会话。

您也可邀请对方到 “QQ在线状态”官网 开启服务。

1. 打开 http://shang.qq.com/v3/widget.html
2. 免费开通通讯组件
3. 点击“设置”,勾选全部回话能力,“安全级别设置”为公开。

在网页中加入:


联系客服

即可不必加为好友也可在线临时QQ对话。

报错: nslookup: command not found

2017年2月25日

nslookup是常用来查询本机域名解析情况的命令。

通过安装bind-utils包来使该命令生效,这个包中也包括dig命令。

yum -y install bind-utils

报错:libtool: command not found

2017年2月22日

参考:http://www.baike.com/wiki/libtool

yum安装:

yum install libtool

怎样编译安装PHP5.2.17和ZendOptimizer3.3.9

2017年2月21日

参考:http://amon.org/php72

由于某些程序不支持php5.2以上的版本,需要安装php5.2.17和ZendOptimizer3.3.9。

参考:http://www.cnblogs.com/52php/p/5668848.html

参考:http://kimsom.com/article/363
下载:http://pan.baidu.com/s/1hrLA4gW

参考:http://blog.chinaunix.net/uid-20653538-id-375795.html
参考:http://www.blogjava.net/xiaomage234/archive/2010/11/25/339028.html
参考:https://my.oschina.net/liting/blog/383459

【创建SWAP】

参考:http://amon.org/swap

【更新系统】

yum update

【安装编译工具和依赖包等】

综合:

yum install yum-utils perl dos2unix apr apr-devel apr-util apr-util-devel curl curl-devel libcurl libcurl-devel wget gcc gcc-c++ flex git zip icu unzip libtiff-devel pam-devel libtool libtool-ltdl libtool-ltdl-devel bison bison-devel libxslt libxslt-devel ncurses ncurses-devel bzip2 bzip2-devel bzip2-libs libpsl libicu libjpeg libjpeg-devel unixODBC-devel net-snmp net-snmp-devel openldap-devel openldap-servers openldap-clients mhash-devel readline-devel libedit-devel sqlite-devel libffi libffi-devel guile guile-devel gmp gmp-devel gettext gettext-devel libidn libidn-devel unbound unbound-devel help2man texlive gtk-doc texinfo autogen autoconf mailcap git2cl gperf libev libev-devel jemalloc jemalloc-devel Cython setuptool trousers trousers-devel python python-devel patch

No package libpsl available.
No package mhash-devel available.
No package git2cl available.
No package jemalloc available.
No package jemalloc-devel available.

【安装Apache 2.2.32】

参考:http://amon.org/apache
参考:http://www.linuxfromscratch.org/blfs/view/svn/server/apache

下载:http://archive.apache.org/dist/httpd/

2.2版本:Apache 2.2.32 (2017-01-13)。

wget http://archive.apache.org/dist/httpd/httpd-2.2.32.tar.gz && tar -zxvf httpd-2.2.32.tar.gz && cd httpd-2.2.32
./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=most --with-crypto --enable-rewrite --enable-headers --enable-deflate --enable-socache-shmcb --enable-negotiation --enable-ssl --with-ssl=/usr/lib
make && make install

查看版本:

/usr/local/apache2/bin/httpd -v

输出:

Server version: Apache/2.2.32 (Unix)
Server built:   Mar 20 2018 08:37:43

安装CGI支持:

参考:http://amon.org/perl

cd modules/generators
/usr/local/apache2/bin/apxs -i -a -c mod_cgi.c
/usr/local/apache2/bin/apxs -i -a -c mod_cgid.c

查看下配置文件 httpd.conf ,发现cgi与cgid模块已被加载:

...
LoadModule cgi_module         modules/mod_cgi.so
LoadModule cgid_module        modules/mod_cgid.so

创建 www 用户

groupadd www && useradd -g www -s /sbin/nologin -M www

设置启动命令:

将Apache设成系统服务:

cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd

编辑 /etc/init.d/httpd,在第二行加入:

# chkconfig: 2345 85 15
# description: httpd is web server

把Apache添加到系统的启动服务组里:

chkconfig --add httpd && chkconfig --level 35 httpd on

输入命令:

service httpd start

输出:

httpd: Could not reliably determine the server's fully qualified domain name, using vultr.guest for ServerName

没关系,这是因为没有在httpd.conf中设置主机名,在后面再处理。

设为开机启动:

chkconfig httpd on

编译安装完成。

【安装MySQL】

参考:http://amon.org/mysql

【安装PHP 5.2.17】

第一步:安装系统环境需要的软件

yum install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-libs krb5-devel krb5-server libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
yum install libxml2 libxml2-devel openssl openssl-devel curl curl-devel libjpeg libjpeg-devel gd gd-devel bzip2 bzip2-devel libmcrypt libmcrypt-devel libmhash libmhash-devel

第二步:编译安装PHP-5.2.17所需要的库

编译安装libiconv

参考:http://amon.org/libiconv

编译安装mcrypt

参考:http://amon.org/mcrypt

第三步:编译安装PHP-5.2.17

下载:http://php.net/releases/index.php

参考:http://serverfault.com/questions/272241/apache2-and-php5-wont-work-together

wget http://museum.php.net/php5/php-5.2.17.tar.gz && tar zxvf php-5.2.17.tar.gz

或:

wget http://museum.php.net/php5/php-5.2.17.tar.bz2 && tar jxvf php-5.2.17.tar.bz2

打补丁:

参考:http://bbs.chinaunix.net/archiver/tid-3668293.html
参考:https://sourceforge.net/projects/mapn/

yum install patch
wget http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz && gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1
wget https://downloads.sourceforge.net/project/mapn/patch/php-5.2.17-max-input-vars.patch && cd php-5.2.17 && patch -p1 < ../php-5.2.17-max-input-vars.patch
sed -i "s/\!png_check_sig (sig, 8)/png_sig_cmp (sig, 0, 8)/" ext/gd/libgd/gd_png.c && ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so && ln -s /usr/lib64/libpng.so /usr/lib/libpng.so

参考:http://www.cnblogs.com/antarctican/p/3752812.html
参考:http://stackoverflow.com/questions/12671148/compile-php-with-ldap

ln -s /usr/lib64/liblber* /usr/lib/
cp -frp /usr/lib64/libldap* /usr/lib/
cd php-5.2.17
curl -o php-5.2.17.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt && patch -p0 -b < php-5.2.17.patch

参考:

cd php-5.2.17 && curl -o php-5.x.x.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt && patch -p0 -b < php-5.x.x.patch

参考:http://www.cnblogs.com/hojor/p/3230739.html
参考:http://blog.csdn.net/wildwild1/article/details/7763644
参考:https://forums.cpanel.net/threads/easy-apache-compile-error-with-enable-extention-mysqli-on-cloudlinux.362552/
参考:https://www.webmasterworld.com/forum88/7177.htm
参考:http://blog.sina.com.cn/s/blog_66e4076401011z0s.html
参考:https://forums.cpanel.net/threads/easy-apache-compile-error-with-enable-extention-mysqli-on-cloudlinux.362552/
参考:http://stackoverflow.com/questions/20266246/unable-to-compile-php-5-2-with-mysqli-extension

开始编译PHP:

确认curl位置:

whereis curl

输出:

curl: /usr/bin/curl /usr/include/curl

开始编译:

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql/ --with-iconv-dir=/usr/local --with-apxs2=/usr/local/apache2/bin/apxs --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl=/usr/bin/curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap
make ZEND_EXTRA_LIBS='-liconv'
make install

如果报错:dlname not found in /usr/local/apache2/modules/libphp5.la.

Installing PHP SAPI module:       apache2handler
/usr/local/apache2/build/instdso.sh SH_LIBTOOL='/usr/lib64/apr-1/build/libtool' libphp5.la /usr/local/apache2/modules
/usr/lib64/apr-1/build/libtool --mode=install cp libphp5.la /usr/local/apache2/modules/
libtool: install: cp .libs/libphp5.lai /usr/local/apache2/modules/libphp5.la
libtool: install: cp .libs/libphp5.a /usr/local/apache2/modules/libphp5.a
libtool: install: chmod 644 /usr/local/apache2/modules/libphp5.a
libtool: install: ranlib /usr/local/apache2/modules/libphp5.a
libtool: install: warning: remember to run `libtool --finish /root/php-5.2.17/libs'
Warning!  dlname not found in /usr/local/apache2/modules/libphp5.la.
Assuming installing a .so rather than a libtool archive.
chmod 755 /usr/local/apache2/modules/libphp5.so
chmod: cannot access ‘/usr/local/apache2/modules/libphp5.so’: No such file or directory
apxs:Error: Command failed with rc=65536
.
make: *** [install-sapi] Error 1

参考:https://www.linuxquestions.org/questions/linux-software-2/cannot-access-%60-usr-local-apache2-modules-libphp5-so%27-384689/
参考:http://hudeyong926.iteye.com/blog/1059390
参考:https://bugs.php.net/bug.php?id=27795#c83708

如果没有先安装MySQL,不能启用mysqli:

ext/mysqli/mysqli.o: In function `php_local_infile_init':
/root/php-5.2.17/ext/mysqli/mysqli.c:1064: undefined reference to `client_errors  '
ext/mysqli/mysqli.o: In function `php_local_infile_read':
/root/php-5.2.17/ext/mysqli/mysqli.c:1113: undefined reference to `client_errors  '
ext/mysqli/mysqli.o: In function `php_local_infile_error':
/root/php-5.2.17/ext/mysqli/mysqli.c:1175: undefined reference to `client_errors  '
collect2: error: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1

那么去掉:

--with-mysqli=/usr/local/mysql/bin/mysql_config 

参考:http://stackoverflow.com/questions/20266246/unable-to-compile-php-5-2-with-mysqli-extension
参考:http://blog.sina.com.cn/s/blog_67dd1efa0100jkkn.html
参考:http://blog.csdn.net/suppress/article/details/5329810

cp php.ini-dist /usr/local/php/etc/php.ini

第四步:编译安装PHP5扩展模块

编译安装memcache

官网:http://www.php.net/memcache
下载:https://pecl.php.net/package/memcache

wget https://pecl.php.net/get/memcache-2.2.6.tgz && tar zxvf memcache-2.2.6.tgz && cd memcache-2.2.6
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

编译安装eaccelerator

官网:http://eaccelerator.net/
下载:https://sourceforge.net/projects/eaccelerator/files/eaccelerator/

wget https://sourceforge.net/projects/eaccelerator/files/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.tar.bz2 && tar jxvf eaccelerator-0.9.6.1.tar.bz2 && cd eaccelerator-0.9.6.1
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config --without-eaccelerator-use-inode
make && make install

编译安装PDO_MYSQL

官网:http://php.net/pdo
下载:https://pecl.php.net/package/PDO

wget  http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz && tar zxvf PDO_MYSQL-1.0.2.tgz && cd PDO_MYSQL-1.0.2
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql/
make && make install

参考:http://www.92csz.com/30/1232.html

编译安装ImageMagick

官网:https://sourceforge.net/projects/imagemagick/
下载:https://sourceforge.net/projects/imagemagick/files/

wget https://jaist.dl.sourceforge.net/project/imagemagick/old-sources/6.x/6.8/ImageMagick-6.8.8-10.tar.gz && tar zxvf ImageMagick-6.8.8-10.tar.gz && cd ImageMagick-6.8.8-10
./configure && make && make install
ln -s /usr/local/include/ImageMagick-6 /usr/local/include/ImageMagick

编译安装imagick

官网:http://php.net/imagick
下载:https://pecl.php.net/package/imagick

wget https://pecl.php.net/get/imagick-3.0.1.tgz && tar zxvf imagick-3.0.1.tgz && cd imagick-3.0.1
/usr/local/php/bin/phpize && ./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

第五步:修改php.ini文件

sed -i "s/output_buffering = Off/output_buffering = On/" /usr/local/php/etc/php.ini
sed -i "s/extension_dir =/; extension_dir =/" /usr/local/php/etc/php.ini
sed -i "s/; cgi.fix_pathinfo=0/cgi.fix_pathinfo=0/" /usr/local/php/etc/php.ini
sed -i 's%;open_basedir =%open_basedir ="/tmp/:/usr/local/apache2/htdocs/"%' /usr/local/php/etc/php.ini
sed -i "s/disable_functions =/disable_functions = popen,pentl_exec,passthru,exec,system,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,show_source,escapeshellcmd,escapeshellarg,curl_exec,curl_multi_exec,parse_ini_file,assert/" /usr/local/php/etc/php.ini
sed -i "s/expose_php = On/expose_php = Off/" /usr/local/php/etc/php.ini
sed -i "s/display_errors = On/display_errors = Off/" /usr/local/php/etc/php.ini
sed -i "s/log_errors = Off/log_errors = On/" /usr/local/php/etc/php.ini

创建www用户及启动php-fpm并加入启动脚本

/usr/sbin/groupadd www
/usr/sbin/useradd -g www www
chown -R www:www /usr/local/apache2/htdocs
chmod +w /usr/local/apache2/htdocs

注:这里的/usr/local/apache2/htdocs/是网站目录,可以根据实际情况修改。

第七步:安装ZendOptimizer 3.3.9

解压ZendOptimizer 3.3.9,并复制ZendOptimizer.so到/usr/local/Zend/lib/

wget http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
tar -zxvf ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz && cd ZendOptimizer-3.3.9-linux-glibc23-x86_64
cd data/5_2_x_comp && mkdir -p /usr/local/Zend/lib && cp ZendOptimizer.so /usr/local/Zend/lib/

注:/usr/local/Zend/lib/这个目录可以自定义。

在/usr/local/php/etc/php.ini文件尾部添加

[Zend]
zend_optimizer.optimization_level=1023
zend_optimizer.encoder_loader=1
zend_extension=/usr/local/Zend/lib/ZendOptimizer.so

第八步:安装完成

查看PHP版本。

/usr/local/php/bin/php -v

结果如下:

PHP 5.2.17p1 (cli) (built: Feb 22 2017 04:00:57)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
    with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies

第九步:安装phpmyadmin

参考:http://amon.org/phpmyadmin