您好,欢迎访问一九零五行业门户网

centos+nginx1.3.9+php5.4.9+mysql5.5.28+memcached

一:安装nginx 1,添加一个不能登录且没有主目录的用户: # useradd www -m -s /sbin/nologin(www可以用nginx,说明是nginx用户)
2,必要的组件 # 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
(如果有错误提示:
./configure: error: the http rewrite module requires the pcre library. 请按照下面的安装方法:安装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
3,编译nginx并安装 # 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 后面的路径 为源码包解压后的路径,而不是安装路径,否则会报错!
[2].安装php 1,安装必要的组件 # 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位系统==
2,编译php并安装 # 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
相关错误解决:
checking for curl in default path... not found configure: error: please reinstall the libcurl distribution - easy.h should be in /include/curl/
其实就是curl的dev包没有安装, 解决方案: 终端下
# yum -y install curl-devel
然后就可以继续了
在centos编译php5的时候有时会遇到以下的一些错误信息,基本上都可以通过yum安装相应的库来解决。以下是具体的一些解决办法:
checking for bzip2 support… yes checking for bzip2 in default path… not found configure: error: please reinstall the bzip2 distribution fix: yum install bzip2-devel
checking for curl support… yes checking if we should use curl for url streams… no checking for curl in default path… not found configure: error: please reinstall the libcurl distribution ? easy.h should be in/include/curl/ fix: yum install curl-devel
checking for curl_multi_strerror in -lcurl… yes checking for qdbm support… no checking for gdbm support… no checking for ndbm support… no configure: error: dba: could not find necessary header file(s). fix: yum install db4-devel
checking for fabsf… yes checking for floorf… yes configure: error: jpeglib.h not found. fix: yum install libjpeg-devel
checking for fabsf… yes checking for floorf… yes checking for jpeg_read_header in -ljpeg… yes configure: error: png.h not found. fix: yum install libpng-devel
checking for png_write_image in -lpng… yes if configure fails try ?with-xpm-dir= configure: error: freetype.h not found. fix: reconfigure your php with the following option. --with-xpm-dir=/usr
checking for png_write_image in -lpng… yes configure: error: libxpm.(a|so) not found. fix: yum install libxpm-devel
checking for bind_textdomain_codeset in -lc… yes checking for gnu mp support… yes configure: error: unable to locate gmp.h fix: yum install gmp-devel
checking for utf8_mime2text signature… new checking for u8t_decompose… configure: error: utf8_mime2text() has new signature, but u8t_canonical is missing. this should not happen. check config.log for additional information. fix: yum install libc-client-devel
checking for ldap support… yes, shared checking for ldap cyrus sasl support… yes configure: error: cannot find ldap.h fix: yum install openldap-devel
checking for mysql_set_character_set in -lmysqlclient… yes checking for mysql_stmt_next_result in -lmysqlclient… no checking for oracle database oci8 support… no checking for unixodbc support… configure: error: odbc header file ‘/usr/include/sqlext.h’ not found! fix:
yum install unixodbc-devel
checking for postgresql support for pdo… yes, shared checking for pg_config… not found configure: error: cannot find libpq-fe.h. please specify correct postgresql installation path fix: yum install postgresql-devel
checking for sqlite 3 support for pdo… yes, shared checking for pdo includes… (cached) /usr/local/src/php-5.3.7/ext checking for sqlite3 files in default path… not found configure: error: please reinstall the sqlite3 distribution fix: yum install sqlite-devel
checking for utsname.domainname… yes checking for pspell support… yes configure: error: cannot find pspell fix: yum install aspell-devel
checking whether to enable ucd snmp hack… yes checking for default_store.h… no checking for kstat_read in -lkstat… no checking for snmp_parse_oid in -lsnmp… no checking for init_snmp in -lsnmp… no configure: error: snmp sanity check failed. please check config.log for more information. fix: yum install net-snmp-devel
checking whether to enable xmlwriter support… yes, shared checking for xml2-config path… (cached) /usr/bin/xml2-config checking whether libxml build works… (cached) yes checking for xsl support… yes, shared configure: error: xslt-config not found. please reinstall the libxslt >= 1.1.0 distribution fix: yum install libxslt-devel
configure: error: xml2-config not found. please check your libxml2 installation. fix: yum install libxml2-devel
checking for pcre headers location… configure: error: could not find pcre.h in /usr fix: yum install pcre-devel
configure: error: cannot find mysql header files under yes. note that the mysql client library is not bundled anymore! fix: yum install mysql-devel
checking for unixodbc support… configure: error: odbc header file ‘/usr/include/sqlext.h’ not found! fix: yum install unixodbc-devel
checking for pg_config… not found configure: error: cannot find libpq-fe.h. please specify correct postgresql installation path fix:
yum install postgresql-devel
configure: error: cannot find pspell fix: yum install pspell-devel
configure: error: could not find net-snmp-config binary. please check your net-snmp installation. fix: yum install net-snmp-devel
configure: error: xslt-config not found. please reinstall the libxslt >= 1.1.0 distribution fix: yum install libxslt-devel
3,拷贝和修改php配置文件 # 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 = onregister_globals = offmagic_quotes_gpc = offallow_url_fopen = offallow_url_include = offexpose_php=offdisable_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.piderror_log = log/php-fpm.loglog_level = noticeemergency_restart_threshold = 0emergency_restart_interval = 0[www]pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35(不能大于max_children)pm.max_requests = 500
4,添加服务启动脚本 # 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
三:安装mysql 3.1, 创建mysql安装目录 mkdir -p /opt/mysql/
3.2, 创建数据存放目录 mkdir -p /data/mysql/
3.3, 创建用户和用户组与赋予数据存放目录权限 # useradd mysql -m -s /sbin/nologin# chown mysql.mysql -r /data/mysql/
3.4, 安装必要的组件 # yum -y install cmake# yum -y install ncurses-devel
3.5, 编译安装mysql tar -zxvf mysql-5.5.28.tar.gz cd mysql-5.5.28cmake . -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
3.6, 初始化数据库 # cd /opt/mysql# scripts/mysql_install_db --user=mysql --basedir=/opt/mysql --datadir=/data/mysql/
3.7, 配置环境 # 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 //设置环境变量
3.8, 启动并设置初始密码 # /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)。
四:安装memcached 1.下载libevent和memcached http://memcached.googlecode.com/files/memcached-1.4.13.tar.gzhttps://github.com/downloads/libevent/libevent/libevent-2.0.18-stable.tar.gz
2.安装libevent tar -zxvf libevent-2.0.18-stable.tar.gzcd libevent-2.0.18-stable./configure --prefix=/usr/local/libeventmake && make installcd ../
3.安装memcached tar -zxvf memcached-1.4.13.tar.gzcd memcached-1.4.13./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent/make && make installcd ..
4:安装memcache的php扩展 (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
5.启动并加入启动项 /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
6.使用telnet查看状态 telnet 192.168.1.2 12000stats #查看运行状态quit #退出
附注: php5.4.9启动命令:/opt/php/sbin/php-fpm检测php运行进程 ps aux|grep php-fpmphp-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的用户)
其它类似信息

推荐信息