[笔记]php配置服务器编译php5
编译 php 5wget http://cn2.php.net/get/php-5.3.5.tar.gz/from/this/mirror
tar zxvf php-5.3.5.tar.gz
cd php-5.3.5/ 5.3
./configure --prefix=/web/server/php --enable-fpm--with-config-file-path=/web/server/php/etc--with-mysql=/web/server/mysql --disable-rpath --enable-safe-mode--enable-bcmath --enable-shmop --enable-sysvsem--enable-inline-optimization --enable-mbregex --enable-mbstring--with-mcrypt --with-mhash --enable-pcntl --enable-sockets--with-pdo-mysql=/web/server/mysql 5.2
./configure --prefix=/web/server/php --enable-fpm--with-config-file-path=/web/server/php/etc --enable-soap--enable-dba --with-curl --with-curlwrappers --with-freetype-dir--with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr--disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop--enable-sysvsem --enable-inline-optimization --with-curl--with-curlwrappers --enable-mbregex --enable-mbstring--with-mcrypt --with-gd --enable-gd-native-ttf --with-mhash--enable-pcntl --enable-sockets --with-xmlrpc --enable-zip--enable-sqlite-utf8 --without-pear--with-pdo-mysql=/web/server/mysql --with-iconv-dir=/usr/local/libmake ZEND_EXTRA_LIBS='-liconv'
make test
make install
cp php.ini-dist /usr/local/webserver/php/etc/php.ini
遇到错误:
第二方法,尹恩惠麻烦一些
http://rental.zhupiter.com/postshow_273_1_1.html
在安装 PHP 到系统中时要是发生「undefined reference to`libiconv_open'」之类的错误讯息,那表示在「./configure 」没抓好一些环境变数值。错误发生点在建立「-osapi/cli/php」时出错,没给到要 link 的 iconv 函式库参数。
快速的解法是:
编辑 Makefile 大约 70 行左右的地方:
EXTRA_LIBS = ..... -lcrypt
在最后加上 -liconv,例如:
EXTRA_LIBS = ..... -lcrypt -liconv
http://blog.s135.com/nginx_php_v6/
-----------------------------------------------------------------------------------------------------------------------------
编译 mariadb 5.2.6
./configure --prefix=/web/server/mysql--with-collation=utf8_general_ci --with-charset=utf8--with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static--with-unix-socket-path=/tmp/mysql.sock --enable-assembler--with-extra-charsets=all --with-plugin-innodb_plugin
make && make install
/web/bin/mysql.server start
GRANT ALL PRIVILEGES ON *.* TO 'speeddate'@"%" IDENTIFIED BY'speeddate@lol99.com';
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
./configure --prefix=/web/server/php --enable-fpm--with-config-file-path=/web/server/php/etc--with-mysql=/web/server/mysql --enable-soap --enable-dba--with-curl --with-curlwrappers --with-freetype-dir --with-jpeg-dir--with-png-dir --with-zlib --enable-ftp --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-mbstring--with-mcrypt --with-gd --enable-gd-native-ttf --with-mhash--enable-pcntl --enable-sockets --with-xmlrpc --enable-zip--enable-sqlite-utf8 --without-pear--with-pdo-mysql=/web/server/mysql
make
make insatll
cp support-files/my-medium.cnf /etc/my.cnf
chmod +w /web/server/mysql
chown -R mysql:mysql /web/server/mysql
cd /web/server/marinadb/
bin/mysql_install_db --user=mysql
bin/mysql_mysqld_safe --user=mysql &
拷贝:/web/server/mysql/share/mysql/mysql.server 文件 到mysql 根目录
vi mysql.server
设置:
basedir=/web/server/mariadb
datadir=/web/server/mariadb/var
chmod +x mysql.server
./mysql.server start
more /web/server/mysql/var/lzq-03.err
-----------------------------------------------------------------------------------------------------------------------------
编译 nginx 8
http://blog.s135.com/nginx_php_v6/
tar zxvf pcre-8.10.tar.gz
cd pcre-8.10/
./configure
make && make install
cd ../
/usr/sbin/groupadd www
/usr/sbin/useradd -g www www
mkdir -p /web/www
chmod +w /web/www
chown -R www:www /web/www
tar zxvf nginx-0.8.46.tar.gz
cd nginx-0.8.46/
./configure --user=www --group=www --prefix=/web/server/nginx--with-http_stub_status_module --with-http_ssl_module
make && make install
cd ../
-----------------------------------------------------------------------------------------------------------------------------
编译 memcache-php 扩展
tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5
/web/server/php/bin/phpize
./configure--with-php-config=/web/server/php/bin/php-config
make
make install
-----------------------------------------------------------------------------------------------------------------------------
编译安装 memcached
运行 memcached -d -m 10 -u root -l 127.0.0.1 -p 11121 -c 256 -P/tmp/memcached.pid
启动错误的解决
启动时候若发现报类似的错误错"/usr/local/bin/memcached: error while loadingshared libraries: libevent-1.3.so.1: cannot open shared objectfile: No such file ordirectory"因为我装的是64位服务器,加上以下一句解决
ln -s /usr/lib/libevent-1.3.so.1.0.3/usr/lib64/libevent-1.3.so.1
或者运行:ldconfig通常在系统启动时运行,而当用户安装了一个新的动态链接库时,就需要手工运行这个命令.
-----------------------------------------------------------------------------------------------------------------------------
编译 mongo
在两台机器上都安装MongoDB
我们直接用官方编译好的rpm包
先增加mongodb的rpm库:
vi /etc/yum.repos.d/10gen.repo
name=10gen Repository
baseurl=http://downloads.mongodb.org/distros/centos/5.4/os/x86_64/
gpgcheck=0
再yum安装:
yum -y install mongo-stable mongo-stable-server
2)配置Master:
vi /etc/mongod.conf
增加下面几行:
rest = true
master = true
启动:
service mongod start
3)配置Slave:
vi /etc/mongod.conf
增加下面几行:
rest = true
slave = true
source = 192.168.1.174
autoresync = true
启动:
service mongod start
4)查看和测试
查看相关的状态
db.printReplicationInfo()
查看是否为Master:
db.isMaster();
测试:
在Master上增加一个Collection
db.createCollection("mycoll2", {capped:true, size:100000})
然后再在Slave上查看
show collections
如果能看到刚刚新增的mycoll2,说明成功了http://zx.cnmeiye.com/。少女时代河智苑韩恩贞成勋整容林秀香整容
4)故障测试
A. Slave机器出了问题怎么办?
按照上面的3)中的步骤,金善雅重做一遍就是了。
B. Master机器出问题怎么办?
如果Master机器挂了,那么我们可以先把Slave改成Master让其提供服务:
在Slave上先停止mongod:
service mongod stop
再删除本地数据库,因为slave的相关信息存在这里面了。
cd /var/lib/mongo
rm -rf local.*
在配置文件内把slave改成master:
vi /etc/mongod.conf
删掉下面几行:
slave = true
source = 192.168.1.174
autoresync = true
增加:
master = true
最后再启动mongod:
service mongod start
nohup /usr/bin/mongod -f /etc/mongod.conf-&
mongodb修复
mongod --repair --dbpath /var/lib/mongo/ --repairpath/web/mongo_repair/
-----------------------------------------------------------------------------------------------------------------------------
编译 redis
redis-2.0.0-rc4.tar.gz
tar zxvf redis-2.0.0-rc4.tar.gz
cd redis-2.0.0-rc4
vi redis.conf
-- daemonize yes
/web/down/redis/redis-server /web/down/redis/redis.conf
-----------------------------------------------------------------------------------------------------------------------------
编译 redis-php 扩展
tar -xvf phpredis.tar
cd phpredis
/web/server/php/bin/phpize
./configure --prefix=/usr/local/
make
make install
-----------------------------------------------------------------------------------------------------------------------------
编译 mongo-php 扩展
wget http://pecl.php.net/get/mongo-1.1.4.tgz
tar xzvf mongo-1.1.4.tgz
cd mongo-1.1.4
/web/server/php/bin/phpize
./configure --enable-mongo--with-php-config=/web/server/php/bin/php-config
make
make install
ll /web/server/php/lib/php/extensions/no-debug-non-zts-20090626/
vi /web/server/php/etc/php.ini
/web/server/php/bin/php -m
killall -9 php-fpm
/web/server/php/sbin/php-fpm
-----------------------------------------------------------------------------------------------------------------------------
配置 php 模块
vi ~/.bash_profile
# .bash_profile # Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi # User specific environment and startup programsPATH=$PATH:$HOME/bin:/web/server/php/bin export PATH
PATH=$PATH:$HOME/bin:/web/server/php/bin
/web/server/php/bin/pecl install curl
文章来源: http://zx.cnmeiye.com/
页:
[1]