当前位置:文档之家› CentOS6.0+apache2.4+php5.4.7+mysql5.5.27

CentOS6.0+apache2.4+php5.4.7+mysql5.5.27

CentOS6.0+apache2.4+php5.4.7+mysql5.5.27一、安装前准备1、安装编译工具及所需要库文件yum install make apr* autoconf automake curl-devel gcc gcc-c++ gtk+-devel zlib-devel openssl openssl-devel pcre-devel gd gettext gettext-devel kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel libXpm* freetype freetype-devel freetype* fontconfig fontconfig-devel libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel2、下载软件包(统一下载到/usr/local/src )wget /Downloads/MySQL-5.5/mysql-5.5.27.tar.gzwget /files/v2.8/cmake-2.8.8.tar.gzwget /apache//httpd/httpd-2.4.3.tar.gzwget /apache//apr/apr-1.4.6.tar.gz # Apache库文件wget /apache//apr/apr-util-1.4.1.tar.gz # Apache库文件wget /distributions/php-5.4.7.tar.gzwget /project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz #PHPlibmcrypt模块wget ftp:///pub/software/programming/pcre/pcre-8.31.tar.gz二、安装mysql 5.5.271、安装cmake# cd /usr/local/src# tar zxf cmake-2.8.8.tar.gz# cd cmake-2.8.8# ./configure# make# make install2、开始安装mysql# groupadd mysql# useradd -g mysql mysql -s /bin/false // 创建用户mysql并加入到mysql组,不允许mysql 用户直接登陆系统# mkdir -p /data/mysql // 创建mysql 数据库存放目录# chown -R mysql.mysql /data/mysql // 设置mysql 数据库权限# mkdir -p /usr/local/mysql // 创建mysql 安装目录# cd /usr/local/src# tar zxf mysql-5.5.27.tar.gz# cd mysql-5.5.27# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc# make# make install# cd /usr/local/mysql# cp ./support-files/f /etc/f# vi /etc/f //编辑配置文件,在[mysqld] 部分增加下面一行datadir = /data/mysql:wq! 保存# ./scripts/mysql_install_db --user=mysql# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld // 把mysql 加入系统启动# chmod 755 /etc/init.d/mysqld# chkconfig mysqld on# vi /etc/rc.d/init.d/mysqld 修改下面两项定义basedir =/usr/local/mysql // MySQL程序安装路径datadir =/data/mysql // MySQl数据库存放目录大约在46、47行,注意,等号后面不要有空格# service mysqld start# vi /etc/profile // 把mysql服务加入系统环境变量:在最后添加下面这一行export PATH=$PATH:/usr/local/mysql/bin:wq! // 保存下面这两行把myslq的库文件链接到系统默认的位置,这样你在编译类似PHP等软件时可以不用指定mysql的库文件地址ln -s /usr/local/mysql/lib/mysql /usr/lib/mysqlln -s /usr/local/mysql/include/mysql /usr/include/mysql# shutdown -r now // 需要重启系统,等待系统重新启动之后继续在终端命令行下面操作# mysql_secure_installation // 根据提示按Y 回车,然后输入2次同样的密码,继续按Y 回车,直到设置完成。

或者采用下面的方式直接修改密码/usr/local/mysql/bin/mysqladmin -u root -p password "123456"# service mysqld restart至此,mysql5.5.27安装完毕# mysql -Vmysql Ver 14.14 Distrib 5.5.27, for Linux (i686) using EditLine wrapper三、安装Apache 2.4.3【注意事项】1)http2.2.* 不能直接升级到2.4.1,需要先停止apache,将http.conf 改名成http.conf-2.2.* 2)http2.4 目前不再支持php5.2.* 可用的php为5.3.10以上php5.2* 会报httpd: Syntax error on line 163 of httpd.conf: Cannot load modules/libphp5.sointo server: modules/libphp5.so: undefined symbol: unixd_config3)http2.4.1 不在需要NameVirtualHost以及不再支持ServerName * 这种写法使用ServerName * 会报Invalid ServerName “*”use ServerAlias to set multiple server names.1、安装libmcryptcd /usr/local/srctar zxvf libmcrypt-2.5.8.tar.gz #解压cd libmcrypt-2.5.8 #进入目录./configure #配置make #编译make install #安装2、安装apache# cd /usr/local/src/# tar zxf apr-1.4.6.tar.gz# tar zxf apr-util-1.4.1.tar.gz# tar zxf httpd-2.4.3.tar.gz# mv /usr/local/src/apr-1.4.6 /usr/local/src/httpd-2.4.3/srclib/apr # 把apr-1.4.6 移动到解压出来的httpd-2.4.3中的srclib目录中,并重命名为apr# mv /usr/local/src/apr-util-1.4.1 /usr/local/src/httpd-2.4.3/srclib/apr-util #把apr-util-1.4.1 移动到解压出来的httpd-2.4.3中的srclib目录中,并重命名为apr-util# cd /usr/local/src/httpd-2.4.3# ./configure --prefix=/usr/local/apache --enable-so --enable-deflate=shared --enable-ssl=shared --enable-expires=shared --enable-headers=shared --enable-rewrite=shared --enable-static-support --with-included-apr --with-mpm=prefork # make# make install# cp -f build/rpm/httpd.init /etc/init.d/httpd# chmod +x /etc/init.d/httpd# chkconfig --add httpd# chkconfig httpd on# cd /etc# ln -s /usr/local/apache/ httpd# cd /usr/sbin/# ln -fs /usr/local/apache/bin/httpd# ln -fs /usr/local/apache/bin/apachectl# cd /var/log# ln -s /usr/local/apache/logs httpd# /usr/local/apache/bin/apachectl -k start# httpd -vServer version: Apache/2.4.3 (Unix)Server built: Sep 14 2012 10:55:23四、安装php1、安装libmcrypt# cd /usr/local/src# tar zxvf libmcrypt-2.5.8.tar.gz #解压# cd libmcrypt-2.5.8 #进入目录# ./configure #配置# make #编译# make install #安装2、安装php# cd /usr/local/src/# tar zxf php-5.4.7.tar.gz# cd php-5.4.7# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc/ --with-libxml-dir=/usr/include/libxml2 --with-zlib --with-zlib-dir --with-bz2 --with-curl --enable-exif --with-gd --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --enable-ftp --with-freetype-dir=/usr/lib/ --enable-gd-native-ttf --enable-mbstring --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --enable-shmop --enable-soap --enable-sockets --enable-wddx --enable-zip --with-xmlrpc --enable-fpm# make# make install# cp php.ini-production /usr/local/php/etc/php.ini# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf# cp /usr/local/src/php-5.4.7/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm // 拷贝php-fpm到启动目录# chmod +x /etc/rc.d/init.d/php-fpm# chkconfig php-fpm on# vi /usr/local/php/etc/php.ini①找到:disable_functions = 修改为:disable_functions =passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit, posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname #列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用②找到:;open_basedir =修改为:open_basedir = .:/tmp/ #防止php木马跨站,相当重要!!③找到:;date.timezone =修改为:date.timezone = PRC #设置时区④找到:expose_php = On修改为:expose_php = OFF #禁止显示php版本的信息⑤找到:short_open_tag = Off修改为:short_open_tag = ON #支持php短标签# /etc/init.d/php-fpm start五、配置apache 支持php1、vi /usr/local/apache/conf/httpd.conf找到#ServerName :80把“#”去掉,并且把:80改成你要发布的域名或者是计算机名称,如果做测试的话可以不用改。

相关主题