标签:
# useradd www -M -s /sbin/nologin(www可以用nginx,说明是nginx用户)
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.13.zip # unzip pcre-8.13.zip # cd pcre-8.13 # ./configure # make && make install
(如果有错误提示:
请按照下面的安装方法:安装pcre-devel与openssl-devel解决问题
yum -y install pcre-devel openssl openssl-devel)
MGB,安装出现一个问题 make: *** No rule to make targetbuild‘, needed bydefault‘. Stop.,莫名的奇妙;
安装make:
yum -y install gcc automake autoconf libtool make
安装g++:
yum install gcc gcc-c++ yum -y install openssl openssl-devel
# tar -zxvf nginx-1.3.9.tar.gz # cd nginx-1.3.9 # ./configure --prefix=/opt/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.34 # make && make install --with-pcre 后面的路径 为源码包解压后的路径,而不是安装路径,否则会报错!
# yum -y install libjpeg-devel libpng-devel # wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.8.tar.gz(下载,这个路径不一定正确,可以通过其他方法下载) # tar -zxvf libmcrypt-2.5.8.tar.gz # cd libmcrypt-2.5.8 # ./configure # make && make install
==64位系统==
ln -s /usr/lib64/mysql/ /usr/lib/mysql
==64位系统==
# cd php-5.4.9 # ./configure --prefix=/opt/php --with-iconv --with-zlib --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 =‘对于libmcrypt的安装目录‘ --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-mysql --with-mysqli --enable-sqlite-utf8 --with-pdo-mysql --enable-ftp --with-jpeg-dir --with-freetype-dir --with-png-dir --enable-fpm --with-fpm-user=www --with-fpm-group=www # make && make install
相关错误解决:
configure: error: Please reinstall the libcurl distribution - easy.h should be in /include/curl/
其实就是curl的dev包没有安装, 解决方案: 终端下
# yum -y install curl-devel
然后就可以继续了
在CentOS编译PHP5的时候有时会遇到以下的一些错误信息,基本上都可以通过yum安装相应的库来解决。以下是具体的一些解决办法:
Fix: yum install bzip2-devel
Fix: yum install curl-devel
Fix: yum install db4-devel
Fix: yum install libjpeg-devel
Fix: yum install libpng-devel
Fix: Reconfigure your PHP with the following option. --with-xpm-dir=/usr
Fix: yum install libXpm-devel
Fix: yum install gmp-devel
Fix: yum install libc-client-devel
Fix: yum install openldap-devel
Fix:
yum install unixODBC-devel
Fix: yum install postgresql-devel
Fix: yum install sqlite-devel
Fix: yum install aspell-devel
Fix: yum install net-snmp-devel
Fix: yum install libxslt-devel
Fix: yum install libxml2-devel
Fix: yum install pcre-devel
Fix: yum install mysql-devel
Fix: yum install unixODBC-devel
Fix:
yum install postgresql-devel
Fix: yum install pspell-devel
Fix: yum install net-snmp-devel
Fix: yum install libxslt-devel
# cp php.ini-production /opt/php/lib/php.ini 或是/usr/local/lib/php.ini # cp /opt/php/etc/php-fpm.conf.default /opt/php/etc/php-fpm.conf # /opt/php/bin/php --ini //测试ini文件是否加载
修改php.ini
[PHP] safe_mode = On register_globals = Off magic_quotes_gpc = Off allow_url_fopen = Off allow_url_include = Off expose_php=Off disable_functions = shell_exec,system,exec,passthru,show_source,curl_exec,curl_multi_exec,get_cfg_var [Date] date.timezone = “Asia/Shanghai”
修改php-fpm.conf
[global] pid = run/php-fpm.pid error_log = log/php-fpm.log log_level = notice emergency_restart_threshold = 0 emergency_restart_interval = 0 [www] pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35(不能大于max_children) pm.max_requests = 500
# cp nginx /etc/init.d/nginx # cp php-fpm /etc/init.d/php-fpm # chmod 755 /etc/init.d/nginx # chmod 755 /etc/init.d/php-fpm # chkconfig --add nginx # chkconfig --add php-fpm # chkconfig nginx on # chkconfig php-fpm on
mkdir -p /opt/mysql/
mkdir -p /data/mysql/
# useradd mysql -M -s /sbin/nologin # chown mysql.mysql -R /data/mysql/
# yum -y install cmake # yum -y install ncurses-devel
tar -zxvf mysql-5.5.28.tar.gz cd mysql-5.5.28 cmake . -DCMAKE_INSTALL_PREFIX=/opt/mysql -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 # make && make install
安装完mysql服务器运行正常,但无法使用gbk字符集,系统装了中文支持,mysql重装了几次都不行.
show character set里没有gbk;
set names gbk 就提示错误 #1115 - Unknown character set: ‘gbk‘
解决方案:
上面的编译参数-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk这个参数引起的问题方法一、去掉这个参数,默认值是支持all的charset 方法二、直接改为-DWITH_EXTRA_CHARSETS=all加入-DDEFAULT_COLLATION=utf8_general_ci选项后,启动mysql可能会有问题,须在my.cnf 文件 [mysqld]加入character_set_server=utf8
# cd /opt/mysql # scripts/mysql_install_db --user=mysql --basedir=/opt/mysql --datadir=/data/mysql/
# cp support-files/my-medium.cnf /etc/my.cnf(这里的my.cnf参考服务器的内存大小 一般my-medium.cnf是256M,my-large.cnf是512M) # cp support-files/mysql.server /etc/init.d/mysql # chmod 755 /etc/init.d/mysql # chkconfig mysql on # export PATH=/opt/mysql/bin:$PATH //设置环境变量
# /etc/init.d/mysql start # mysqladmin -uroot password ‘123123‘
进行再修改密码的语句
1: UPDATE mysql.user SET Password = PASSWORD(‘newpwd’) WHERE User = ‘root’;(生新设置密码) 2: flush privileges;(刷新权限)
注:mysql日志文件保存在/data/mysql/下面,对应数据文件保存的路径(比如.err)。
http://memcached.googlecode.com/files/memcached-1.4.13.tar.gz https://github.com/downloads/libevent/libevent/libevent-2.0.18-stable.tar.gz
tar -zxvf libevent-2.0.18-stable.tar.gz cd libevent-2.0.18-stable ./configure --prefix=/usr/local/libevent make && make install cd ../
tar -zxvf memcached-1.4.13.tar.gz cd memcached-1.4.13 ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent/ make && make install cd ..
(1).在http://pecl.php.net/package/memcache 选择相应想要下载的memcache版本。 (2).安装PHP的memcache扩展
tar vxzf memcache-2.2.6.tar.gz cd memcache-2.2.6 /usr/local/php/bin/phpize ./configure –enable-memcache –with-php-config=/usr/local/php/bin/php-config –with-zlib-dir make make install
(3).上述安装完后会有类似这样的提示:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
(4).把php.ini中的extension_dir = “./”修改为
extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/”
(5).添加一行来载入memcache扩展:extension=memcache.so
/usr/local/memcached/bin/memcached -d -l 192.168.1.2 -u www -m 512 -c 10240 -p 12000 -P /tmp/memcached.pid
将以上加入到/etc/rc.local方便下次自动启动 *注:用户-u必须指定,在此处示例所用的是WEB用户www
telnet 192.168.1.2 12000 stats #查看运行状态 quit #退出
php5.4.9启动命令:/opt/php/sbin/php-fpm 检测php运行进程 ps aux|grep php-fpm php-fpm 关闭: kill -INT `cat /usr/local/php/var/run/php-fpm.pid` 关闭后,需要 /opt/php/sbin/php-fpm启动;没有php-fpm.pid就用touch创建。 php-fpm 重启: kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid` Nginx 服务启动命令:/opt/nginx/sbin/nginx 语法检测 /opt/nginx/sbin/nginx -t 检测nginx.conf文件语法;
php启动报错:
ERROR: [pool www] cannot get uid for user ‘fpm‘
需要在php-fpm上改动user=fpm group=fpm fpm改成nginx;(安装nginx的用户)
centos+nginx1.3.9+php5.4.9+mysql5.5.28+memcached
标签:
原文地址:http://my.oschina.net/lzh1104/blog/384547