[国内VPS]CentOS6.2下安装php5.4.0,mysql-5.5.21,nginx-1.0.12的步骤记录,PHP5.4与Apache结合实现上传进度的安装配置,Nginx开机启动自动输入SSL启动密码。
后期问题
在虚拟机里出现在最后时卡住了,于是排查:按F2,发现两个问题:
问题1:
mounting local filesystem: mount: mount point vmhgfs does not exist
mounting other filesystems: mount: mount point vmhgfs does not exist
问题2:
PHP作为服务启动时老启动不起来,卡了,在最后,只好关闭:chkconfig php-fpm off
统一在脚本里启动:在/etc/init.d# vi lnmp
nohup service php-fpm start > /dev/null 2>&1 &
对Mountain出现不存在的错误屏蔽掉:
/etc# vi fstab
#host://mnt/hgfs vmhgfs defaults,user,ttl=5,uid=root,gid=root,fmask=0113,dmask=0002 0 0
------------------------------------------------------------问题得到解决。
2.0 安装快速备份命令bcp
bcp命令:https://github.com/RickieL/bcp/blob/master/bcp
用于快速备份文件或目录。
wget https://nodeload.github.com/RickieL/bcp/tarball/master -O bcp.tar.gz
tar xzf bcp.tar.gz
cd RickieL-bcp-f65e017
chmod +x bcp
mv bcp /bin/bcp
2.1 备份php.ini配置文件
bcp /usr/local/php5/lib/php.ini
2.2 备份php-fpm.conf配置文件
bcp /usr/local/php5/etc/php-fpm.conf
2.3 备份/etc/init.d/php-fpm 启动文件
bcp /etc/init.d/php-fpm
2.4 备份原来的整个程序目录:
bcp /usr/local/php5
centos5.5安装最新的LNMP:
一、获取相关开源程序:
1、【适用CentOS操作系统】利用CentOS Linux系统自带的yum命令安装、升级所需的程序库(RedHat等其他Linux发行版可从安装光盘中找到这些程序库的RPM包,进行安装):
yum install telnet -y
yum install lrzsz -y
yum install nc -y
yum install unzip -y
yum install wget -y
yum install sudo -y
嵌入式串口相关操作rpm包安装:
yum install setserial
yum install minicom
扯下串口这块的记录:
得到的串口信息:
setserial -a /dev/ttyS0
/dev/ttyS0, Line 0, UART: 16550A, Port: 0x03f8, IRQ: 4
Baud_base: 115200, close_delay: 50, divisor: 0
closing_wait: 3000
Flags: spd_normal skip_test
setserial /dev/ttyS0 port 0x03f8 irq 4 uart 16550A baud_base 9600
设置:
root@192.168.225.128:/home/jackxiang/com# setserial /dev/ttyS0 port 0x03f8 irq 4 uart 16550A baud_base 9600
再看设置成功了没?
root@192.168.225.128:/home/jackxiang/com# setserial -a /dev/ttyS0
/dev/ttyS0, Line 0, UART: 16550A, Port: 0x03f8, IRQ: 4
Baud_base: 9600, close_delay: 50, divisor: 0
closing_wait: 3000
Flags: spd_normal skip_test
其它setserial参数设置:
root@192.168.225.128:/home/jackxiang/c_com# setserial -g /dev/ttyS0
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
root@192.168.225.128:/home/jackxiang/c_com# setserial -gb /dev/ttyS0
/dev/ttyS0 at 0x03f8 (irq = 4) is a 16550A
root@192.168.225.128:/home/jackxiang/c_com# setserial -g -G /dev/ttyS0
/dev/ttyS0 uart 16550A port 0x03f8 irq 4 baud_base 9600 spd_normal skip_test
相关参考:http://phorum.study-area.org/index.php/topic,25440.0.html
http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/Serial-HOWTO.html
http://baike.baidu.com/view/245027.htm
关于minicom也就可以在这儿查看以前的记录:http://jackxiang.com/visit.php?job=viewresult&sid=f13e4b9a640d4c80db689fab5db06c16
开始正式安装这个Lnmp:
sudo -s
LANG=C
yum -y 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 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
RedHat AS4 系统环境,通常情况下缺少的支持包安装,64位和32位会自动识别:
yum install libjpeg-devel
yum install freetype-devel
yum install libpng-devel
CentOS下MySQL 5.7.9编译安装,安装成功:
https://blog.linuxeye.com/432.html
多行容易有问题,实践一行更好使:
mysql-8.0.0-dmr-Linux-x86_64
-- Downloading boost_1_60_0.tar.gz to /data/software/mysql-8.0.0-dmr/boost/boost_1_60_0/boost
-- [download 0% complete]
-- [download 1% complete]
直接不带boost版本的mysql安装包:
安装mysql最新版本:
tar -zxvf cmake-2.8.4.tar.gz
首先,需要下载安装Cmake;
wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.12.tar.gz/from/http://cdn.mysql.com/
安装cmake;
tar xvzf cmake-2.8.4.tar.gz
./configure
make
make install
http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.27.tar.gz
vi /etc/profile
PATH=$PATH:/usr/local/bin/
export PATH
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql/ \
-DMYSQL_DATADIR=/usr/local/webserver/mysql/data \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/usr/local/webserver/mysql/data/mysql.sock \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0
为了不做软链接编译时就指定mysql.sock到另外的位置:
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql/ \
-DMYSQL_DATADIR=/usr/local/webserver/mysql/data \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/data0/data/mysql.sock \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0
VPS实践如下:(2014-09-28)
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \
-DMYSQL_DATADIR=/data/mysql \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0
我在编译的时候报错,意思是 DMYSQL_USER=mysql无效,懒得找原因,直接把那个参数给去掉了,接着进行下面的操作;
make && make install
如果想要加入:Coreseek编译上有区别,且目前版本不能全兼容,试了下:mysql5.5.8是可以的,需要加入参数:-DCMAKE_BUILD_TYPE=Release -DWITH_SPHINX_STORAGE_ENGINE=1
具体请看:http://jackxiang.com/post/4317/ 【可能没法访问,我还没有整理完的缘故】
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
cp support-files/my-small.cnf /etc/my.cnf
chown mysql:mysql /etc/my.cnf
chown -R mysql:mysql /usr/local/webserver/mysql
切换用户进入安装目录:
su mysql
cd /usr/local/webserver/mysql/scripts
./mysql_install_db
下面技巧实践Ok:
如安装的源代码文件给丢失后,也可以用下面的方法直接初始化Mysql的mysql表,相当于:
/usr/local/webserver/mysql/scripts/mysql_install_db --user=mysql --datadir=/data0/data/ --basedir=/usr/local/webserver/mysql
/usr/local/webserver/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql
出现:[注意:这儿就是指定BaseDir函数的脚本的地方啦]
FATAL ERROR: Could not find ./bin/my_print_defaults
修改:
basedir="/usr/local/webserver/mysql"
builddir="/root/software/mysql-5.5.8"
解决方法[上面就是直接修改啦,下面是参数传入罢了]:
/usr/local/webserver/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/webserver/mysql --datadir=/usr/local/webserver/mysql/data &(这点非常重要)
如何修改basedir特别是vps里有两个盘时,把database放到另外一块盘上:
datadir = /data/datadir/mysql
innodb_log_group_home_dir = /data/datadir/mysql
root@*.10.6.23:/usr/local/mysql/bin# ./mysqladmin -umysql shutdown
cp -Rf /usr/local/mysql/var/* /data/datadir/mysql/.
root@*.10.6.23:/usr/local/mysql/bin# service mysql start
Starting MySQL. ERROR! The server quit without updating PID file (/data/datadir/mysql/ZWCLC6X-7198.pid).
MYSQL启动后报:ERROR! The server quit without updating PID file错误的问题解决
无法启动mysql,后来上网找了一下解决方法,无非就是以下几种
1. 注释/etc/my.cnf里的skip-federated注释掉即#skip-federated;
2. my.cnf文件配置过高,重新定义其中的参数(根据服务器情况定义);
3. 杀掉mysql_safe和mysqld进程,然后再重启;
4. 当前日志文件过大,超出了my.cnf中定义的大小(默认为64M),删除日志文件再重启;
但是在主机中:
1. 注释中无skip-federated这个选项
2. My.cnf是自己优化过的,断电之前正常使用,不是这个的问题
3. Ps –ef | grep mysql 根本就没有mysql的僵尸进程
4. 没有这个问题
基本上网上的所有方式都试过了,都无法解决问题,然后我就打开了error.log,发现了是磁盘空间不够。
http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=4141403
root@*.10.6.23:/data/datadir# chown -R mysql:root mysql
root@*.10.6.23:/data/datadir# service mysql start
Starting MySQL.. SUCCESS!
110327 3:07:33 InnoDB: Initializing buffer pool, size = 128.0M
110327 3:07:33 InnoDB: Completed initialization of buffer pool
在/etc/my.cnf 打开下面的InnoDB配置以减少内存即可:
default-storage-engine=MyISAM [注意:Mysql5.6.11放在server-id里不行,还是会报Plugin 'InnoDB' is disabled错,要往上挪挪:放socket = /data0/data/mysql.sock 后就行了。]
server-id = 1
innodb_buffer_pool_size = 21M
innodb_additional_mem_pool_size = 2M
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
启动:带--user=mysql
/usr/local/webserver/mysql/bin/mysqld_safe --user=mysql &
编译PHP前准备:libiconv PHP Mysql都用得到,不安会出现如下情况
本人在编译php5.2.8时候,make ZEND_EXTRA_LIBS='-liconv',出现下列错误提示
ext/gd/libgd/gdkanji.o: In function `do_convert':
/data0/software/php-5.2.8/ext/gd/libgd/gdkanji.c:350: undefined reference to `libiconv_open'
/data0/software/php-5.2.8/ext/gd/libgd/gdkanji.c:365: undefined reference to `libiconv'
........
........
........
/data0/software/php-5.2.8/ext/iconv/iconv.c:2491: undefined reference to `libiconv_open'
/usr/bin/ld: final link failed: No space left on device
collect2: ld returned 1 exit status
先这样:
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
./configure --prefix=/usr/local/libiconv
make;make install
后依旧的话,则再看下:
注意“/usr/bin/ld: final link failed: No space left on device
”,应该是磁盘空间不够所致,果然,我清空了部分内容,顺利通过编译!算是给大家提醒一下,希望大家不要出现下列错误!
最后可能是直接用了make,而不是:make ZEND_EXTRA_LIBS='-liconv' ...
以上是我在编译:5.3.8版本时发现的,后面编译完后在运行FastCGI时会提示:
Starting php-fpm [eAccelerator] This build of "eAccelerator" was compiled for PHP version 5.3.6. Rebuild it for your PHP version (5.3.8) or download precompiled binaries.
done
于是需要重新编译一次这个缓存插件:
cd eaccelerator-0.9.6.1
/usr/local/webserver/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
还有就是查看php.ini关于eaccelerator的配置:
[eaccelerator]
zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/usr/local/webserver/eaccelerator_cache"
........
然后根据上面的目录结构中去删除以前版本的缓存即可:
root@116.255.139.240:/usr/local/webserver/eaccelerator_cache# ls
0 1 2 3 4 5 6 7 8 9 a b c d e f
root@116.255.139.240:/usr/local/webserver/eaccelerator_cache# rm -Rf *
------------------------------------------------------------------------------------------------------------------------------------
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local
make
make install
cd ..
http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
wget http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../
http://sourceforge.net/projects/mhash/files/mhash/
wget http://nchc.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make
make install
cd ..
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
http://sourceforge.net/projects/mcrypt/files/MCrypt/
wget http://nchc.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
/sbin/ldconfig
./configure
make
make install
可能会出现:
=================================================================
configure: error: *** libmcrypt was not found
为了的到mcrypt.so库文件,先后安装编译了mhash和libmcrypt,但是到最后编译mcrypt时报错:
configure: error: *** libmcrypt was not found
最后发现是因为环境变量的问题,gcc编译的时候根据自身定义的变量寻找相关函数库等文件,libmcrypt也是刚安装的,在变量中没有定义出来,所以手动添加:
[root@localhost modules]# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
再次编译即可。
=================================================================
PHP5.3.9: wget http://cn.php.net/get/php-5.3.9.tar.gz/from/this/mirror
编译PHP:
wget http://cn.php.net/distributions/php-5.3.6.tar.gz
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local/libiconv --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 --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl
PHP7.0编译参数:
./configure --prefix=/usr/local/php7.0 --with-config-file-path=/usr/local/php7.0/etc --with-fpm-user=www --with-fpm-group=www --enable-fpm --disable-fileinfo --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif --enable-sysvsem --with-curl --enable-mbregex --enable-inline-optimization --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug --enable-opcache --with-readline
make时还是需要加上iconv那个:make ZEND_EXTRA_LIBS='-liconv',否则还是会报错,对于PHP7.0主PHP低的生产版本混合运行,把:
cp /etc/init.d/php-fpm拷贝到自己的home目录下修改一下路径,重新启动,这个脚本的启动参数打印了下,如下:
/usr/local/php7.0/sbin/php-fpm --daemonize --fpm-config /usr/local/php7.0/etc/php-fpm.conf --pid /usr/local/php7.0/var/run/php-fpm.pid
本次新加:
--with-pdo=shared -with-pdo-mysql=/usr/local/webserver/mysql
PHP想在一开始就把PDO编译进去,而不是直接加载PDO.so,在configure时可能会出现一个问题,如下:
checking for MySQL support for PDO... yes
checking for mysql_config... /usr/local/webserver/mysql/bin/mysql_config
checking for mysql_query in -lmysqlclient... no
checking for mysql_query in -lmysqlclient... (cached) no
configure: error: PDO_MYSQL configure failed. Please check config.log for more information.
引起的原因,Centos6.2最小化安装,没有安一个rpm包:mysql-level没有装,或者是mysql的版本不对。但Mysql我是通过源码安装的,于是,可以在目录 /usr/local/webserver/mysql/lib/ 找到以下需要的包,也就是最新的Mysql5.5.20编译好的这些库,如下:
[root@bogon lib]# echo ~+/libmysqlclient.
libmysqlclient.a libmysqlclient.so libmysqlclient.so.18 libmysqlclient.so.18.0.0
[root@bogon lib]# ls ~+/libmysqlclient.a
/usr/local/webserver/mysql/lib/libmysqlclient.a
export LDFLAGS=-L/usr/local/webserver/mysql/lib/
再次在PHP5.3.10下进行configure时,就不会提示PDO的相关问题了,但问题依旧,难道还是得要单独安装这个PDO模块!!
暂时不安PDO,先把所有用到的都给编译进PHP里去再说,如下:
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local/libiconv --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 --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --enable-soap=shared --enable-pdo enable-dom --with-readline --enable-xmlwriter --with-pcre-regex --with-pear --enable-session --enable-spl --enable-hash --enable-reflection
出现:configure: error: Please reinstall readline - I cannot find readline.h
解决方法:
yum install readline-devel
但又报错:php configure: error: readline library not found 干脆去掉这一个不常用的项目:
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local/libiconv --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 --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --enable-soap=shared --enable-pdo enable-dom --enable-xmlwriter --with-pcre-regex --with-pear --enable-session --enable-spl --enable-hash --enable-reflection
就configure通过了:
Thank you for using PHP.
make ZEND_EXTRA_LIBS='-liconv'
//如果是路径L不对得手动加参数:
make ZEND_EXTRA_LIBS='-liconv -L/usr/local/lib'
成功...
make install
/usr/bin/ld: ext/ldap/.libs/ldap.o: undefined reference to symbol 'ber_strdup'
/usr/bin/ld: note: 'ber_strdup' is defined in DSO /lib64/liblber-2.4.so.2 so try adding it to the linker command line
/lib64/liblber-2.4.so.2: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make: *** [sapi/cli/php] 错误 1
在老外的一篇文章中终于找到解决办法,我是在centos7下进行编译时遇到这个问题的:
-Run your configure command
-edit Makefile
-Find the line that starts with "EXTRA_LIBS ="
-Add the following to the end of the line " -llber"
cp php.ini-dist /usr/local/webserver/php/etc/php.ini
cd ../
刚开始就把SOAP编译进去:
Move into the source directory and configure PHP with SOAP enabled (this may take a few minutes):
cd php-5.2.5
./configure --enable-soap=shared
加上这个:
--enable-soap=shared
加上后是这样:
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local/libiconv --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 --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --enable-soap=shared
make ZEND_EXTRA_LIBS='-liconv'
PHP5.6.3 2014-11-30 编译成功备案:
编译php报错:/usr/bin/ld: cannot find -liconv解决方法:
首先检查libiconv是否有安装,其次,确认libiconv的安装目录为/usr/local,即编译参数
]#./configure --prefix=/usr/local
然后记得更新下库
]#ldconfig
在最后面添加 -liconv :
编辑:
./src/MakeFile文件
将
LIBS = -lm -lexpat -L/usr/local/lib
改成
LIBS = -lm -lexpat -liconv -L/usr/local/lib
vi /etc/ld.so.conf
这样php编译安装就可以正常运行了。
但有时还是会报错的:
||||||PHP的configure没加:--with-iconv=/usr/local/libiconv引发的/usr/bin/ld: cannot find -liconv||||||||
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv=/usr/local/libiconv --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-gettext --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --with-snmp --enable-shmop --enable-sysvsem --enable-sysvshm --enable-calendar --enable-inline-optimization --with-curl --with-curlwrappers --enable-exif --enable-sysvmsg --with-mcrypt --with-gd --enable-gd-jis-conv --disable-debug --with-openssl --with-mhash --enable-pcntl --silent --enable-sockets
make
make install
出现的原因是没加:--with-iconv=/usr/local/libiconv ,这个是编译时编译到那儿的:
------------------------------------------------------------------------------------------------------------------------------------------
解决方法:
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar -zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/libiconv
make
make install
------------------------------------------------------------------------------------------------------------------------------------------
~/software/php-5.3.15# ./configure --help|grep iconv
--without-iconv[=DIR] Exclude iconv support
--with-iconv-dir=DIR XMLRPC-EPI: iconv dir for XMLRPC-EPI
--with-iconv-dir:
用于 PHP 编译时指定 iconv 在系统里的路径,否则会扫描默认路径。
--with-iconv:
要激活这个扩展必须在编译时使用[DIR]
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
昨天编译安装PHP的时候make报错,make: *** [sapi/fpm/php-fpm] Error 1
/usr/bin/ld: cannot find -liconv
collect2: ld returned 1 exit status
make: *** [sapi/fpm/php-fpm] 错误 1
上面的方法还是没法解决,最后解决了,直接用make,没有用make ZEND_EXTRA_LIBS='-liconv'
不再提示cannot find -liconv,而是:error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory ,于是按以前的方法,如下:ln -s /usr/local/webserver/mysql/lib/libmysqlclient.so.18 /usr/lib/ ,再make一下,直接就过去了,Yeath.
原因iconv重复安装在不同目录,造成include文件iconv.h等重复 通过 find / -name “iconv.h” 如果查找到2个以上返回结果,说明 iconv重复安装了,卸载多余的版本即可正常编译。
[root@bogon /]# find / -name "iconv.h"
/usr/local/libiconv/include/iconv.h
/usr/include/iconv.h
果然是这个问题。
安装iconv是源码编译安装,于是到安装目录cd /usr/local/src/libiconv-1.13.1,执行 make uninstall卸载自己安装的版本。再重新安装PHP。
问题1:
You may want to add: /usr/local/webserver/php/lib/php to your php.ini include_path
/root/jackxiang.com/php-5.3.6/build/shtool install -c ext/phar/phar.phar /usr/local/webserver/php/bin
cp: cannot stat `ext/phar/phar.phar': No such file or directory
[vps实践]linux下安装php5.3.6的扩展包pear :http://jackxiang.com/post/4153/
(1)chmod: cannot access `ext/phar/phar.phar': No such file or directory:
wget http://pear.php.net/go-pear.phar
[root@localhost phar]# /usr/local/webserver/php/bin/php go-pear.phar
Below is a suggested file layout for your new PEAR installation. To
change individual locations, type the number in front of the
directory. Type 'all' to change all of them or simply press Enter to
accept these locations.
1. Installation base ($prefix) : /usr/local/webserver/php
2. Temporary directory for processing : /tmp/pear/install
3. Temporary directory for downloads : /tmp/pear/install
4. Binaries directory : /usr/local/webserver/php/bin
5. PHP code directory ($php_dir) : /usr/local/webserver/php/lib/php
6. Documentation directory : /usr/local/webserver/php/docs
7. Data directory : /usr/local/webserver/php/data
8. User-modifiable configuration files directory : /usr/local/webserver/php/cfg
9. Public Web Files directory : /usr/local/webserver/php/www
10. Tests directory : /usr/local/webserver/php/tests
11. Name of configuration file : /usr/local/webserver/php/etc/pear.conf
1-11, 'all' or Enter to continue: all
这个根据个人环境进行修改。(我是直接回车即可)
================================================
(2)chmod: cannot access `ext/phar/phar.phar': No such file or directory:
make: [ext/phar/phar.phar] Error 1 (ignored)
解决方法1:./configure的时候 要加上--without-pear
然后再make install或者重新make ZEND_EXTRA_LIBS='-liconv',Then :make install
解决方法2:
cd ext/phar/. cp ./phar.php phar.phar
问题2:
/root/jackxiang.com/php-5.3.6/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
make: *** [ext/phar/phar.php] Error 127
ln -s /usr/local/webserver/mysql/lib/libmysqlclient.so.18 /usr/lib/
PHP扩展:
memcache:
http://pecl.php.net/package/memcache
wget http://pecl.php.net/get/memcache-3.0.6.tgz
tar zxvf memcache-3.0.6.tgz
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../
eaccelerator:
wget http://bart.eaccelerator.net/source/0.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/webserver/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../
PDO_MYSQL:
http://pecl.php.net/package/PDO_MYSQL
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/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-pdo-mysql=/usr/local/webserver/mysql
make
make install
cd ../
ImageMagick:
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.6.8-8
./configure
make
make install
imagick:[依赖前面的ImageMagick,注意顺序]
wget http://pecl.php.net/get/imagick-3.1.0b1.tgz
tar -zxvf imagick-3.1.0b1.tgz
cd imagick-3.1.0b1
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../
修改php.ini文件:
cd /root/jackxiang.com/php-5.3.6
cp ./php.ini-production /usr/local/webserver/php/etc/php.ini
手工修改:查找/usr/local/webserver/php/etc/php.ini中的extension_dir = "./"
修改为extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/"
//各种PHP版本的extension_dir是不一样的!!!
并在此行后增加以下几行,然后保存:
extension = "memcache.so"
extension = "pdo_mysql.so"
extension = "imagick.so"
再查找output_buffering = Off
修改为output_buffering = On
[eaccelerator]
zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/usr/local/webserver/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="300"
eaccelerator.shm_prune_period="120"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
安装Nginx:
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.12.zip
tar zxvf pcre-7.8.tar.gz
cd pcre-8.12
./configure
make && make install
cd ../
wget http://nginx.org/download/nginx-0.9.6.tar.gz
wget http://nginx.org/download/nginx-1.0.2.tar.gz
cd nginx-0.9.6
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
cd ../
启动nginx:
/usr/local/webserver/nginx/sbin/nginx -c /usr/local/webserver/nginx/conf/nginx.conf
如果需要添加Nginx_HTTP_Push_Module长连接模块,需要加入新选项,/root/software/nginx_http_push_module-0.692是下载的模块文件位置:
--add-module=/root/software/nginx_http_push_module-0.692
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --add-module=/root/software/nginx_http_push_module-0.692
自己加入安全模块的编译选项:
./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --add-module=/root/software/nginx_http_push_module-0.692 --add-module=/root/software/ngx_cache_purge-1.3 --with-http_secure_link_module
目前最新生产环境的版本:
wget http://nginx.org/download/nginx-1.0.8.tar.gz 这儿新加了一个模块:--with-http_mp4_module
./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --add-module=/root/software/nginx_http_push_module-0.692 --add-module=/root/software/ngx_cache_purge-1.3 --with-http_secure_link_module --with-http_mp4_module
编译:
make;make install
配置nginx.conf:
error_page 519 /519.html;
if ($request_uri ~* "(cost\()|(concat\()") {
return 519;
}
if ($request_uri ~* "[+|(%20)]union[+|(%20)]") {
return 519;
}
if ($request_uri ~* "[+|(%20)]and[+|(%20)]") {
return 519;
}
if ($request_uri ~* "[+|(%20)]select[+|(%20)]") {
return 519;
}
还有乱七八糟的一些扩展参考:
configure arguments: --prefix=/home/nginx --with-pcre --add-module=../ngx_http_consistent_hash --add-module=../ngx_max_connections --add-module=../ngx_cache_purge --add-module=../ngx_mp4_streaming_public --with-cc-opt=-O3 --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --without-http_memcached_module --without-http_fastcgi_module --with-google_perftools_module
编译过程中几个注意事项:
1、必须采用--with-pcre,而不要偷懒采用--without-http_rewrite_module,否则配置文件里将不支持if判断;
2、加载mp4_streaming,必须采用--with-cc-opt=-O3方式进行编译。
3、max_connections模块默认支持nginx最新版本是0.8.32,需要vi修改其DIR,然后path -p0,但千万不要看见有个Makefile就执行make && make install了,因为它会毫无道理的把整个nginx安装到当前目录的.nginx下隐藏起来……
最新安装nginx-1.1.0全编译项目配置如下:
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --add-module=/root/software/nginx_http_push_module-0.692 --add-module=/root/software/ngx_cache_purge-1.3
在linux下安装Nginx的Pcre包的时候,有时候提示
configure: error: newly created file is older than distributed files!
Check your system clock
出现此编译错误,请检查你的系统时间是否设置有误。。。
查看硬件日期时间
hwclock -show
linux是每隔一段时间将系统时间写入 硬件bois的 如果刚设置完了就关机,开机后时间还是等于没有设置
# date -s 991128
Sun Nov 28 00:00:00 CST 1999
实例:设置时间伟2008年8月8号12:00
# date -s “2008-08-08 12:00:00″
修改完后,记得输入:
clock -w
把系统时间写入CMOS即可
参看:http://linux.net527.cn/fuwuqiyingyong/Webfuwuqi/16516.html
---------------------
配置nginx和phpfastcgi平滑过度:
创建php-fpm配置文件(php-fpm是为PHP打的一个FastCGI管理补丁,可以平滑变更php.ini配置而无需重启php-cgi):
在/usr/local/webserver/php/etc/目录中创建php-fpm.conf文件:
rm -f /usr/local/webserver/php/etc/php-fpm.conf
vi /usr/local/webserver/php/etc/php-fpm.conf
输入以下内容(如果您安装 Nginx + PHP 用于程序调试,请将以下的<value name="display_errors">0</value>改为<value name="display_errors">1</value>,以便显示PHP错误信息,否则,Nginx 会报状态为500的空白错误页):
优化fpm参数:
[root@localhost]# vi php-fpm.conf 【把前面的分号给去掉】
user = www
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 5
pm.min_spare_servers = 2
pm.max_spare_servers = 7
pm.max_requests = 120
创建Nginx日志目录:
mkdir -p /data1/logs
chmod +w /data1/logs
chown -R www:www /data1/logs
创建Nginx配置文件
在/usr/local/webserver/nginx/conf/目录中创建nginx.conf文件:
rm -f /usr/local/webserver/nginx/conf/nginx.conf
vi /usr/local/webserver/nginx/conf/nginx.conf
<!--Begin-->
user www www;
worker_processes 8;
error_log /data1/logs/nginx_error.log crit;
pid /usr/local/webserver/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
http
{
include mime.types;
default_type application/octet-stream;
#charset gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
#limit_zone crawler $binary_remote_addr 10m;
server
{
listen 80;
server_name status.blog.jackxiang.com;
location / {
stub_status on;
access_log off;
}
}
server
{
listen 80;
server_name jackxiang.com www.jackxiang.com;
index index.html index.htm index.php;
root /data0/htdocs/blog;
if (!-e $request_filename)
{
rewrite ^/post/([0-9]+)/?([0-9]+)?/?([0-9]+)?/?$ /read.php?entryid=$1&page=$2&part=$3 last;
rewrite ^/page/([0-9]+)/([0-9]+)/?$ /index.php?mode=$1&page=$2 last;
rewrite ^/starred/([0-9]+)/?([0-9]+)?/?$ /star.php?mode=$1&page=$2 last;
rewrite ^/category/([^/]+)/?([0-9]+)?/?([0-9]+)?/?$ /index.php?go=category_$1&mode=$2&page=$3 last;
rewrite ^/archiver/([0-9]+)/([0-9]+)/?([0-9]+)?/?([0-9]+)?/?$ /index.php?go=archive&cm=$1&cy=$2&mode=$3&page=$4 last;
rewrite ^/date/([0-9]+)/([0-9]+)/([0-9]+)/?([0-9]+)?/?([0-9]+)?/?$ /index.php?go=showday_$1-$2-$3&mode=$4&page=$5 last;
rewrite ^/user/([0-9]+)/?$ /view.php?go=user_$1 last;
rewrite ^/tags/([^/]+)/?([0-9]+)?/?([0-9]+)?/?$ /tag.php?tag=$1&mode=$2&page=$3 last;
rewrite ^/component/id/([0-9]+)/?$ /page.php?pageid=$1 last;
rewrite ^/component/([^/]+)/?$ /page.php?pagealias=$1 last;
#Force redirection for old rules
rewrite ^/read\.php/([0-9]+)\.htm$ http://$host/post/$1/ permanent;
rewrite ^/post/([0-9]+)\.htm$ http://$host/post/$1/ permanent;
rewrite ^/post/([0-9]+)\_([0-9]+)\.htm$ http://$host/post/$1/$2/ permanent;
rewrite ^/post/([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/post/$1/$2/$3/ permanent;
rewrite ^/index\_([0-9]+)\_([0-9]+)\.htm$ http://$host/page/$1/$2/ permanent;
rewrite ^/star\_([0-9]+)\_([0-9]+)\.htm$ http://$host/starred/$1/$2/ permanent;
rewrite ^/category\_([0-9]+)\.htm$ http://$host/category/$1/ permanent;
rewrite ^/category\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/category/$1/$2/$3/ permanent;
rewrite ^/archive\_([0-9]+)\_([0-9]+)\.htm$ http://$host/archiver/$1/$2/ permanent;
rewrite ^/archive\_([0-9]+)\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/archiver/$1/$2/$3/$4/ permanent;
rewrite ^/showday\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/date/$1/$2/$3/ permanent;
rewrite ^/showday\_([0-9]+)\_([0-9]+)\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/date/$1/$2/$3/$4/$5/ permanent;
#Filename alias
rewrite ^/([a-zA-Z0-9_-]+)/?([0-9]+)?/?([0-9]+)?/?$ /read.php?blogalias=$1&page=$2&part=$3 last;
}
#limit_conn crawler 20;
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log /data1/logs/access.log access;
}
}
<--End-->
安装Memache:
libevent-2.0.10-stable:
wget http://monkey.org/~provos/libevent-2.0.10-stable.tar.gz
tar xzf libevent-2.0.10-stable.tar.gz
cd libevent-2.0.10-stable
./configure
make
make install
#刷新库文件连接
ldconfig
Then Memcache setup:
wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
tar xzf memcached-1.4.5.tar.gz
cd memcached-1.4.5
./configure --prefix=/usr/local/webserver/memcached
make
make install
#增加用户组memcached和用户memcached
/usr/sbin/groupadd memcached
/usr/sbin/useradd -g memcached memcached
启动Memcached时可能出现的问题:
找不到以下的so,用如下操作及可:
ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/
启动PHP的FastCGI:
启动PHP FastCGI:
cp /root/jackxiang.com/php-5.3.6/sapi/fpm/init.d.php-fpm /etc/init.d/phpfpm
chmod 755 /etc/init.d/phpfpm
ulimit -SHn 51200
/etc/init.d/phpfpm start
启动PHp的FastCGI时可能会出现下面错误:
出现下面的错误(这个错误是我在安装过程中发现的,是内在不足导致的,在文章的结尾优化后,就不会有这样的问题了,在这里做个记录,方便大家学习)
Starting php_fpm eAccelerator: Could not allocate 67108864 bytes, the maximum size the kernel allows is 33554432 bytes. Lower the amount of memory request or increase the limit in /proc/sys/kernel/shmmax.
PHP Warning: [eAccelerator] Can not create shared memory area in Unknown on line 0
PHP Fatal error: Unable to start eAccelerator module in Unknown on line 0
failed
#说明
php.ini中设置的eAccelerator,eaccelerator.shm_size="64",解释:eaccelerator可使用的共享内存大小(单位为MB),即64M
在Linux下,单个进程的最大内存使用量受/proc/sys/kernel/shmmax中设置的数字限制(单位为字节) /proc/sys/kernel/shmmax = 33554432 (32M)
临时更改该值:
echo 128000000 > /proc/sys/kernel/shmmax
或者
vi /etc/sysctl.conf
#add by jack
kernel.shmmax = 128000000
使配置立即生效:
/sbin/sysctl -p
优化Linux内核参数
vi /etc/sysctl.conf
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 5000 65000使配置立即生效:
/sbin/sysctl -p
配置开机自动启动Nginx + PHP:
在不停止Nginx服务的情况下平滑变更Nginx配置
修改/usr/local/webserver/nginx/conf/nginx.conf配置文件后,请执行以下命令检查配置文件是否正确
/usr/local/webserver/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/webserver/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/webserver/nginx/conf/nginx.conf test is successful这时,输入以下命令查看Nginx主进程号:
ps -ef | grep "nginx: master process" | grep -v "grep" | awk -F ' ' '{print $2}'
这时,执行以下命令即可使修改过的Nginx配置文件生效:
kill -HUP 6302
kill -HUP `cat /usr/local/webserver/nginx/nginx.pid`
编写每天定时切割Nginx日志的脚本:
创建脚本/usr/local/webserver/nginx/sbin/cut_nginx_log.sh
vi /usr/local/webserver/nginx/sbin/cut_nginx_log.sh
#!/bin/bash
# This script run at 00:00
# The Nginx logs path
logs_path="/usr/local/webserver/nginx/logs/"
mkdir -p ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/
mv ${logs_path}access.log ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/access_$(date -d "yesterday" +"%Y%m%d").log
kill -USR1 `cat /usr/local/webserver/nginx/nginx.pid`
设置crontab,每天凌晨00:00切割nginx访问日志
crontab -e
00 00 * * * /bin/bash /usr/local/webserver/nginx/sbin/cut_nginx_log.sh
开机自动 启动namp服务如下设置,关于开机程序的自动启动:
1)如专门启动Mysql这样一个,你可以参考:
开机自动 启动Mysql的方法: http://www.jackxiang.com/post/4730/ ,
也就是随便芿一个可执行文件到目录:/etc/rc.d/init.d/ ,赋予可执行权限写入开机启动的脚本即可。
2)如果要同时启动多个服务器软件,则如下所示:
开机启动知识及步骤如下:
想用命令chkconfig加载自启动.提示"**服务不支持chkconfig",原来是自己写的脚本时,忘记写两行了.开头一般要这样写,345是启动级,85和15分别是启动优先级,关闭优先级,下面的就是描述了。:
#!/bin/bash
#chkconfig:345 61 61 //此行的345参数表示,在哪些运行级别启动,启动序号(S61);关闭序号(K61)
#description:nginx php mysql memcache start shell
,修改来自Apache里的启动shell,也可以不用修改:
保存为/etc/init.d/lnmp,内容如下:
#!/bin/bash
#chkconfig:345 61 61
#description:nginx php mysql memcache start shell
echo "Starting memcache mysql php nginx daemon..."
ulimit -SHn 51200
nohup /usr/local/webserver/memcached/bin/memcached -d -m 1 -u www -p 11211 > /dev/null 2>&1 &
nohup /usr/local/webserver/mysql/bin/mysqld_safe --user=mysql > /dev/null 2>&1 &
nohup /etc/init.d/phpfpm start > /dev/null 2>&1 &
nohup /usr/local/webserver/nginx/sbin/nginx -c /usr/local/webserver/nginx/conf/nginx.conf > /dev/null 2>&1 &
把脚本拷贝至/etc/init.d/目录下,执行命令:
ln -s /etc/init.d/lnmp /etc/rc.d/rc3.d/S61lnmp
ln -s /etc/init.d/lnmp /etc/rc.d/rc4.d/S61lnmp
ln -s /etc/init.d/lnmp /etc/rc.d/rc5.d/S61lnmp
再执行
chkconfig --add lnmp
chkconfig --levels lnmp345 on //也成
开机启动:
service lnmp start
env: /etc/init.d/lnmp: 权限不够
chmod -R a+x /etc/init.d/lnmp
reboot 重启动,看服务起来了没,没起来再运行:service lnmp 试试,这儿就不用start了,因上面没有start这个参数!!!
要删除某个service的自动启动的设置,使用--del选项,如下:
# chkconfig --del lnmp
# chkconfig --list | grep lnmp
Nginx这块自己有ssl启动需要输入密码,默认的那个不行,怎么干掉?
nginx 开机启动的service项想删除,service nginx start 这个想干掉,我现在放开机启动里了:
/etc/init.d/nginx //可以把它重写成自己的,因为我的有https
chkconfig nginx off
=======================shell环境关于bash启动脚本======================================
/etc/profile
/etc/bashrc
~/.bash_profile
~/.bashrc
~/.bash_logout
每一个文件都有特殊的功用并对登陆和交互环境有不同的影响。
/etc/profile 和 ~/.bash_profile 是在启动一个交互登陆shell的时候被调用。
/etc/bashrc 和 ~/.bashrc 是在一个交互的非登陆shell启动的时候被调用。
~/.bash_logout 在用户注销登陆的时候被读取
一 个交互的登陆shell会在 /bin/login 成功登陆之后运行。一个交互的非登陆shell是通过命令行来运行的,如[prompt]$/bin/bash。一般一个非交互的shell出现在运行 shell脚本的时候。之所以叫非交互的shell,是因为它不在命令行上等待输入而只是执行脚本程序。
关于开机程序的自动启动
系统脚本可以放置在/etc/rc.d/init.d中并建立/etc/rc.d/rc?.d链接,也可以直接放置在/etc/rc.d/rc.local中。
init.d脚本包含完整的start,stop,status,reload等参数,是标准做法,推荐使用。
为特定用户使用的程序(如有的用户需要使用中文输入法而有的不需要)放置在~/中的bash启动脚本中。
chkconfig --list //开机启动的list
ntsysv //simple gui,直接修改
chkconfig httpd off //还是这个见效快****
chkconfig iptables off //关闭防火墙,还是这个见效快*
chkconfig --list |grep sendmail
chkconfig sendmail off
chkconfig --list |grep auditd
chkconfig auditd off
chkconfig rpcgssd off
chkconfig rpcidmapd off
chkconfig rpcsvcgssd off
chkconfig portmap off最近发现了一个Deamo进程也可以关闭:
udp 0 0 0.0.0.0:46563 0.0.0.0:* 2295/avahi-daemon:
udp 0 0 0.0.0.0:5353 0.0.0.0:* 2295/avahi-daemon:
udp 0 0 :::5353 :::* 2295/avahi-daemon:
步骤方法如下:
chkconfig --list avahi-daemon
root@116.255.139.240:/data0/htdocs/blog/template# chkconfig --list avahi-daemon
avahi-daemon 0:off 1:off 2:off 3:on 4:on 5:on 6:off
avahi-daemon 关闭:
service avahi-daemon stop
chkconfig avahi-daemon off 再看:
root@116.255.139.240:/data0/htdocs/blog/template# chkconfig --list avahi-daemon
avahi-daemon 0:off 1:off 2:off 3:off 4:off 5:off 6:off确实关闭了。
试试把 avahi-daemon 服务关闭,你会得到空前变化。avahi-daemon
Avahi 是 zeroconf 协议的实现。它可以在没有 DNS 服务的局域网里发现基于 zeroconf 协议的设备和服务。它跟mDNS 一样。除非你有兼容的设备或使用 zeroconf 协议的服务,否则应该关闭它。现在用的基本都是DNS了。
更专业点讲就是The Avahi mDNS/DNS-SD daemon implements Apple’s Zeroconfarchitecture(also known as "Rendezvous" or "Bonjour"). The daemonregisters local IP addresses and static services using mDNS/DNS-SD andprovides two IPC APIs for local programs to make use of the mDNS recordcache the avahi-daemon maintains.
avahi-daemon is a daemon which runs on client machines to performZeroconf service discovery on a network. avahi-daemon must be runningon systems that use Avahi for service discovery. Avahi-daemon shouldnot be running otherwise.
AutoMount 自动挂载功能
方法: 启动进程autofs
在RedHat安装后期,在选择启动时需要自动执行进程的那一步骤剔选“autofs”。
如果已经安装好了作业系统,也可以更改该项设置。在Terminal中输入“setup”指令,选“System services”,或者直接输入启动进程配置指令“ntsysv”都可以打开启动进程配置介面,剔选“autofs后,下次进入RedHat Linux后,这一进程就会被自动装载。
1837 root 15 0 29424 1376 1060 S 0.0 0.5 0:00.23 automount
root@116.255.139.240:~# chkconfig --list|grep autofs
autofs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
chkconfig autofs off
root@116.255.139.240:~# service autofs stop
vps取消设置自动挂载ISCSI分区的服务:
方法一:
用编辑器打开/etc/fstab 例如:gedit /etc/fstab ,并在最后一行加入下列命令
/dev/sda1 /mnt/t0 ext2 defaults 0 0 //如果是FAT分区,则将ext2改为vfat。(这个选项很重要,如果没有则无法成功自动挂载)
关闭测试启动自动挂载磁盘的服务:
root@116.255.139.240:~# chkconfig --list|grep iscsi
iscsi 0:off 1:off 2:off 3:on 4:on 5:on 6:off
iscsid 0:off 1:off 2:off 3:on 4:on 5:on 6:off
root@116.255.139.240:~# chkconfig iscsid off
root@116.255.139.240:~# service iscsid stop
Stopping iSCSI daemon:
root@116.255.139.240:~# [ OK ]
Stopping automount: [ OK ]
php扩展ssh2的安装:
wget http://www.libssh2.org/download/libssh2-1.2.7.tar.gz
cd libssh2-1.2.7
./configure
make;make install
pecl install -f ssh2
选择:Y
/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/ssh2.so
You should add "extension=ssh2.so" to php.ini
PHP SOAP Extension:
cd /root/jackxiang.com/php-5.3.6/ext/soap
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make;make install
/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/soap.so
特别注意:
开机启动SVN服务的Apache的设置方法:
vim /etc/init.d/apache
/usr/local/webserver/apache2/bin/apachectl start
chmod 775 /etc/init.d/apache
chkconfig apache on
当然你也可以抄一个shell标准脚本,如前面php的phpfpm启动脚本。
遇到443端口加密需要需要输入密码的还请慎重考虑,如下所示:
Server svn.jackxiang.com:443 (RSA)
Enter pass phrase:
Apache:mod_ssl:Error: Pass phrase empty (needs to be at least 1 character).
Enter pass phrase:
Ok: Pass Phrase Dialog successful.
需要研究如何自动启动并自动地输入密码。
这块还不行,这块expect里的spawn要和ssh结合,nginx这种情况还不行,下面这个有警告,但是能执行:
上面路径要写死/usr/local/scripts,别相对:
startNginx.sh
升级到PHP5.3.8后启动FastCGI出现:
root@116.255.139.240:~/software/eaccelerator-0.9.6.1# cat /root/runphp.sh
pkill -9 php
usleep 100000
/etc/init.d/phpfpm start
=============执行上面这段代码:
root@116.255.139.240:~/software/eaccelerator-0.9.6.1# sh /root/runphp.sh
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Starting php-fpm
done
原因是:估计升级PHP后 还是在原来PHP目录下,到了一个不存在的目录中 而显示错误.
Mysql的数据文件移动时出现的新问题:2011-10-16 Add By:jack。
主要是讲述新版本的Mysql在移动目录时,在特别是有Innodb的情况下,出现问题解决问题的一个过程,及Mysql的sock文件和PHP接合的问题。
Mysql数据文件搬家到另外一个目录出现的 二个问题(从/usr/local/webserver/mysql/data/ 搬家到:/data0/data),如下:
1.Innodb出现问题,Mysql启动不了,如附录中的日志所示:
InnoDB: The InnoDB memory heap is disabled
这样的警告,查资料说,只要在my.cnf中加入以下,就可以消除以上警告
innodb_use_sys_malloc =0
系统默认为
innodb_use_sys_malloc =1
似乎有人说innodb_use_sys_malloc =1速度更快,我还没有得到证实。
所以,我就没有修改了。
解决办法:
cd /data0/data
rm -Rf ibdata1
rm -Rf ib_logfile0
rm -Rf ib_logfile1
========================================================
1.检查Linux下Mysql的日志
2.错误信息是"Default storage engine (InnoDB) is not available"
解决方法:
1.删除在MySQL安装目录下的Data目录中的
ib_logfile0
ib_logfile1
2.找到在配置MySQL服务器时指定的InfoDB目录删除掉
ibdata1
3.重新启动MySQL的Service
这个问题第二天又摸索了一下,其实是可以用InnoDB引擎的.
需要在mysql生成的配置文件增加一行配置,即增加一个临时目录,这个在启动mysql服务的时候是需要的.
[mysqld]
tmpdir=/tmp
我的my.ini配置文件如下,注意红色字体,是默认不会生成的;
========================================================
如下:
root@116.255.139.240:/data0/data# rm -Rf ib_logfile0 ib_logfile1
root@116.255.139.240:/data0/data# rm -Rf ibdata1
root@116.255.139.240:/data0/data# rm -Rf ibdata1
后续指定DB目录,和InnoDB目录及日志文件设置如下:
datadir = /data0/data/
innodb_data_home_dir = /data0/data/
innodb_data_home_dir = /data0/data/
innodb_log_group_home_dir = /data0/data/
innodb_data_file_path = ibdata1:128M:autoextend
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_use_sys_malloc = 0
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 4M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 5M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
#log write and so on...
general-log = /data0/data/error_log/log-error.log
log-error = /data0/data/error_log/log-error.log
slow-query-log = /data0/data/error_log/log-slow-query.log
#slow query search
slow_query_log=1
slow_query_log_file = /data0/data/slow_query_log/mysql-slow.log
long_query_time = 2
log-queries-not-using-indexes
2.移动数据文件目录后再访问时出现了问题二:
Bo-Blog Database System Tips: Can not connect to MySQL server
Time: 2011-10-16 8:09am
Script:
Error: Can't connect to local MySQL server through socket '/usr/local/webserver/mysql/data/mysql.sock' (2)
Errno.: 2002
检测php.ini的设置,再检测my.conf里面的值设成一样就OK 另外目录mysql.sock所在目录的读取权限也是
如果用php连接要特别注意php.ini的设置
mysql.default_socket=(默认为空) ,这块连接Mysql相关的设置请看:http://www.jackxiang.com/post/4327/
所以首要侨务检测php.ini的设置,再检测my.conf里面的值设成一样就OK
另外目录mysql.sock所在目录的读取权限也是问题(兄弟们原谅我linux下的目录权限真的是不懂,所以简单点就直接chmod 777了)
另外要特别注意,我想这点才是可能导致失败的就是web目录不能用root用户运行.而应该用nobody用户
# vi /etc/my.cnf
[mysqld]
port = 3306
socket = /data0/data/mysql.sock
vi /usr/local/webserver/php/etc/php.ini
mysql.default_socket =
修改成和修改后的一样即可:
mysql.default_socket = /data0/data/mysql.sock
是FastCGI得重启fastcgi的Php,而如是Apache,则重启动Apache即可,就是把PHP.ini给纳入重新初始化。
附录Mysql启动后的日志情况:
111016 16:01:29 mysqld_safe Starting mysqld daemon with databases from /data0/data
InnoDB: Mutexes and rw_locks use InnoDB's own implementation
InnoDB: Compressed tables use zlib 1.2.3
111016 16:01:29 InnoDB: Initializing buffer pool, size = 18.0M
111016 16:01:29 InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file /data0/data/ibdata1 did not exist:
InnoDB: a new database to be created!
111016 16:01:29 InnoDB: Setting file /data0/data/ibdata1 size to 128 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Progress in MB: 100
InnoDB: Error: all log files must be created at the same time.
InnoDB: All log files must be created also in database creation.
InnoDB: If you want bigger or smaller log files, shut down the
InnoDB: database and make sure there were no errors in shutdown.
InnoDB: Then delete the existing log files. Edit the .cnf file
InnoDB: and start the database again.
111016 16:01:49 [ERROR] Plugin 'InnoDB' init function returned error.
111016 16:01:49 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
111016 16:01:49 [ERROR] Unknown/unsupported storage engine: InnoDB
111016 16:01:49 [ERROR] Aborting
启动Ok如下:
111016 16:05:13 mysqld_safe Starting mysqld daemon with databases from /data0/data
InnoDB: Mutexes and rw_locks use InnoDB's own implementation
InnoDB: Compressed tables use zlib 1.2.3
111016 16:05:13 InnoDB: Initializing buffer pool, size = 16.0M
111016 16:05:13 InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file /data0/data/ibdata1 did not exist:
InnoDB: a new database to be created!
111016 16:05:13 InnoDB: Setting file /data0/data/ibdata1 size to 128 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Progress in MB: 100
111016 16:05:22 InnoDB: Log file /data0/data/ib_logfile0 did not exist: new to be created
InnoDB: Setting log file /data0/data/ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
111016 16:05:23 InnoDB: Log file /data0/data/ib_logfile1 did not exist: new to be created
InnoDB: Setting log file /data0/data/ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: 127 rollback segment(s) active.
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
111016 16:05:24 InnoDB: 1.1.4 started; log sequence number 0
111016 16:05:24 [Note] Event Scheduler: Loaded 0 events
111016 16:05:24 [Note] /usr/local/webserver/mysql/bin/mysqld: ready for connections.
Version: '5.5.8-log' socket: '/data0/data/mysql.sock' port: 3306 Source distribution
注意,Nginx下的file_get_contents会出现100%的Cpu情况,原因是:
开启<value name="request_slowlog_timeout">3s</value>记录慢执行日志,会在日志中打印出执行慢的代码行数。php-cgi(php-fpm) 使用了Libevent,而Libevent 在 Linux 2.6 内核以上默认会使用 epoll I/O 模型处理 FastCGI 网络请求,而非 select/poll。在慢日志记录的代码行数中,包含 file_get_contents 以及其他函数,而 file_get_contents 等作为 Client 发起 HTTP 请求的函数使用的是 select/poll 模型,也就是说,只有 file_get_contents 等满足“TCP请求默认不超时、使用select/poll 模型、进程CPU 100%”的网络操作函数,会导致 strace -p 看到的这种情况。
最好还是用Curl吧,这个靠谱些。
后补上,如何在PHP里安装GD2,方法如下:
如果源码安装需要找齐下面的源码包,在安GD2时需要指定其安装的位置:
./configure --prefix=/usr/local/modules/gd --with-jpeg=/usr/local/modules/jpeg6 --with-png --with-zlib --with-freetype=/usr/local/modules/freetype
如果安装gd版本低,会报configure: error: Unable to find libgd.(a|so) >= 2.1.0 anywhere under /usr/local/gd
GD库重装成功 尝试重装PHP 依然报错 查找到libgd.*位置 复制到/usr/local/gd/ 依然找不到。 找到原因,GD库版本过低,低于2.1.0 下载最新版本
替换高版本gd解决,也可能是这样解决:
configure: error: Unable to find libgd.(a|so) >= 2.1.0 anywhere under /usr/local/libgd
如果提示libgd版本错误,把php编译参数--with-gd=/usr/local/libgd修改为--with-gd即可 ,Dockerfile 是这样的:--with-gd=/usr \ ,指向/usr。
修改成下面这个路径试试:
--with-gd=/usr/local/gd \
而要是自带的这个rpm,用linux的yum安好即可,特别要注意要用到的devel这样的包,这个是有一个头文件在里面的,
rpm -ql zlib-devel-1.2.3-27.el6.i686
/usr/include/zconf.h
/usr/include/zlib.h
/usr/lib/libz.so
如下,查看是否所有的包都安好了:
root@192.168.225.128:~# rpm -qa|grep zlib
zlib-devel-1.2.3-27.el6.i686
zlib-1.2.3-27.el6.i686
root@192.168.225.128:~# rpm -qa|grep libpng
libpng-devel-1.2.46-1.el6_1.i686
libpng-1.2.46-1.el6_1.i686
root@192.168.225.128:~# rpm -qa|grep freetype
freetype-2.3.11-6.el6_1.8.i686
freetype-devel-2.3.11-6.el6_1.8.i686
root@192.168.225.128:~# rpm -qa|grep libxml
libxml2-2.7.6-4.el6_2.1.i686
libxml2-devel-2.7.6-4.el6_2.1.i686
root@192.168.225.128:~# rpm -qa|grep gd
gdbm-1.8.0-36.el6.i686
root@192.168.225.128:~# rpm -qa|grep jpeg
libjpeg-6b-46.el6.i686
libjpeg-devel-6b-46.el6.i686
于是直接这样来安这个GD2即可:
./configure --prefix=/usr/local/gd
** Configuration summary for gd 2.0.34:
Support for PNG library: yes
Support for JPEG library: yes
Support for Freetype 2.x library: yes
Support for Fontconfig library: no
Support for Xpm library: no
Support for pthreads: yes
make;make install
PHP:
--with-gd=/usr/local/gd
安装配置方法:
/configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local/libiconv --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 --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd=/usr/local/gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --enable-soap=shared --enable-pdo enable-dom --enable-xmlwriter --with-pcre-regex --with-pear --enable-session --enable-spl --enable-hash --enable-reflection
重新指定so的位置:
打开/etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/gd/lib
ldconfig
再make;make install ,以上安装出现PHP还是跑到php5.3.10/ext/gd 并报错了。考。。。。
再试着用源码来安装(记录一下,安装是可以,但在最后时发现php还是去读取了PHP自己的目录下的ext/gd),后面只有先暂时不安,在最后再来安装这个gd2:
FreeType安装
FreeType库是一个完全免费(开源)的、高质量的且可移植的字体引擎,它提供统一的接口来访问多种字体格式文件,包括TrueType, OpenType, Type1, CID, CFF, Windows FON/FNT, X11 PCF等。支持单色位图、反走样位图的渲染。FreeType库是高度模块化的程序库,虽然它是使用ANSI C开发,但是采用面向对象的思想,因此,FreeType的用户可以灵活地对它进行裁剪。
[root@yznvm1 yzn]# wget http://nchc.dl.sourceforge.net/project/freetype/freetype2/2.4.8/freetype-2.4.8.tar.gz
[root@yznvm1 yzn]# tar xzvf freetype-2.4.8.tar.gz
[root@yznvm1 yzn]# cd freetype-2.4.8
[root@yznvm1 yzn]# ./configure --prefix=/usr/local/freetype
[root@yznvm1 freetype-2.4.8]# make && make install
[root@yznvm1 yzn]# wget http://www.ijg.org/files/jpegsrc.v8c.tar.gz
[root@yznvm1 yzn]# tar zxvf jpegsrc.v8c.tar.gz
[root@yznvm1 yzn]# cd jpeg-8c/
[root@yznvm1 jpeg-8c]# ./configure --prefix=/usr/local/jpeg
[root@yznvm1 jpeg-8c]# make && make install && cd ..
libpng
可查看http://www.libpng.org/pub/png/libpng.html
查看zlib版本
[root@yznvm1 yzn]# rpm -qa zlib
zlib-1.2.3-3
zlib-1.2.3-3
出于性能和安全考虑,zlib最好是1.2.5以上版本
[root@yznvm1 yzn]# wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.5.7.tar.gz
[root@yznvm1 yzn]# tar zxvf libpng-1.5.7.tar.gz
[root@yznvm1 yzn]# cd libpng-1.5.7
[root@yznvm1 libpng-1.5.7]# ./configure --prefix=/usr/local/libpng
[root@yznvm1 libpng-1.5.7]# make && make install
[root@yznvm1 libpng-1.5.7]# cd ..
libgd
http://www.libgd.org/ 这个网站down
[root@yznvm1 gd-2.0.33]# http://www.boutell.com/gd/http/gd-2.0.33.tar.gz
[root@yznvm1 gd-2.0.33]# tar xzvf gd-2.0.33.tar.gz
[root@yznvm1 gd-2.0.33]# cd gd-2.0.33
[root@yznvm1 gd-2.0.33]# ln -s /usr/local/libpng/include/pngconf.h /usr/include
[root@yznvm1 gd-2.0.33]# ln -s /usr/local/libpng/include/png.h /usr/include
[root@yznvm1 gd-2.0.33]# ./configure --prefix=/usr/local/gd2 --with-freetype=/usr/local/freetype --with-png=/usr/local/libpng --with-jpeg=/usr/local/jpeg
[root@yznvm1 gd-2.0.33]# make
[root@yznvm1 gd-2.0.33]# make install
下面是全的安装配置configure文件,但实践中要注意下面四点:
1)This is the test message -- configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
Fix: yum install net-snmp-devel
2)
configure: WARNING: You will need re2c 0.13.4 or later 解决办法
我在为php安装imagick-2.3.0模块的时候出现来错误
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
说需要安装re2c
执行以下命令
wget http://sourceforge.net/projects/re2c/files/re2c/0.13.5/re2c-0.13.5.tar.gz/download
tar -zxvf re2c-0.13.5.tar.gz
cd re2c-0.13.5
./configure && make && make install
3)configure: warning: bison versions supported for regeneration of the Zend/PHP parsers: 1.28 1.35 1.75 1.875 2.0 2.1 2.2 2.3 2.4 2.4.1 (found: none).
yum install bison
4)checking for lemon... no
configure: warning: lemon versions supported for regeneration of libsqlite parsers: 1.0 (found: none).
解决方法:
wget http://www.sqlite.org/cvstrac/getfile/sqlite/tool/lemon.c [下载不了]
这儿下:
http://code.google.com/p/lemonbind/source/browse/tools/lemon.c
gcc -o lemon lemon.c
mv lemon /usr/local/bin
重新运行 ./configure 后,问题解决。
最后正确的安装php5.3.10的配置configure方法,汇总,配置完所有的扩展要要用的配置参数了:
接着用如下make,不加参数会报错找不到ld什么的:
make ZEND_EXTRA_LIBS='-liconv'
更多的事件驱动扩展,PHP5.3 下安装ZendGuardLoader及eaccelerator 加速器:
http://www.jackxiang.com/post/5626/
PHP高一点的版本如:php-5.3.26,那些没有用的参数就不用了,于是得出下面的编译列表:
如果想兼容Nginx和Apache2时,还应加上--with-apxs2,但只能编译成一种,不能同时编译既支持fastCGI,又支持Apache的传统方式:
关于php编译时SAPI错误 :
近日在Centos6.3上编译php的时候出现了错误:You've configured multiple SAPIs to be build. You can build only |
| one SAPI module and CLI binary at the same time.
翻译:
You've configured multiple SAPIs to be build.You can build only one SAPI module and CLI binary at the same time.(你已经配置了多个SAPIs,你只可以建立一个SAPI模块和一个CLI binary。)
导致的原因是我的配置参数中同时使用了--enable-fpm 与--with-apxs2= ,因此编译的时候出错了,去掉其中的任意一个参数编译成功。
checking for Apache 1.x module support via DSO through APXS... configure: error: You have enabled Apache 1.3 support while your server is Apache 2. Please use the appropiate switch --with-apxs2
把下面的语句 --enable-fpm 去掉:就可以编译成功Apache下的PHP了。
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --enable-soap=shared --enable-pdo --enable-dom --enable-xmlwriter --with-pcre-regex --with-pear --enable-session --enable-hash --with-pdo-mysql=/usr/local/webserver/mysql --with-apxs2=/usr/local/webserver/apache2/bin/apxs
make ZEND_EXTRA_LIBS='-liconv'
会提示:如果要用Apache的线程安全模式,需要加上配置参数为: --enable-maintainer-zts
参考:http://jackxiang.com/post/5868/
You have built PHP for Apache's current non-threaded MPM.
If you change Apache to use a threaded MPM you must reconfigure
PHP with --enable-maintainer-zts
出现配置时的输出错误:
configure :error:unable to find your mysql installation
在--with-pdo-mysql后加上路径 ---with-pdo-mysql=/usr/local/webserver/mysql
终于再次编译成功!!
Apache相关的编译成功参数情况如下:
make install ...安装时会在Apache2下安装libphp5.so等文件:
在编译Apache下的PHP时出现一个can't find -lltdl的问题解决方法:
/usr/bin/ld: cannot find 错误解决方法
通常在软件编译时出现的usr/bin/ld: cannot find -lxxx的错误,主要的原因是库文件并没有导入的ld检索目录中。
解决方式:
1。确认库文件是否存在,比如-l123, 在/usr/lib, /usr/local/lib,或者其他自定义的lib下有无lib123.so, 如果只是存在lib123.so.1,
那么可以通过ln -sv lib123.so.1 lib123.so,建立一个连接重建lib123.so.
2。检查/etc/ld.so.conf中的库文件路径是否正确,如果库文件不是使用系统路径,/usr/lib, /usr/local/lib, 那么必须在文件中加入。
3。ldconfig 重建ld.so.cache文件,ld的库文件检索目录存放文件。尤其刚刚编译安装的软件,必须运行ldconfig,才能将新安装的
库文件导入ld.so.cache.
4。测试,gcc -l123 --verbose.
参考:http://blog.siyebocai.cn/20100324_5p424qs7.html
实践操作:
/usr/lib/libltdl.so /usr/bin/ld: cannot find -lltdl collect2: ld returned 1 exit status make: *** [libphp5.la] 错误 1
找找下面这些位置是否有这样的包?
erro: Installed (but unpackaged) file(s) found:
/usr/lib64/libltdl.a
/usr/lib64/libltdl.la
/usr/lib64/libltdl.so.3.1.0
Installed (but unpackaged) file(s) found:
/usr/lib64/libltdl.a
/usr/lib64/libltdl.la
/usr/lib64/libltdl.so.3.1.0
如果找不到,解决的方法基本很容易.
#yum install libtool-ltdl-devel
如果找到,我的情况:
root@192.168.244.128:/# cd /;find . -name "*libltdl.so*"
./usr/lib/libltdl.so.7.2.1
./usr/lib/libltdl.so.7
按上面的介绍来作出添加操作:
1)检查/etc/ld.so.conf中的库文件路径是否正确,如果库文件不是使用系统路径,/usr/lib, /usr/local/lib, 那么必须在文件中加入。
2)ldconfig 重建ld.so.cache文件,ld的库文件检索目录存放文件。尤其刚刚编译安装的软件,必须运行ldconfig,才能将新安装的
库文件导入ld.so.cache.
如下操作:
vi /etc/ld.so.conf 添加一行:
/usr/lib/
执行: ldconfig
再次编译PHP即可!!!
------------------------------------------------------------------------------------------------------------------------------------------------------------------
还是不行啊?呵呵,那明明整上去了还不行再这样试试:
第一步很容做到:yum -y install libtool libtool-ltdl; //这一步实在是没有那个库再说吧,略。直接第二步。
root@192.168.244.128:/# ldconfig -p |grep ltdl
libltdl.so.7 (libc6) => /usr/lib/libltdl.so.7
第二步由于PHP的configure指定的libltdl名为libltdl.so,为此我们只需添加一个名称连接:ln -s /usr/lib64/libltdl.so.3.1.4 /usr/lib64/libltdl.so ,如果不是64位则:
,其原始文件是:/usr/lib/libltdl.so.7.2.1 ,一个个都是软链接。
http://blog.chinaunix.net/uid-20774942-id-3001010.html
------------------------------------------------------------------------------------------------------------------------------------------------------------------
安装php并且打补丁(由于gd与iconv冲突,暂不编译gd库),于是在后来追加编译gd库
进入目录php-5.2.10/ext/gd执行命令
/usr/local/php/lib/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/libpng --with-zlib-dir=/usr/local/zlib/ --with-freetype-dir=/usr/local/freetype
make;make install
,最后,发现这个新生成的gd.so,和前面默认安的这个gd是一样的东东,现在还是不太明白他们所说的gd2和gd有什么大的区别,哈哈,上面这种方法提供了一条安gd.so的方法,也还是不小的收获。同时,以前这个PDO都是编译为so,而上面这个编译是直接编译进php的源码时就编译了,也是不错的收获。
这次主要是把PHP模块Mysql的的PDO直接安装在了编译时,而不需要extension(;extension = "pdo_mysql.so"):
root@192.168.225.128:~/software/php-5.3.10# php -m|grep pdo
PHP Warning: Module 'pdo_mysql' already loaded in Unknown on line 0
pdo_mysql
pdo_sqlite
==============后期的方便操作的设置===================
方便管理,显示IP等,如:jackxiang@72.46.128.82:~#
vi ~/.bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ll='ls -l'
alias la='ls -A'
alias vi='vim'
alias v='vim'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
ipL=`/sbin/ifconfig eth0|grep "inet addr:"|cut -d: -f 2|cut -d" " -f1`
export PS1="\u@$ipL:\w# "
alias cdh="cd /usr/local/tads/htdocs/"
alias cnginx="cd /usr/local/webserver/nginx/"
alias chtdocs="cd /data0/htdocs/"
alias cphpuml="cd /root/software/PHP_UML-1.5.5/PHP/scripts"
一些目录的快捷键:
vi ~+/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/webserver/php/bin:/usr/local/webserver/mysql/bin:/usr/local/webserver/memcached/bin:/usr/local/webserver/nginx/sbin:./usr/local/webserver/subversion/bin:/usr/local/webserver/python/bin:/home/webdev/bin;
export PATH
unset USERNAME
alias chtdocs='cd /data0/htdocs'
alias cphp='cd /usr/local/webserver/php'
alias cmysql='cd /usr/local/webserver/mysql'
alias capache='cd /usr/local/webserver/apache'
alias cblog='cd /data0/htdocs/blog'
alias h='history'
Vim的一些设置等:
vi ~+/.vimrc
syntax on
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
set nu
if &term=="xterm"
set t_Co=8
set t_Sb=^[[4%dm
set t_Sf=^[[3%dm
endif
behave mswin
colo murphy
set fileencodings=utf-8,gb2312,gbk,gb18030
set termencoding=utf-8
set fileformats=unix
set fileencoding=utf-8
au FileType php call AddPHPFuncList()
function AddPHPFuncList()
set dictionary-=/root/.vim/ExtraVim/php_funclist.txt dictionary+=/root/.vim/ExtraVim/php_funclist.txt
set complete-=k complete+=k
endfunction
map <F10> : NERDTreeToggle<CR>
map <F12> ::TlistToggle<CR>
let NERDTreeWinPos = "right" "where NERD tree window is placed on the screen
let Tlist_Enable_Fold_Column = 0
let Tlist_Exit_OnlyWindow = 0
let Tlist_File_Fold_Auto_Close = 0
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_Hightlight_Tag_On_BufEnter = 1
let Tlist_Inc_Winwidth = 0
let Tlist_Max_Submenu_Items = 1
let Tlist_Max_Tag_Length = 30
let Tlist_Process_File_Always = 0
let Tlist_Show_Menu = 0
let Tlist_Show_One_File = 0
let Tlist_Sort_Type = "order"
let Tlist_Use_Horiz_Window = 0
let Tlist_Use_Right_Window = 1
let Tlist_WinWidth = 40
let tlist_php_settings = 'php;c:class;i:interfaces;d:constant;f:function'
eaccelerator的小生产配置备案:
[Zend]
zend_optimizer.optimization_level=15
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/data/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.log_file = "/var/log/httpd/eaccelerator_log"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
YAML扩展:http://jackxiang.com/post/4431/
Xdebug:http://jackxiang.com/post/4675/
更加清晰的参考:
http://www.osyunwei.com/archives/4924.html
http://www.ypgogo.com/world/pearl/id/13000
_____________________PHP5.4以上非fastCGI和apche结合支持上传进度的实践之重新配置Apache____________________________
目的:想实现PHP5.4的进度progress的上传,搞了个nginx的,后来一老外说这Nginx玩意在获取进度时获取不到,还得用传统的Apache那一套。Add Time:14/3/27 星期四
一)给Apache2重新编译下PHP:(像什么GD库,Mysql先省了)
./configure --prefix=/usr/local/webserver/php5.4ForApache -with-apxs2=/usr/local/webserver/apache2/bin/apxs --with-curl --with-mcrypt --enable-mbstring --enable-pdo --with-iconv-dir=/usr/local/libiconv
二)make ZEND_EXTRA_LIBS='-liconv' && make install
libtool: install: install .libs/libphp5.so /usr/local/webserver/apache2/modules/libphp5.so
libtool: install: install .libs/libphp5.lai /usr/local/webserver/apache2/modules/libphp5.la
三)再次检查下httpd.conf的配置情况:
<IfModule mime_module>
TypesConfig conf/mime.types
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
启动Apache,开始测试。
root@192.168.0.6:/usr/local/webserver/apache2/bin# ./httpd -k start
httpd: Syntax error on line 388 of /usr/local/webserver/apache2/conf/httpd.conf: Cannot load modules/libphp5.so into server: /usr/local/webserver/apache2/modules/libphp5.so: undefined symbol: zend_parse_parameters
解决办法:
在新的服务器(centos 6.3)编译安装完php-5.4.8,再配置好php.ini和httpd.conf后,启动apache-2.4.3的时候,命令执行/usr/local/apache2/bin/apachectl start时,提示:
httpd: Syntax error on line 146 of /etc/httpd/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: undefined symbol: zend_parse_parameters
通过搜索发现,说是缺少bison。
如果通过rpm -qa|grep bison发现没有安装bison,安装bison即可。centos可以用yum install bison
rpm -qa|grep bison 是:bison-2.4.1-5.el6.i686,但是我发现已经安装了bison-2.4.1,rpm -e bison-2.4.1-5.el6.i686。最后实在是没办法了,下载了bison-2.5的rpm包直接安装。
[root@localhost ~]# wget http://ftp.gnu.org/gnu/bison/bison-2.5.tar.gz
[root@localhost ~]# tar -zxvf bison-2.5.tar.gz
[root@localhost ~]# cd bison-2.5
[root@localhost ~]# ./configure
[root@localhost ~]# make && make install
再重新编译安装了PHP[实践发现在重新编译PHP时要注意:make clean再编译,后才能启动Apache2并支持PHP5.4.26]。然后/usr/local/apache2/webserver/bin/apachectl start启动Apache。惊奇的发现可以正常启动了,测试了下PHP网页,可以正常访问。
来自:http://www.myxzy.com/post-272.html
1)配置好后,测试上传进度占比的PHP自己带的进度实践来源:
(1)http://www.pureweber.com/article/php-upload-progress/
(2)https://github.com/pureweber/samples/blob/master/php-upload-progress/upload.php
2)配置好后,测试上传进度占比的Flash实践来源:http://jackxiang.com/post/6939/
在虚拟机里出现在最后时卡住了,于是排查:按F2,发现两个问题:
问题1:
mounting local filesystem: mount: mount point vmhgfs does not exist
mounting other filesystems: mount: mount point vmhgfs does not exist
问题2:
PHP作为服务启动时老启动不起来,卡了,在最后,只好关闭:chkconfig php-fpm off
统一在脚本里启动:在/etc/init.d# vi lnmp
nohup service php-fpm start > /dev/null 2>&1 &
对Mountain出现不存在的错误屏蔽掉:
/etc# vi fstab
#host://mnt/hgfs vmhgfs defaults,user,ttl=5,uid=root,gid=root,fmask=0113,dmask=0002 0 0
------------------------------------------------------------问题得到解决。
2.0 安装快速备份命令bcp
bcp命令:https://github.com/RickieL/bcp/blob/master/bcp
用于快速备份文件或目录。
wget https://nodeload.github.com/RickieL/bcp/tarball/master -O bcp.tar.gz
tar xzf bcp.tar.gz
cd RickieL-bcp-f65e017
chmod +x bcp
mv bcp /bin/bcp
2.1 备份php.ini配置文件
bcp /usr/local/php5/lib/php.ini
2.2 备份php-fpm.conf配置文件
bcp /usr/local/php5/etc/php-fpm.conf
2.3 备份/etc/init.d/php-fpm 启动文件
bcp /etc/init.d/php-fpm
2.4 备份原来的整个程序目录:
bcp /usr/local/php5
centos5.5安装最新的LNMP:
一、获取相关开源程序:
1、【适用CentOS操作系统】利用CentOS Linux系统自带的yum命令安装、升级所需的程序库(RedHat等其他Linux发行版可从安装光盘中找到这些程序库的RPM包,进行安装):
yum install telnet -y
yum install lrzsz -y
yum install nc -y
yum install unzip -y
yum install wget -y
yum install sudo -y
嵌入式串口相关操作rpm包安装:
yum install setserial
yum install minicom
扯下串口这块的记录:
得到的串口信息:
setserial -a /dev/ttyS0
/dev/ttyS0, Line 0, UART: 16550A, Port: 0x03f8, IRQ: 4
Baud_base: 115200, close_delay: 50, divisor: 0
closing_wait: 3000
Flags: spd_normal skip_test
setserial /dev/ttyS0 port 0x03f8 irq 4 uart 16550A baud_base 9600
设置:
root@192.168.225.128:/home/jackxiang/com# setserial /dev/ttyS0 port 0x03f8 irq 4 uart 16550A baud_base 9600
再看设置成功了没?
root@192.168.225.128:/home/jackxiang/com# setserial -a /dev/ttyS0
/dev/ttyS0, Line 0, UART: 16550A, Port: 0x03f8, IRQ: 4
Baud_base: 9600, close_delay: 50, divisor: 0
closing_wait: 3000
Flags: spd_normal skip_test
其它setserial参数设置:
root@192.168.225.128:/home/jackxiang/c_com# setserial -g /dev/ttyS0
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
root@192.168.225.128:/home/jackxiang/c_com# setserial -gb /dev/ttyS0
/dev/ttyS0 at 0x03f8 (irq = 4) is a 16550A
root@192.168.225.128:/home/jackxiang/c_com# setserial -g -G /dev/ttyS0
/dev/ttyS0 uart 16550A port 0x03f8 irq 4 baud_base 9600 spd_normal skip_test
相关参考:http://phorum.study-area.org/index.php/topic,25440.0.html
http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/Serial-HOWTO.html
http://baike.baidu.com/view/245027.htm
关于minicom也就可以在这儿查看以前的记录:http://jackxiang.com/visit.php?job=viewresult&sid=f13e4b9a640d4c80db689fab5db06c16
开始正式安装这个Lnmp:
sudo -s
LANG=C
yum -y 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 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
RedHat AS4 系统环境,通常情况下缺少的支持包安装,64位和32位会自动识别:
yum install libjpeg-devel
yum install freetype-devel
yum install libpng-devel
CentOS下MySQL 5.7.9编译安装,安装成功:
https://blog.linuxeye.com/432.html
多行容易有问题,实践一行更好使:
mysql-8.0.0-dmr-Linux-x86_64
-- Downloading boost_1_60_0.tar.gz to /data/software/mysql-8.0.0-dmr/boost/boost_1_60_0/boost
-- [download 0% complete]
-- [download 1% complete]
直接不带boost版本的mysql安装包:
安装mysql最新版本:
tar -zxvf cmake-2.8.4.tar.gz
首先,需要下载安装Cmake;
wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.12.tar.gz/from/http://cdn.mysql.com/
安装cmake;
tar xvzf cmake-2.8.4.tar.gz
./configure
make
make install
http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.27.tar.gz
vi /etc/profile
PATH=$PATH:/usr/local/bin/
export PATH
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql/ \
-DMYSQL_DATADIR=/usr/local/webserver/mysql/data \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/usr/local/webserver/mysql/data/mysql.sock \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0
为了不做软链接编译时就指定mysql.sock到另外的位置:
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql/ \
-DMYSQL_DATADIR=/usr/local/webserver/mysql/data \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/data0/data/mysql.sock \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0
VPS实践如下:(2014-09-28)
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \
-DMYSQL_DATADIR=/data/mysql \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0
我在编译的时候报错,意思是 DMYSQL_USER=mysql无效,懒得找原因,直接把那个参数给去掉了,接着进行下面的操作;
make && make install
如果想要加入:Coreseek编译上有区别,且目前版本不能全兼容,试了下:mysql5.5.8是可以的,需要加入参数:-DCMAKE_BUILD_TYPE=Release -DWITH_SPHINX_STORAGE_ENGINE=1
具体请看:http://jackxiang.com/post/4317/ 【可能没法访问,我还没有整理完的缘故】
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
cp support-files/my-small.cnf /etc/my.cnf
chown mysql:mysql /etc/my.cnf
chown -R mysql:mysql /usr/local/webserver/mysql
切换用户进入安装目录:
su mysql
cd /usr/local/webserver/mysql/scripts
./mysql_install_db
下面技巧实践Ok:
如安装的源代码文件给丢失后,也可以用下面的方法直接初始化Mysql的mysql表,相当于:
/usr/local/webserver/mysql/scripts/mysql_install_db --user=mysql --datadir=/data0/data/ --basedir=/usr/local/webserver/mysql
/usr/local/webserver/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql
出现:[注意:这儿就是指定BaseDir函数的脚本的地方啦]
FATAL ERROR: Could not find ./bin/my_print_defaults
修改:
basedir="/usr/local/webserver/mysql"
builddir="/root/software/mysql-5.5.8"
解决方法[上面就是直接修改啦,下面是参数传入罢了]:
/usr/local/webserver/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/webserver/mysql --datadir=/usr/local/webserver/mysql/data &(这点非常重要)
如何修改basedir特别是vps里有两个盘时,把database放到另外一块盘上:
datadir = /data/datadir/mysql
innodb_log_group_home_dir = /data/datadir/mysql
root@*.10.6.23:/usr/local/mysql/bin# ./mysqladmin -umysql shutdown
cp -Rf /usr/local/mysql/var/* /data/datadir/mysql/.
root@*.10.6.23:/usr/local/mysql/bin# service mysql start
Starting MySQL. ERROR! The server quit without updating PID file (/data/datadir/mysql/ZWCLC6X-7198.pid).
MYSQL启动后报:ERROR! The server quit without updating PID file错误的问题解决
无法启动mysql,后来上网找了一下解决方法,无非就是以下几种
1. 注释/etc/my.cnf里的skip-federated注释掉即#skip-federated;
2. my.cnf文件配置过高,重新定义其中的参数(根据服务器情况定义);
3. 杀掉mysql_safe和mysqld进程,然后再重启;
4. 当前日志文件过大,超出了my.cnf中定义的大小(默认为64M),删除日志文件再重启;
但是在主机中:
1. 注释中无skip-federated这个选项
2. My.cnf是自己优化过的,断电之前正常使用,不是这个的问题
3. Ps –ef | grep mysql 根本就没有mysql的僵尸进程
4. 没有这个问题
基本上网上的所有方式都试过了,都无法解决问题,然后我就打开了error.log,发现了是磁盘空间不够。
http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=4141403
root@*.10.6.23:/data/datadir# chown -R mysql:root mysql
root@*.10.6.23:/data/datadir# service mysql start
Starting MySQL.. SUCCESS!
110327 3:07:33 InnoDB: Initializing buffer pool, size = 128.0M
110327 3:07:33 InnoDB: Completed initialization of buffer pool
在/etc/my.cnf 打开下面的InnoDB配置以减少内存即可:
default-storage-engine=MyISAM [注意:Mysql5.6.11放在server-id里不行,还是会报Plugin 'InnoDB' is disabled错,要往上挪挪:放socket = /data0/data/mysql.sock 后就行了。]
server-id = 1
innodb_buffer_pool_size = 21M
innodb_additional_mem_pool_size = 2M
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
启动:带--user=mysql
/usr/local/webserver/mysql/bin/mysqld_safe --user=mysql &
编译PHP前准备:libiconv PHP Mysql都用得到,不安会出现如下情况
本人在编译php5.2.8时候,make ZEND_EXTRA_LIBS='-liconv',出现下列错误提示
ext/gd/libgd/gdkanji.o: In function `do_convert':
/data0/software/php-5.2.8/ext/gd/libgd/gdkanji.c:350: undefined reference to `libiconv_open'
/data0/software/php-5.2.8/ext/gd/libgd/gdkanji.c:365: undefined reference to `libiconv'
........
........
........
/data0/software/php-5.2.8/ext/iconv/iconv.c:2491: undefined reference to `libiconv_open'
/usr/bin/ld: final link failed: No space left on device
collect2: ld returned 1 exit status
先这样:
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
./configure --prefix=/usr/local/libiconv
make;make install
后依旧的话,则再看下:
注意“/usr/bin/ld: final link failed: No space left on device
”,应该是磁盘空间不够所致,果然,我清空了部分内容,顺利通过编译!算是给大家提醒一下,希望大家不要出现下列错误!
最后可能是直接用了make,而不是:make ZEND_EXTRA_LIBS='-liconv' ...
以上是我在编译:5.3.8版本时发现的,后面编译完后在运行FastCGI时会提示:
Starting php-fpm [eAccelerator] This build of "eAccelerator" was compiled for PHP version 5.3.6. Rebuild it for your PHP version (5.3.8) or download precompiled binaries.
done
于是需要重新编译一次这个缓存插件:
cd eaccelerator-0.9.6.1
/usr/local/webserver/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
还有就是查看php.ini关于eaccelerator的配置:
[eaccelerator]
zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/usr/local/webserver/eaccelerator_cache"
........
然后根据上面的目录结构中去删除以前版本的缓存即可:
root@116.255.139.240:/usr/local/webserver/eaccelerator_cache# ls
0 1 2 3 4 5 6 7 8 9 a b c d e f
root@116.255.139.240:/usr/local/webserver/eaccelerator_cache# rm -Rf *
------------------------------------------------------------------------------------------------------------------------------------
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local
make
make install
cd ..
http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
wget http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../
http://sourceforge.net/projects/mhash/files/mhash/
wget http://nchc.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make
make install
cd ..
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
http://sourceforge.net/projects/mcrypt/files/MCrypt/
wget http://nchc.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
/sbin/ldconfig
./configure
make
make install
可能会出现:
=================================================================
configure: error: *** libmcrypt was not found
为了的到mcrypt.so库文件,先后安装编译了mhash和libmcrypt,但是到最后编译mcrypt时报错:
configure: error: *** libmcrypt was not found
最后发现是因为环境变量的问题,gcc编译的时候根据自身定义的变量寻找相关函数库等文件,libmcrypt也是刚安装的,在变量中没有定义出来,所以手动添加:
[root@localhost modules]# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
再次编译即可。
=================================================================
PHP5.3.9: wget http://cn.php.net/get/php-5.3.9.tar.gz/from/this/mirror
编译PHP:
wget http://cn.php.net/distributions/php-5.3.6.tar.gz
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local/libiconv --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 --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl
PHP7.0编译参数:
./configure --prefix=/usr/local/php7.0 --with-config-file-path=/usr/local/php7.0/etc --with-fpm-user=www --with-fpm-group=www --enable-fpm --disable-fileinfo --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif --enable-sysvsem --with-curl --enable-mbregex --enable-inline-optimization --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug --enable-opcache --with-readline
make时还是需要加上iconv那个:make ZEND_EXTRA_LIBS='-liconv',否则还是会报错,对于PHP7.0主PHP低的生产版本混合运行,把:
cp /etc/init.d/php-fpm拷贝到自己的home目录下修改一下路径,重新启动,这个脚本的启动参数打印了下,如下:
/usr/local/php7.0/sbin/php-fpm --daemonize --fpm-config /usr/local/php7.0/etc/php-fpm.conf --pid /usr/local/php7.0/var/run/php-fpm.pid
本次新加:
--with-pdo=shared -with-pdo-mysql=/usr/local/webserver/mysql
PHP想在一开始就把PDO编译进去,而不是直接加载PDO.so,在configure时可能会出现一个问题,如下:
checking for MySQL support for PDO... yes
checking for mysql_config... /usr/local/webserver/mysql/bin/mysql_config
checking for mysql_query in -lmysqlclient... no
checking for mysql_query in -lmysqlclient... (cached) no
configure: error: PDO_MYSQL configure failed. Please check config.log for more information.
引起的原因,Centos6.2最小化安装,没有安一个rpm包:mysql-level没有装,或者是mysql的版本不对。但Mysql我是通过源码安装的,于是,可以在目录 /usr/local/webserver/mysql/lib/ 找到以下需要的包,也就是最新的Mysql5.5.20编译好的这些库,如下:
[root@bogon lib]# echo ~+/libmysqlclient.
libmysqlclient.a libmysqlclient.so libmysqlclient.so.18 libmysqlclient.so.18.0.0
[root@bogon lib]# ls ~+/libmysqlclient.a
/usr/local/webserver/mysql/lib/libmysqlclient.a
export LDFLAGS=-L/usr/local/webserver/mysql/lib/
再次在PHP5.3.10下进行configure时,就不会提示PDO的相关问题了,但问题依旧,难道还是得要单独安装这个PDO模块!!
暂时不安PDO,先把所有用到的都给编译进PHP里去再说,如下:
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local/libiconv --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 --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --enable-soap=shared --enable-pdo enable-dom --with-readline --enable-xmlwriter --with-pcre-regex --with-pear --enable-session --enable-spl --enable-hash --enable-reflection
出现:configure: error: Please reinstall readline - I cannot find readline.h
解决方法:
yum install readline-devel
但又报错:php configure: error: readline library not found 干脆去掉这一个不常用的项目:
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local/libiconv --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 --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --enable-soap=shared --enable-pdo enable-dom --enable-xmlwriter --with-pcre-regex --with-pear --enable-session --enable-spl --enable-hash --enable-reflection
就configure通过了:
Thank you for using PHP.
make ZEND_EXTRA_LIBS='-liconv'
//如果是路径L不对得手动加参数:
make ZEND_EXTRA_LIBS='-liconv -L/usr/local/lib'
成功...
make install
/usr/bin/ld: ext/ldap/.libs/ldap.o: undefined reference to symbol 'ber_strdup'
/usr/bin/ld: note: 'ber_strdup' is defined in DSO /lib64/liblber-2.4.so.2 so try adding it to the linker command line
/lib64/liblber-2.4.so.2: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make: *** [sapi/cli/php] 错误 1
在老外的一篇文章中终于找到解决办法,我是在centos7下进行编译时遇到这个问题的:
-Run your configure command
-edit Makefile
-Find the line that starts with "EXTRA_LIBS ="
-Add the following to the end of the line " -llber"
cp php.ini-dist /usr/local/webserver/php/etc/php.ini
cd ../
刚开始就把SOAP编译进去:
Move into the source directory and configure PHP with SOAP enabled (this may take a few minutes):
cd php-5.2.5
./configure --enable-soap=shared
加上这个:
--enable-soap=shared
加上后是这样:
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local/libiconv --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 --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --enable-soap=shared
make ZEND_EXTRA_LIBS='-liconv'
PHP5.6.3 2014-11-30 编译成功备案:
编译php报错:/usr/bin/ld: cannot find -liconv解决方法:
首先检查libiconv是否有安装,其次,确认libiconv的安装目录为/usr/local,即编译参数
]#./configure --prefix=/usr/local
然后记得更新下库
]#ldconfig
在最后面添加 -liconv :
编辑:
./src/MakeFile文件
将
LIBS = -lm -lexpat -L/usr/local/lib
改成
LIBS = -lm -lexpat -liconv -L/usr/local/lib
vi /etc/ld.so.conf
这样php编译安装就可以正常运行了。
但有时还是会报错的:
||||||PHP的configure没加:--with-iconv=/usr/local/libiconv引发的/usr/bin/ld: cannot find -liconv||||||||
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv=/usr/local/libiconv --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-gettext --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --with-snmp --enable-shmop --enable-sysvsem --enable-sysvshm --enable-calendar --enable-inline-optimization --with-curl --with-curlwrappers --enable-exif --enable-sysvmsg --with-mcrypt --with-gd --enable-gd-jis-conv --disable-debug --with-openssl --with-mhash --enable-pcntl --silent --enable-sockets
make
make install
出现的原因是没加:--with-iconv=/usr/local/libiconv ,这个是编译时编译到那儿的:
------------------------------------------------------------------------------------------------------------------------------------------
解决方法:
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar -zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/libiconv
make
make install
------------------------------------------------------------------------------------------------------------------------------------------
~/software/php-5.3.15# ./configure --help|grep iconv
--without-iconv[=DIR] Exclude iconv support
--with-iconv-dir=DIR XMLRPC-EPI: iconv dir for XMLRPC-EPI
--with-iconv-dir:
用于 PHP 编译时指定 iconv 在系统里的路径,否则会扫描默认路径。
--with-iconv:
要激活这个扩展必须在编译时使用[DIR]
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
昨天编译安装PHP的时候make报错,make: *** [sapi/fpm/php-fpm] Error 1
/usr/bin/ld: cannot find -liconv
collect2: ld returned 1 exit status
make: *** [sapi/fpm/php-fpm] 错误 1
上面的方法还是没法解决,最后解决了,直接用make,没有用make ZEND_EXTRA_LIBS='-liconv'
不再提示cannot find -liconv,而是:error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory ,于是按以前的方法,如下:ln -s /usr/local/webserver/mysql/lib/libmysqlclient.so.18 /usr/lib/ ,再make一下,直接就过去了,Yeath.
原因iconv重复安装在不同目录,造成include文件iconv.h等重复 通过 find / -name “iconv.h” 如果查找到2个以上返回结果,说明 iconv重复安装了,卸载多余的版本即可正常编译。
[root@bogon /]# find / -name "iconv.h"
/usr/local/libiconv/include/iconv.h
/usr/include/iconv.h
果然是这个问题。
安装iconv是源码编译安装,于是到安装目录cd /usr/local/src/libiconv-1.13.1,执行 make uninstall卸载自己安装的版本。再重新安装PHP。
问题1:
You may want to add: /usr/local/webserver/php/lib/php to your php.ini include_path
/root/jackxiang.com/php-5.3.6/build/shtool install -c ext/phar/phar.phar /usr/local/webserver/php/bin
cp: cannot stat `ext/phar/phar.phar': No such file or directory
[vps实践]linux下安装php5.3.6的扩展包pear :http://jackxiang.com/post/4153/
(1)chmod: cannot access `ext/phar/phar.phar': No such file or directory:
wget http://pear.php.net/go-pear.phar
[root@localhost phar]# /usr/local/webserver/php/bin/php go-pear.phar
Below is a suggested file layout for your new PEAR installation. To
change individual locations, type the number in front of the
directory. Type 'all' to change all of them or simply press Enter to
accept these locations.
1. Installation base ($prefix) : /usr/local/webserver/php
2. Temporary directory for processing : /tmp/pear/install
3. Temporary directory for downloads : /tmp/pear/install
4. Binaries directory : /usr/local/webserver/php/bin
5. PHP code directory ($php_dir) : /usr/local/webserver/php/lib/php
6. Documentation directory : /usr/local/webserver/php/docs
7. Data directory : /usr/local/webserver/php/data
8. User-modifiable configuration files directory : /usr/local/webserver/php/cfg
9. Public Web Files directory : /usr/local/webserver/php/www
10. Tests directory : /usr/local/webserver/php/tests
11. Name of configuration file : /usr/local/webserver/php/etc/pear.conf
1-11, 'all' or Enter to continue: all
这个根据个人环境进行修改。(我是直接回车即可)
================================================
(2)chmod: cannot access `ext/phar/phar.phar': No such file or directory:
make: [ext/phar/phar.phar] Error 1 (ignored)
解决方法1:./configure的时候 要加上--without-pear
然后再make install或者重新make ZEND_EXTRA_LIBS='-liconv',Then :make install
解决方法2:
cd ext/phar/. cp ./phar.php phar.phar
问题2:
/root/jackxiang.com/php-5.3.6/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
make: *** [ext/phar/phar.php] Error 127
ln -s /usr/local/webserver/mysql/lib/libmysqlclient.so.18 /usr/lib/
PHP扩展:
memcache:
http://pecl.php.net/package/memcache
wget http://pecl.php.net/get/memcache-3.0.6.tgz
tar zxvf memcache-3.0.6.tgz
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../
eaccelerator:
wget http://bart.eaccelerator.net/source/0.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/webserver/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../
PDO_MYSQL:
http://pecl.php.net/package/PDO_MYSQL
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/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-pdo-mysql=/usr/local/webserver/mysql
make
make install
cd ../
ImageMagick:
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.6.8-8
./configure
make
make install
imagick:[依赖前面的ImageMagick,注意顺序]
wget http://pecl.php.net/get/imagick-3.1.0b1.tgz
tar -zxvf imagick-3.1.0b1.tgz
cd imagick-3.1.0b1
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../
修改php.ini文件:
cd /root/jackxiang.com/php-5.3.6
cp ./php.ini-production /usr/local/webserver/php/etc/php.ini
手工修改:查找/usr/local/webserver/php/etc/php.ini中的extension_dir = "./"
修改为extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/"
//各种PHP版本的extension_dir是不一样的!!!
并在此行后增加以下几行,然后保存:
extension = "memcache.so"
extension = "pdo_mysql.so"
extension = "imagick.so"
再查找output_buffering = Off
修改为output_buffering = On
[eaccelerator]
zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/usr/local/webserver/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="300"
eaccelerator.shm_prune_period="120"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
安装Nginx:
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.12.zip
tar zxvf pcre-7.8.tar.gz
cd pcre-8.12
./configure
make && make install
cd ../
wget http://nginx.org/download/nginx-0.9.6.tar.gz
wget http://nginx.org/download/nginx-1.0.2.tar.gz
cd nginx-0.9.6
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
cd ../
启动nginx:
/usr/local/webserver/nginx/sbin/nginx -c /usr/local/webserver/nginx/conf/nginx.conf
如果需要添加Nginx_HTTP_Push_Module长连接模块,需要加入新选项,/root/software/nginx_http_push_module-0.692是下载的模块文件位置:
--add-module=/root/software/nginx_http_push_module-0.692
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --add-module=/root/software/nginx_http_push_module-0.692
自己加入安全模块的编译选项:
./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --add-module=/root/software/nginx_http_push_module-0.692 --add-module=/root/software/ngx_cache_purge-1.3 --with-http_secure_link_module
目前最新生产环境的版本:
wget http://nginx.org/download/nginx-1.0.8.tar.gz 这儿新加了一个模块:--with-http_mp4_module
./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --add-module=/root/software/nginx_http_push_module-0.692 --add-module=/root/software/ngx_cache_purge-1.3 --with-http_secure_link_module --with-http_mp4_module
编译:
make;make install
配置nginx.conf:
error_page 519 /519.html;
if ($request_uri ~* "(cost\()|(concat\()") {
return 519;
}
if ($request_uri ~* "[+|(%20)]union[+|(%20)]") {
return 519;
}
if ($request_uri ~* "[+|(%20)]and[+|(%20)]") {
return 519;
}
if ($request_uri ~* "[+|(%20)]select[+|(%20)]") {
return 519;
}
还有乱七八糟的一些扩展参考:
configure arguments: --prefix=/home/nginx --with-pcre --add-module=../ngx_http_consistent_hash --add-module=../ngx_max_connections --add-module=../ngx_cache_purge --add-module=../ngx_mp4_streaming_public --with-cc-opt=-O3 --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --without-http_memcached_module --without-http_fastcgi_module --with-google_perftools_module
编译过程中几个注意事项:
1、必须采用--with-pcre,而不要偷懒采用--without-http_rewrite_module,否则配置文件里将不支持if判断;
2、加载mp4_streaming,必须采用--with-cc-opt=-O3方式进行编译。
3、max_connections模块默认支持nginx最新版本是0.8.32,需要vi修改其DIR,然后path -p0,但千万不要看见有个Makefile就执行make && make install了,因为它会毫无道理的把整个nginx安装到当前目录的.nginx下隐藏起来……
最新安装nginx-1.1.0全编译项目配置如下:
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --add-module=/root/software/nginx_http_push_module-0.692 --add-module=/root/software/ngx_cache_purge-1.3
在linux下安装Nginx的Pcre包的时候,有时候提示
configure: error: newly created file is older than distributed files!
Check your system clock
出现此编译错误,请检查你的系统时间是否设置有误。。。
查看硬件日期时间
hwclock -show
linux是每隔一段时间将系统时间写入 硬件bois的 如果刚设置完了就关机,开机后时间还是等于没有设置
# date -s 991128
Sun Nov 28 00:00:00 CST 1999
实例:设置时间伟2008年8月8号12:00
# date -s “2008-08-08 12:00:00″
修改完后,记得输入:
clock -w
把系统时间写入CMOS即可
参看:http://linux.net527.cn/fuwuqiyingyong/Webfuwuqi/16516.html
---------------------
配置nginx和phpfastcgi平滑过度:
创建php-fpm配置文件(php-fpm是为PHP打的一个FastCGI管理补丁,可以平滑变更php.ini配置而无需重启php-cgi):
在/usr/local/webserver/php/etc/目录中创建php-fpm.conf文件:
rm -f /usr/local/webserver/php/etc/php-fpm.conf
vi /usr/local/webserver/php/etc/php-fpm.conf
输入以下内容(如果您安装 Nginx + PHP 用于程序调试,请将以下的<value name="display_errors">0</value>改为<value name="display_errors">1</value>,以便显示PHP错误信息,否则,Nginx 会报状态为500的空白错误页):
优化fpm参数:
[root@localhost]# vi php-fpm.conf 【把前面的分号给去掉】
user = www
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 5
pm.min_spare_servers = 2
pm.max_spare_servers = 7
pm.max_requests = 120
创建Nginx日志目录:
mkdir -p /data1/logs
chmod +w /data1/logs
chown -R www:www /data1/logs
创建Nginx配置文件
在/usr/local/webserver/nginx/conf/目录中创建nginx.conf文件:
rm -f /usr/local/webserver/nginx/conf/nginx.conf
vi /usr/local/webserver/nginx/conf/nginx.conf
<!--Begin-->
user www www;
worker_processes 8;
error_log /data1/logs/nginx_error.log crit;
pid /usr/local/webserver/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
http
{
include mime.types;
default_type application/octet-stream;
#charset gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
#limit_zone crawler $binary_remote_addr 10m;
server
{
listen 80;
server_name status.blog.jackxiang.com;
location / {
stub_status on;
access_log off;
}
}
server
{
listen 80;
server_name jackxiang.com www.jackxiang.com;
index index.html index.htm index.php;
root /data0/htdocs/blog;
if (!-e $request_filename)
{
rewrite ^/post/([0-9]+)/?([0-9]+)?/?([0-9]+)?/?$ /read.php?entryid=$1&page=$2&part=$3 last;
rewrite ^/page/([0-9]+)/([0-9]+)/?$ /index.php?mode=$1&page=$2 last;
rewrite ^/starred/([0-9]+)/?([0-9]+)?/?$ /star.php?mode=$1&page=$2 last;
rewrite ^/category/([^/]+)/?([0-9]+)?/?([0-9]+)?/?$ /index.php?go=category_$1&mode=$2&page=$3 last;
rewrite ^/archiver/([0-9]+)/([0-9]+)/?([0-9]+)?/?([0-9]+)?/?$ /index.php?go=archive&cm=$1&cy=$2&mode=$3&page=$4 last;
rewrite ^/date/([0-9]+)/([0-9]+)/([0-9]+)/?([0-9]+)?/?([0-9]+)?/?$ /index.php?go=showday_$1-$2-$3&mode=$4&page=$5 last;
rewrite ^/user/([0-9]+)/?$ /view.php?go=user_$1 last;
rewrite ^/tags/([^/]+)/?([0-9]+)?/?([0-9]+)?/?$ /tag.php?tag=$1&mode=$2&page=$3 last;
rewrite ^/component/id/([0-9]+)/?$ /page.php?pageid=$1 last;
rewrite ^/component/([^/]+)/?$ /page.php?pagealias=$1 last;
#Force redirection for old rules
rewrite ^/read\.php/([0-9]+)\.htm$ http://$host/post/$1/ permanent;
rewrite ^/post/([0-9]+)\.htm$ http://$host/post/$1/ permanent;
rewrite ^/post/([0-9]+)\_([0-9]+)\.htm$ http://$host/post/$1/$2/ permanent;
rewrite ^/post/([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/post/$1/$2/$3/ permanent;
rewrite ^/index\_([0-9]+)\_([0-9]+)\.htm$ http://$host/page/$1/$2/ permanent;
rewrite ^/star\_([0-9]+)\_([0-9]+)\.htm$ http://$host/starred/$1/$2/ permanent;
rewrite ^/category\_([0-9]+)\.htm$ http://$host/category/$1/ permanent;
rewrite ^/category\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/category/$1/$2/$3/ permanent;
rewrite ^/archive\_([0-9]+)\_([0-9]+)\.htm$ http://$host/archiver/$1/$2/ permanent;
rewrite ^/archive\_([0-9]+)\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/archiver/$1/$2/$3/$4/ permanent;
rewrite ^/showday\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/date/$1/$2/$3/ permanent;
rewrite ^/showday\_([0-9]+)\_([0-9]+)\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/date/$1/$2/$3/$4/$5/ permanent;
#Filename alias
rewrite ^/([a-zA-Z0-9_-]+)/?([0-9]+)?/?([0-9]+)?/?$ /read.php?blogalias=$1&page=$2&part=$3 last;
}
#limit_conn crawler 20;
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log /data1/logs/access.log access;
}
}
<--End-->
安装Memache:
libevent-2.0.10-stable:
wget http://monkey.org/~provos/libevent-2.0.10-stable.tar.gz
tar xzf libevent-2.0.10-stable.tar.gz
cd libevent-2.0.10-stable
./configure
make
make install
#刷新库文件连接
ldconfig
Then Memcache setup:
wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
tar xzf memcached-1.4.5.tar.gz
cd memcached-1.4.5
./configure --prefix=/usr/local/webserver/memcached
make
make install
#增加用户组memcached和用户memcached
/usr/sbin/groupadd memcached
/usr/sbin/useradd -g memcached memcached
启动Memcached时可能出现的问题:
找不到以下的so,用如下操作及可:
ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/
启动PHP的FastCGI:
启动PHP FastCGI:
cp /root/jackxiang.com/php-5.3.6/sapi/fpm/init.d.php-fpm /etc/init.d/phpfpm
chmod 755 /etc/init.d/phpfpm
ulimit -SHn 51200
/etc/init.d/phpfpm start
启动PHp的FastCGI时可能会出现下面错误:
出现下面的错误(这个错误是我在安装过程中发现的,是内在不足导致的,在文章的结尾优化后,就不会有这样的问题了,在这里做个记录,方便大家学习)
Starting php_fpm eAccelerator: Could not allocate 67108864 bytes, the maximum size the kernel allows is 33554432 bytes. Lower the amount of memory request or increase the limit in /proc/sys/kernel/shmmax.
PHP Warning: [eAccelerator] Can not create shared memory area in Unknown on line 0
PHP Fatal error: Unable to start eAccelerator module in Unknown on line 0
failed
#说明
php.ini中设置的eAccelerator,eaccelerator.shm_size="64",解释:eaccelerator可使用的共享内存大小(单位为MB),即64M
在Linux下,单个进程的最大内存使用量受/proc/sys/kernel/shmmax中设置的数字限制(单位为字节) /proc/sys/kernel/shmmax = 33554432 (32M)
临时更改该值:
echo 128000000 > /proc/sys/kernel/shmmax
或者
vi /etc/sysctl.conf
#add by jack
kernel.shmmax = 128000000
使配置立即生效:
/sbin/sysctl -p
优化Linux内核参数
vi /etc/sysctl.conf
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 5000 65000使配置立即生效:
/sbin/sysctl -p
配置开机自动启动Nginx + PHP:
在不停止Nginx服务的情况下平滑变更Nginx配置
修改/usr/local/webserver/nginx/conf/nginx.conf配置文件后,请执行以下命令检查配置文件是否正确
/usr/local/webserver/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/webserver/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/webserver/nginx/conf/nginx.conf test is successful这时,输入以下命令查看Nginx主进程号:
ps -ef | grep "nginx: master process" | grep -v "grep" | awk -F ' ' '{print $2}'
这时,执行以下命令即可使修改过的Nginx配置文件生效:
kill -HUP 6302
kill -HUP `cat /usr/local/webserver/nginx/nginx.pid`
编写每天定时切割Nginx日志的脚本:
创建脚本/usr/local/webserver/nginx/sbin/cut_nginx_log.sh
vi /usr/local/webserver/nginx/sbin/cut_nginx_log.sh
#!/bin/bash
# This script run at 00:00
# The Nginx logs path
logs_path="/usr/local/webserver/nginx/logs/"
mkdir -p ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/
mv ${logs_path}access.log ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/access_$(date -d "yesterday" +"%Y%m%d").log
kill -USR1 `cat /usr/local/webserver/nginx/nginx.pid`
设置crontab,每天凌晨00:00切割nginx访问日志
crontab -e
00 00 * * * /bin/bash /usr/local/webserver/nginx/sbin/cut_nginx_log.sh
开机自动 启动namp服务如下设置,关于开机程序的自动启动:
1)如专门启动Mysql这样一个,你可以参考:
开机自动 启动Mysql的方法: http://www.jackxiang.com/post/4730/ ,
也就是随便芿一个可执行文件到目录:/etc/rc.d/init.d/ ,赋予可执行权限写入开机启动的脚本即可。
2)如果要同时启动多个服务器软件,则如下所示:
开机启动知识及步骤如下:
想用命令chkconfig加载自启动.提示"**服务不支持chkconfig",原来是自己写的脚本时,忘记写两行了.开头一般要这样写,345是启动级,85和15分别是启动优先级,关闭优先级,下面的就是描述了。:
#!/bin/bash
#chkconfig:345 61 61 //此行的345参数表示,在哪些运行级别启动,启动序号(S61);关闭序号(K61)
#description:nginx php mysql memcache start shell
,修改来自Apache里的启动shell,也可以不用修改:
保存为/etc/init.d/lnmp,内容如下:
#!/bin/bash
#chkconfig:345 61 61
#description:nginx php mysql memcache start shell
echo "Starting memcache mysql php nginx daemon..."
ulimit -SHn 51200
nohup /usr/local/webserver/memcached/bin/memcached -d -m 1 -u www -p 11211 > /dev/null 2>&1 &
nohup /usr/local/webserver/mysql/bin/mysqld_safe --user=mysql > /dev/null 2>&1 &
nohup /etc/init.d/phpfpm start > /dev/null 2>&1 &
nohup /usr/local/webserver/nginx/sbin/nginx -c /usr/local/webserver/nginx/conf/nginx.conf > /dev/null 2>&1 &
把脚本拷贝至/etc/init.d/目录下,执行命令:
ln -s /etc/init.d/lnmp /etc/rc.d/rc3.d/S61lnmp
ln -s /etc/init.d/lnmp /etc/rc.d/rc4.d/S61lnmp
ln -s /etc/init.d/lnmp /etc/rc.d/rc5.d/S61lnmp
再执行
chkconfig --add lnmp
chkconfig --levels lnmp345 on //也成
开机启动:
service lnmp start
env: /etc/init.d/lnmp: 权限不够
chmod -R a+x /etc/init.d/lnmp
reboot 重启动,看服务起来了没,没起来再运行:service lnmp 试试,这儿就不用start了,因上面没有start这个参数!!!
要删除某个service的自动启动的设置,使用--del选项,如下:
# chkconfig --del lnmp
# chkconfig --list | grep lnmp
Nginx这块自己有ssl启动需要输入密码,默认的那个不行,怎么干掉?
nginx 开机启动的service项想删除,service nginx start 这个想干掉,我现在放开机启动里了:
/etc/init.d/nginx //可以把它重写成自己的,因为我的有https
chkconfig nginx off
=======================shell环境关于bash启动脚本======================================
/etc/profile
/etc/bashrc
~/.bash_profile
~/.bashrc
~/.bash_logout
每一个文件都有特殊的功用并对登陆和交互环境有不同的影响。
/etc/profile 和 ~/.bash_profile 是在启动一个交互登陆shell的时候被调用。
/etc/bashrc 和 ~/.bashrc 是在一个交互的非登陆shell启动的时候被调用。
~/.bash_logout 在用户注销登陆的时候被读取
一 个交互的登陆shell会在 /bin/login 成功登陆之后运行。一个交互的非登陆shell是通过命令行来运行的,如[prompt]$/bin/bash。一般一个非交互的shell出现在运行 shell脚本的时候。之所以叫非交互的shell,是因为它不在命令行上等待输入而只是执行脚本程序。
关于开机程序的自动启动
系统脚本可以放置在/etc/rc.d/init.d中并建立/etc/rc.d/rc?.d链接,也可以直接放置在/etc/rc.d/rc.local中。
init.d脚本包含完整的start,stop,status,reload等参数,是标准做法,推荐使用。
为特定用户使用的程序(如有的用户需要使用中文输入法而有的不需要)放置在~/中的bash启动脚本中。
chkconfig --list //开机启动的list
ntsysv //simple gui,直接修改
chkconfig httpd off //还是这个见效快****
chkconfig iptables off //关闭防火墙,还是这个见效快*
chkconfig --list |grep sendmail
chkconfig sendmail off
chkconfig --list |grep auditd
chkconfig auditd off
chkconfig rpcgssd off
chkconfig rpcidmapd off
chkconfig rpcsvcgssd off
chkconfig portmap off最近发现了一个Deamo进程也可以关闭:
udp 0 0 0.0.0.0:46563 0.0.0.0:* 2295/avahi-daemon:
udp 0 0 0.0.0.0:5353 0.0.0.0:* 2295/avahi-daemon:
udp 0 0 :::5353 :::* 2295/avahi-daemon:
步骤方法如下:
chkconfig --list avahi-daemon
root@116.255.139.240:/data0/htdocs/blog/template# chkconfig --list avahi-daemon
avahi-daemon 0:off 1:off 2:off 3:on 4:on 5:on 6:off
avahi-daemon 关闭:
service avahi-daemon stop
chkconfig avahi-daemon off 再看:
root@116.255.139.240:/data0/htdocs/blog/template# chkconfig --list avahi-daemon
avahi-daemon 0:off 1:off 2:off 3:off 4:off 5:off 6:off确实关闭了。
试试把 avahi-daemon 服务关闭,你会得到空前变化。avahi-daemon
Avahi 是 zeroconf 协议的实现。它可以在没有 DNS 服务的局域网里发现基于 zeroconf 协议的设备和服务。它跟mDNS 一样。除非你有兼容的设备或使用 zeroconf 协议的服务,否则应该关闭它。现在用的基本都是DNS了。
更专业点讲就是The Avahi mDNS/DNS-SD daemon implements Apple’s Zeroconfarchitecture(also known as "Rendezvous" or "Bonjour"). The daemonregisters local IP addresses and static services using mDNS/DNS-SD andprovides two IPC APIs for local programs to make use of the mDNS recordcache the avahi-daemon maintains.
avahi-daemon is a daemon which runs on client machines to performZeroconf service discovery on a network. avahi-daemon must be runningon systems that use Avahi for service discovery. Avahi-daemon shouldnot be running otherwise.
AutoMount 自动挂载功能
方法: 启动进程autofs
在RedHat安装后期,在选择启动时需要自动执行进程的那一步骤剔选“autofs”。
如果已经安装好了作业系统,也可以更改该项设置。在Terminal中输入“setup”指令,选“System services”,或者直接输入启动进程配置指令“ntsysv”都可以打开启动进程配置介面,剔选“autofs后,下次进入RedHat Linux后,这一进程就会被自动装载。
1837 root 15 0 29424 1376 1060 S 0.0 0.5 0:00.23 automount
root@116.255.139.240:~# chkconfig --list|grep autofs
autofs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
chkconfig autofs off
root@116.255.139.240:~# service autofs stop
vps取消设置自动挂载ISCSI分区的服务:
方法一:
用编辑器打开/etc/fstab 例如:gedit /etc/fstab ,并在最后一行加入下列命令
/dev/sda1 /mnt/t0 ext2 defaults 0 0 //如果是FAT分区,则将ext2改为vfat。(这个选项很重要,如果没有则无法成功自动挂载)
关闭测试启动自动挂载磁盘的服务:
root@116.255.139.240:~# chkconfig --list|grep iscsi
iscsi 0:off 1:off 2:off 3:on 4:on 5:on 6:off
iscsid 0:off 1:off 2:off 3:on 4:on 5:on 6:off
root@116.255.139.240:~# chkconfig iscsid off
root@116.255.139.240:~# service iscsid stop
Stopping iSCSI daemon:
root@116.255.139.240:~# [ OK ]
Stopping automount: [ OK ]
php扩展ssh2的安装:
wget http://www.libssh2.org/download/libssh2-1.2.7.tar.gz
cd libssh2-1.2.7
./configure
make;make install
pecl install -f ssh2
选择:Y
/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/ssh2.so
You should add "extension=ssh2.so" to php.ini
PHP SOAP Extension:
cd /root/jackxiang.com/php-5.3.6/ext/soap
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make;make install
/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/soap.so
特别注意:
开机启动SVN服务的Apache的设置方法:
vim /etc/init.d/apache
/usr/local/webserver/apache2/bin/apachectl start
chmod 775 /etc/init.d/apache
chkconfig apache on
当然你也可以抄一个shell标准脚本,如前面php的phpfpm启动脚本。
遇到443端口加密需要需要输入密码的还请慎重考虑,如下所示:
Server svn.jackxiang.com:443 (RSA)
Enter pass phrase:
Apache:mod_ssl:Error: Pass phrase empty (needs to be at least 1 character).
Enter pass phrase:
Ok: Pass Phrase Dialog successful.
需要研究如何自动启动并自动地输入密码。
这块还不行,这块expect里的spawn要和ssh结合,nginx这种情况还不行,下面这个有警告,但是能执行:
上面路径要写死/usr/local/scripts,别相对:
startNginx.sh
升级到PHP5.3.8后启动FastCGI出现:
root@116.255.139.240:~/software/eaccelerator-0.9.6.1# cat /root/runphp.sh
pkill -9 php
usleep 100000
/etc/init.d/phpfpm start
=============执行上面这段代码:
root@116.255.139.240:~/software/eaccelerator-0.9.6.1# sh /root/runphp.sh
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Starting php-fpm
done
原因是:估计升级PHP后 还是在原来PHP目录下,到了一个不存在的目录中 而显示错误.
Mysql的数据文件移动时出现的新问题:2011-10-16 Add By:jack。
主要是讲述新版本的Mysql在移动目录时,在特别是有Innodb的情况下,出现问题解决问题的一个过程,及Mysql的sock文件和PHP接合的问题。
Mysql数据文件搬家到另外一个目录出现的 二个问题(从/usr/local/webserver/mysql/data/ 搬家到:/data0/data),如下:
1.Innodb出现问题,Mysql启动不了,如附录中的日志所示:
InnoDB: The InnoDB memory heap is disabled
这样的警告,查资料说,只要在my.cnf中加入以下,就可以消除以上警告
innodb_use_sys_malloc =0
系统默认为
innodb_use_sys_malloc =1
似乎有人说innodb_use_sys_malloc =1速度更快,我还没有得到证实。
所以,我就没有修改了。
解决办法:
cd /data0/data
rm -Rf ibdata1
rm -Rf ib_logfile0
rm -Rf ib_logfile1
========================================================
1.检查Linux下Mysql的日志
2.错误信息是"Default storage engine (InnoDB) is not available"
解决方法:
1.删除在MySQL安装目录下的Data目录中的
ib_logfile0
ib_logfile1
2.找到在配置MySQL服务器时指定的InfoDB目录删除掉
ibdata1
3.重新启动MySQL的Service
这个问题第二天又摸索了一下,其实是可以用InnoDB引擎的.
需要在mysql生成的配置文件增加一行配置,即增加一个临时目录,这个在启动mysql服务的时候是需要的.
[mysqld]
tmpdir=/tmp
我的my.ini配置文件如下,注意红色字体,是默认不会生成的;
========================================================
如下:
root@116.255.139.240:/data0/data# rm -Rf ib_logfile0 ib_logfile1
root@116.255.139.240:/data0/data# rm -Rf ibdata1
root@116.255.139.240:/data0/data# rm -Rf ibdata1
后续指定DB目录,和InnoDB目录及日志文件设置如下:
datadir = /data0/data/
innodb_data_home_dir = /data0/data/
innodb_data_home_dir = /data0/data/
innodb_log_group_home_dir = /data0/data/
innodb_data_file_path = ibdata1:128M:autoextend
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_use_sys_malloc = 0
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 4M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 5M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
#log write and so on...
general-log = /data0/data/error_log/log-error.log
log-error = /data0/data/error_log/log-error.log
slow-query-log = /data0/data/error_log/log-slow-query.log
#slow query search
slow_query_log=1
slow_query_log_file = /data0/data/slow_query_log/mysql-slow.log
long_query_time = 2
log-queries-not-using-indexes
2.移动数据文件目录后再访问时出现了问题二:
Bo-Blog Database System Tips: Can not connect to MySQL server
Time: 2011-10-16 8:09am
Script:
Error: Can't connect to local MySQL server through socket '/usr/local/webserver/mysql/data/mysql.sock' (2)
Errno.: 2002
检测php.ini的设置,再检测my.conf里面的值设成一样就OK 另外目录mysql.sock所在目录的读取权限也是
如果用php连接要特别注意php.ini的设置
mysql.default_socket=(默认为空) ,这块连接Mysql相关的设置请看:http://www.jackxiang.com/post/4327/
所以首要侨务检测php.ini的设置,再检测my.conf里面的值设成一样就OK
另外目录mysql.sock所在目录的读取权限也是问题(兄弟们原谅我linux下的目录权限真的是不懂,所以简单点就直接chmod 777了)
另外要特别注意,我想这点才是可能导致失败的就是web目录不能用root用户运行.而应该用nobody用户
# vi /etc/my.cnf
[mysqld]
port = 3306
socket = /data0/data/mysql.sock
vi /usr/local/webserver/php/etc/php.ini
mysql.default_socket =
修改成和修改后的一样即可:
mysql.default_socket = /data0/data/mysql.sock
是FastCGI得重启fastcgi的Php,而如是Apache,则重启动Apache即可,就是把PHP.ini给纳入重新初始化。
附录Mysql启动后的日志情况:
111016 16:01:29 mysqld_safe Starting mysqld daemon with databases from /data0/data
InnoDB: Mutexes and rw_locks use InnoDB's own implementation
InnoDB: Compressed tables use zlib 1.2.3
111016 16:01:29 InnoDB: Initializing buffer pool, size = 18.0M
111016 16:01:29 InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file /data0/data/ibdata1 did not exist:
InnoDB: a new database to be created!
111016 16:01:29 InnoDB: Setting file /data0/data/ibdata1 size to 128 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Progress in MB: 100
InnoDB: Error: all log files must be created at the same time.
InnoDB: All log files must be created also in database creation.
InnoDB: If you want bigger or smaller log files, shut down the
InnoDB: database and make sure there were no errors in shutdown.
InnoDB: Then delete the existing log files. Edit the .cnf file
InnoDB: and start the database again.
111016 16:01:49 [ERROR] Plugin 'InnoDB' init function returned error.
111016 16:01:49 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
111016 16:01:49 [ERROR] Unknown/unsupported storage engine: InnoDB
111016 16:01:49 [ERROR] Aborting
启动Ok如下:
111016 16:05:13 mysqld_safe Starting mysqld daemon with databases from /data0/data
InnoDB: Mutexes and rw_locks use InnoDB's own implementation
InnoDB: Compressed tables use zlib 1.2.3
111016 16:05:13 InnoDB: Initializing buffer pool, size = 16.0M
111016 16:05:13 InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file /data0/data/ibdata1 did not exist:
InnoDB: a new database to be created!
111016 16:05:13 InnoDB: Setting file /data0/data/ibdata1 size to 128 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Progress in MB: 100
111016 16:05:22 InnoDB: Log file /data0/data/ib_logfile0 did not exist: new to be created
InnoDB: Setting log file /data0/data/ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
111016 16:05:23 InnoDB: Log file /data0/data/ib_logfile1 did not exist: new to be created
InnoDB: Setting log file /data0/data/ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: 127 rollback segment(s) active.
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
111016 16:05:24 InnoDB: 1.1.4 started; log sequence number 0
111016 16:05:24 [Note] Event Scheduler: Loaded 0 events
111016 16:05:24 [Note] /usr/local/webserver/mysql/bin/mysqld: ready for connections.
Version: '5.5.8-log' socket: '/data0/data/mysql.sock' port: 3306 Source distribution
注意,Nginx下的file_get_contents会出现100%的Cpu情况,原因是:
开启<value name="request_slowlog_timeout">3s</value>记录慢执行日志,会在日志中打印出执行慢的代码行数。php-cgi(php-fpm) 使用了Libevent,而Libevent 在 Linux 2.6 内核以上默认会使用 epoll I/O 模型处理 FastCGI 网络请求,而非 select/poll。在慢日志记录的代码行数中,包含 file_get_contents 以及其他函数,而 file_get_contents 等作为 Client 发起 HTTP 请求的函数使用的是 select/poll 模型,也就是说,只有 file_get_contents 等满足“TCP请求默认不超时、使用select/poll 模型、进程CPU 100%”的网络操作函数,会导致 strace -p 看到的这种情况。
最好还是用Curl吧,这个靠谱些。
后补上,如何在PHP里安装GD2,方法如下:
如果源码安装需要找齐下面的源码包,在安GD2时需要指定其安装的位置:
./configure --prefix=/usr/local/modules/gd --with-jpeg=/usr/local/modules/jpeg6 --with-png --with-zlib --with-freetype=/usr/local/modules/freetype
如果安装gd版本低,会报configure: error: Unable to find libgd.(a|so) >= 2.1.0 anywhere under /usr/local/gd
GD库重装成功 尝试重装PHP 依然报错 查找到libgd.*位置 复制到/usr/local/gd/ 依然找不到。 找到原因,GD库版本过低,低于2.1.0 下载最新版本
替换高版本gd解决,也可能是这样解决:
configure: error: Unable to find libgd.(a|so) >= 2.1.0 anywhere under /usr/local/libgd
如果提示libgd版本错误,把php编译参数--with-gd=/usr/local/libgd修改为--with-gd即可 ,Dockerfile 是这样的:--with-gd=/usr \ ,指向/usr。
修改成下面这个路径试试:
--with-gd=/usr/local/gd \
而要是自带的这个rpm,用linux的yum安好即可,特别要注意要用到的devel这样的包,这个是有一个头文件在里面的,
rpm -ql zlib-devel-1.2.3-27.el6.i686
/usr/include/zconf.h
/usr/include/zlib.h
/usr/lib/libz.so
如下,查看是否所有的包都安好了:
root@192.168.225.128:~# rpm -qa|grep zlib
zlib-devel-1.2.3-27.el6.i686
zlib-1.2.3-27.el6.i686
root@192.168.225.128:~# rpm -qa|grep libpng
libpng-devel-1.2.46-1.el6_1.i686
libpng-1.2.46-1.el6_1.i686
root@192.168.225.128:~# rpm -qa|grep freetype
freetype-2.3.11-6.el6_1.8.i686
freetype-devel-2.3.11-6.el6_1.8.i686
root@192.168.225.128:~# rpm -qa|grep libxml
libxml2-2.7.6-4.el6_2.1.i686
libxml2-devel-2.7.6-4.el6_2.1.i686
root@192.168.225.128:~# rpm -qa|grep gd
gdbm-1.8.0-36.el6.i686
root@192.168.225.128:~# rpm -qa|grep jpeg
libjpeg-6b-46.el6.i686
libjpeg-devel-6b-46.el6.i686
于是直接这样来安这个GD2即可:
./configure --prefix=/usr/local/gd
** Configuration summary for gd 2.0.34:
Support for PNG library: yes
Support for JPEG library: yes
Support for Freetype 2.x library: yes
Support for Fontconfig library: no
Support for Xpm library: no
Support for pthreads: yes
make;make install
PHP:
--with-gd=/usr/local/gd
安装配置方法:
/configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local/libiconv --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 --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd=/usr/local/gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --enable-soap=shared --enable-pdo enable-dom --enable-xmlwriter --with-pcre-regex --with-pear --enable-session --enable-spl --enable-hash --enable-reflection
重新指定so的位置:
打开/etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/gd/lib
ldconfig
再make;make install ,以上安装出现PHP还是跑到php5.3.10/ext/gd 并报错了。考。。。。
再试着用源码来安装(记录一下,安装是可以,但在最后时发现php还是去读取了PHP自己的目录下的ext/gd),后面只有先暂时不安,在最后再来安装这个gd2:
FreeType安装
FreeType库是一个完全免费(开源)的、高质量的且可移植的字体引擎,它提供统一的接口来访问多种字体格式文件,包括TrueType, OpenType, Type1, CID, CFF, Windows FON/FNT, X11 PCF等。支持单色位图、反走样位图的渲染。FreeType库是高度模块化的程序库,虽然它是使用ANSI C开发,但是采用面向对象的思想,因此,FreeType的用户可以灵活地对它进行裁剪。
[root@yznvm1 yzn]# wget http://nchc.dl.sourceforge.net/project/freetype/freetype2/2.4.8/freetype-2.4.8.tar.gz
[root@yznvm1 yzn]# tar xzvf freetype-2.4.8.tar.gz
[root@yznvm1 yzn]# cd freetype-2.4.8
[root@yznvm1 yzn]# ./configure --prefix=/usr/local/freetype
[root@yznvm1 freetype-2.4.8]# make && make install
[root@yznvm1 yzn]# wget http://www.ijg.org/files/jpegsrc.v8c.tar.gz
[root@yznvm1 yzn]# tar zxvf jpegsrc.v8c.tar.gz
[root@yznvm1 yzn]# cd jpeg-8c/
[root@yznvm1 jpeg-8c]# ./configure --prefix=/usr/local/jpeg
[root@yznvm1 jpeg-8c]# make && make install && cd ..
libpng
可查看http://www.libpng.org/pub/png/libpng.html
查看zlib版本
[root@yznvm1 yzn]# rpm -qa zlib
zlib-1.2.3-3
zlib-1.2.3-3
出于性能和安全考虑,zlib最好是1.2.5以上版本
[root@yznvm1 yzn]# wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.5.7.tar.gz
[root@yznvm1 yzn]# tar zxvf libpng-1.5.7.tar.gz
[root@yznvm1 yzn]# cd libpng-1.5.7
[root@yznvm1 libpng-1.5.7]# ./configure --prefix=/usr/local/libpng
[root@yznvm1 libpng-1.5.7]# make && make install
[root@yznvm1 libpng-1.5.7]# cd ..
libgd
http://www.libgd.org/ 这个网站down
[root@yznvm1 gd-2.0.33]# http://www.boutell.com/gd/http/gd-2.0.33.tar.gz
[root@yznvm1 gd-2.0.33]# tar xzvf gd-2.0.33.tar.gz
[root@yznvm1 gd-2.0.33]# cd gd-2.0.33
[root@yznvm1 gd-2.0.33]# ln -s /usr/local/libpng/include/pngconf.h /usr/include
[root@yznvm1 gd-2.0.33]# ln -s /usr/local/libpng/include/png.h /usr/include
[root@yznvm1 gd-2.0.33]# ./configure --prefix=/usr/local/gd2 --with-freetype=/usr/local/freetype --with-png=/usr/local/libpng --with-jpeg=/usr/local/jpeg
[root@yznvm1 gd-2.0.33]# make
[root@yznvm1 gd-2.0.33]# make install
下面是全的安装配置configure文件,但实践中要注意下面四点:
1)This is the test message -- configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
Fix: yum install net-snmp-devel
2)
configure: WARNING: You will need re2c 0.13.4 or later 解决办法
我在为php安装imagick-2.3.0模块的时候出现来错误
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
说需要安装re2c
执行以下命令
wget http://sourceforge.net/projects/re2c/files/re2c/0.13.5/re2c-0.13.5.tar.gz/download
tar -zxvf re2c-0.13.5.tar.gz
cd re2c-0.13.5
./configure && make && make install
3)configure: warning: bison versions supported for regeneration of the Zend/PHP parsers: 1.28 1.35 1.75 1.875 2.0 2.1 2.2 2.3 2.4 2.4.1 (found: none).
yum install bison
4)checking for lemon... no
configure: warning: lemon versions supported for regeneration of libsqlite parsers: 1.0 (found: none).
解决方法:
wget http://www.sqlite.org/cvstrac/getfile/sqlite/tool/lemon.c [下载不了]
这儿下:
http://code.google.com/p/lemonbind/source/browse/tools/lemon.c
gcc -o lemon lemon.c
mv lemon /usr/local/bin
重新运行 ./configure 后,问题解决。
最后正确的安装php5.3.10的配置configure方法,汇总,配置完所有的扩展要要用的配置参数了:
接着用如下make,不加参数会报错找不到ld什么的:
make ZEND_EXTRA_LIBS='-liconv'
更多的事件驱动扩展,PHP5.3 下安装ZendGuardLoader及eaccelerator 加速器:
http://www.jackxiang.com/post/5626/
PHP高一点的版本如:php-5.3.26,那些没有用的参数就不用了,于是得出下面的编译列表:
如果想兼容Nginx和Apache2时,还应加上--with-apxs2,但只能编译成一种,不能同时编译既支持fastCGI,又支持Apache的传统方式:
关于php编译时SAPI错误 :
近日在Centos6.3上编译php的时候出现了错误:You've configured multiple SAPIs to be build. You can build only |
| one SAPI module and CLI binary at the same time.
翻译:
You've configured multiple SAPIs to be build.You can build only one SAPI module and CLI binary at the same time.(你已经配置了多个SAPIs,你只可以建立一个SAPI模块和一个CLI binary。)
导致的原因是我的配置参数中同时使用了--enable-fpm 与--with-apxs2= ,因此编译的时候出错了,去掉其中的任意一个参数编译成功。
checking for Apache 1.x module support via DSO through APXS... configure: error: You have enabled Apache 1.3 support while your server is Apache 2. Please use the appropiate switch --with-apxs2
把下面的语句 --enable-fpm 去掉:就可以编译成功Apache下的PHP了。
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --enable-soap=shared --enable-pdo --enable-dom --enable-xmlwriter --with-pcre-regex --with-pear --enable-session --enable-hash --with-pdo-mysql=/usr/local/webserver/mysql --with-apxs2=/usr/local/webserver/apache2/bin/apxs
make ZEND_EXTRA_LIBS='-liconv'
会提示:如果要用Apache的线程安全模式,需要加上配置参数为: --enable-maintainer-zts
参考:http://jackxiang.com/post/5868/
You have built PHP for Apache's current non-threaded MPM.
If you change Apache to use a threaded MPM you must reconfigure
PHP with --enable-maintainer-zts
出现配置时的输出错误:
configure :error:unable to find your mysql installation
在--with-pdo-mysql后加上路径 ---with-pdo-mysql=/usr/local/webserver/mysql
终于再次编译成功!!
Apache相关的编译成功参数情况如下:
make install ...安装时会在Apache2下安装libphp5.so等文件:
在编译Apache下的PHP时出现一个can't find -lltdl的问题解决方法:
/usr/bin/ld: cannot find 错误解决方法
通常在软件编译时出现的usr/bin/ld: cannot find -lxxx的错误,主要的原因是库文件并没有导入的ld检索目录中。
解决方式:
1。确认库文件是否存在,比如-l123, 在/usr/lib, /usr/local/lib,或者其他自定义的lib下有无lib123.so, 如果只是存在lib123.so.1,
那么可以通过ln -sv lib123.so.1 lib123.so,建立一个连接重建lib123.so.
2。检查/etc/ld.so.conf中的库文件路径是否正确,如果库文件不是使用系统路径,/usr/lib, /usr/local/lib, 那么必须在文件中加入。
3。ldconfig 重建ld.so.cache文件,ld的库文件检索目录存放文件。尤其刚刚编译安装的软件,必须运行ldconfig,才能将新安装的
库文件导入ld.so.cache.
4。测试,gcc -l123 --verbose.
参考:http://blog.siyebocai.cn/20100324_5p424qs7.html
实践操作:
/usr/lib/libltdl.so /usr/bin/ld: cannot find -lltdl collect2: ld returned 1 exit status make: *** [libphp5.la] 错误 1
找找下面这些位置是否有这样的包?
erro: Installed (but unpackaged) file(s) found:
/usr/lib64/libltdl.a
/usr/lib64/libltdl.la
/usr/lib64/libltdl.so.3.1.0
Installed (but unpackaged) file(s) found:
/usr/lib64/libltdl.a
/usr/lib64/libltdl.la
/usr/lib64/libltdl.so.3.1.0
如果找不到,解决的方法基本很容易.
#yum install libtool-ltdl-devel
如果找到,我的情况:
root@192.168.244.128:/# cd /;find . -name "*libltdl.so*"
./usr/lib/libltdl.so.7.2.1
./usr/lib/libltdl.so.7
按上面的介绍来作出添加操作:
1)检查/etc/ld.so.conf中的库文件路径是否正确,如果库文件不是使用系统路径,/usr/lib, /usr/local/lib, 那么必须在文件中加入。
2)ldconfig 重建ld.so.cache文件,ld的库文件检索目录存放文件。尤其刚刚编译安装的软件,必须运行ldconfig,才能将新安装的
库文件导入ld.so.cache.
如下操作:
vi /etc/ld.so.conf 添加一行:
/usr/lib/
执行: ldconfig
再次编译PHP即可!!!
------------------------------------------------------------------------------------------------------------------------------------------------------------------
还是不行啊?呵呵,那明明整上去了还不行再这样试试:
第一步很容做到:yum -y install libtool libtool-ltdl; //这一步实在是没有那个库再说吧,略。直接第二步。
root@192.168.244.128:/# ldconfig -p |grep ltdl
libltdl.so.7 (libc6) => /usr/lib/libltdl.so.7
第二步由于PHP的configure指定的libltdl名为libltdl.so,为此我们只需添加一个名称连接:ln -s /usr/lib64/libltdl.so.3.1.4 /usr/lib64/libltdl.so ,如果不是64位则:
,其原始文件是:/usr/lib/libltdl.so.7.2.1 ,一个个都是软链接。
http://blog.chinaunix.net/uid-20774942-id-3001010.html
------------------------------------------------------------------------------------------------------------------------------------------------------------------
安装php并且打补丁(由于gd与iconv冲突,暂不编译gd库),于是在后来追加编译gd库
进入目录php-5.2.10/ext/gd执行命令
/usr/local/php/lib/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/libpng --with-zlib-dir=/usr/local/zlib/ --with-freetype-dir=/usr/local/freetype
make;make install
,最后,发现这个新生成的gd.so,和前面默认安的这个gd是一样的东东,现在还是不太明白他们所说的gd2和gd有什么大的区别,哈哈,上面这种方法提供了一条安gd.so的方法,也还是不小的收获。同时,以前这个PDO都是编译为so,而上面这个编译是直接编译进php的源码时就编译了,也是不错的收获。
这次主要是把PHP模块Mysql的的PDO直接安装在了编译时,而不需要extension(;extension = "pdo_mysql.so"):
root@192.168.225.128:~/software/php-5.3.10# php -m|grep pdo
PHP Warning: Module 'pdo_mysql' already loaded in Unknown on line 0
pdo_mysql
pdo_sqlite
==============后期的方便操作的设置===================
方便管理,显示IP等,如:jackxiang@72.46.128.82:~#
vi ~/.bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ll='ls -l'
alias la='ls -A'
alias vi='vim'
alias v='vim'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
ipL=`/sbin/ifconfig eth0|grep "inet addr:"|cut -d: -f 2|cut -d" " -f1`
export PS1="\u@$ipL:\w# "
alias cdh="cd /usr/local/tads/htdocs/"
alias cnginx="cd /usr/local/webserver/nginx/"
alias chtdocs="cd /data0/htdocs/"
alias cphpuml="cd /root/software/PHP_UML-1.5.5/PHP/scripts"
一些目录的快捷键:
vi ~+/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/webserver/php/bin:/usr/local/webserver/mysql/bin:/usr/local/webserver/memcached/bin:/usr/local/webserver/nginx/sbin:./usr/local/webserver/subversion/bin:/usr/local/webserver/python/bin:/home/webdev/bin;
export PATH
unset USERNAME
alias chtdocs='cd /data0/htdocs'
alias cphp='cd /usr/local/webserver/php'
alias cmysql='cd /usr/local/webserver/mysql'
alias capache='cd /usr/local/webserver/apache'
alias cblog='cd /data0/htdocs/blog'
alias h='history'
Vim的一些设置等:
vi ~+/.vimrc
syntax on
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
set nu
if &term=="xterm"
set t_Co=8
set t_Sb=^[[4%dm
set t_Sf=^[[3%dm
endif
behave mswin
colo murphy
set fileencodings=utf-8,gb2312,gbk,gb18030
set termencoding=utf-8
set fileformats=unix
set fileencoding=utf-8
au FileType php call AddPHPFuncList()
function AddPHPFuncList()
set dictionary-=/root/.vim/ExtraVim/php_funclist.txt dictionary+=/root/.vim/ExtraVim/php_funclist.txt
set complete-=k complete+=k
endfunction
map <F10> : NERDTreeToggle<CR>
map <F12> ::TlistToggle<CR>
let NERDTreeWinPos = "right" "where NERD tree window is placed on the screen
let Tlist_Enable_Fold_Column = 0
let Tlist_Exit_OnlyWindow = 0
let Tlist_File_Fold_Auto_Close = 0
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_Hightlight_Tag_On_BufEnter = 1
let Tlist_Inc_Winwidth = 0
let Tlist_Max_Submenu_Items = 1
let Tlist_Max_Tag_Length = 30
let Tlist_Process_File_Always = 0
let Tlist_Show_Menu = 0
let Tlist_Show_One_File = 0
let Tlist_Sort_Type = "order"
let Tlist_Use_Horiz_Window = 0
let Tlist_Use_Right_Window = 1
let Tlist_WinWidth = 40
let tlist_php_settings = 'php;c:class;i:interfaces;d:constant;f:function'
eaccelerator的小生产配置备案:
[Zend]
zend_optimizer.optimization_level=15
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/data/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.log_file = "/var/log/httpd/eaccelerator_log"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
YAML扩展:http://jackxiang.com/post/4431/
Xdebug:http://jackxiang.com/post/4675/
更加清晰的参考:
http://www.osyunwei.com/archives/4924.html
http://www.ypgogo.com/world/pearl/id/13000
_____________________PHP5.4以上非fastCGI和apche结合支持上传进度的实践之重新配置Apache____________________________
目的:想实现PHP5.4的进度progress的上传,搞了个nginx的,后来一老外说这Nginx玩意在获取进度时获取不到,还得用传统的Apache那一套。Add Time:14/3/27 星期四
一)给Apache2重新编译下PHP:(像什么GD库,Mysql先省了)
./configure --prefix=/usr/local/webserver/php5.4ForApache -with-apxs2=/usr/local/webserver/apache2/bin/apxs --with-curl --with-mcrypt --enable-mbstring --enable-pdo --with-iconv-dir=/usr/local/libiconv
二)make ZEND_EXTRA_LIBS='-liconv' && make install
libtool: install: install .libs/libphp5.so /usr/local/webserver/apache2/modules/libphp5.so
libtool: install: install .libs/libphp5.lai /usr/local/webserver/apache2/modules/libphp5.la
三)再次检查下httpd.conf的配置情况:
<IfModule mime_module>
TypesConfig conf/mime.types
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
启动Apache,开始测试。
root@192.168.0.6:/usr/local/webserver/apache2/bin# ./httpd -k start
httpd: Syntax error on line 388 of /usr/local/webserver/apache2/conf/httpd.conf: Cannot load modules/libphp5.so into server: /usr/local/webserver/apache2/modules/libphp5.so: undefined symbol: zend_parse_parameters
解决办法:
在新的服务器(centos 6.3)编译安装完php-5.4.8,再配置好php.ini和httpd.conf后,启动apache-2.4.3的时候,命令执行/usr/local/apache2/bin/apachectl start时,提示:
httpd: Syntax error on line 146 of /etc/httpd/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: undefined symbol: zend_parse_parameters
通过搜索发现,说是缺少bison。
如果通过rpm -qa|grep bison发现没有安装bison,安装bison即可。centos可以用yum install bison
rpm -qa|grep bison 是:bison-2.4.1-5.el6.i686,但是我发现已经安装了bison-2.4.1,rpm -e bison-2.4.1-5.el6.i686。最后实在是没办法了,下载了bison-2.5的rpm包直接安装。
[root@localhost ~]# wget http://ftp.gnu.org/gnu/bison/bison-2.5.tar.gz
[root@localhost ~]# tar -zxvf bison-2.5.tar.gz
[root@localhost ~]# cd bison-2.5
[root@localhost ~]# ./configure
[root@localhost ~]# make && make install
再重新编译安装了PHP[实践发现在重新编译PHP时要注意:make clean再编译,后才能启动Apache2并支持PHP5.4.26]。然后/usr/local/apache2/webserver/bin/apachectl start启动Apache。惊奇的发现可以正常启动了,测试了下PHP网页,可以正常访问。
来自:http://www.myxzy.com/post-272.html
1)配置好后,测试上传进度占比的PHP自己带的进度实践来源:
(1)http://www.pureweber.com/article/php-upload-progress/
(2)https://github.com/pureweber/samples/blob/master/php-upload-progress/upload.php
2)配置好后,测试上传进度占比的Flash实践来源:http://jackxiang.com/post/6939/
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/4155/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: jackxiang 编辑于2019-5-8 17:57
评论列表