您的位置:首页 > 运维架构 > Nginx

LNMP-(mysql 5.5.27&php 5.4.6&nginx1.2.3) 安装手记

2013-09-12 10:00 1056 查看
---------------注意----------------------------------
1.---------------------------
/bin/sh ./libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -c ltdl.c
mkdir .libs
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c ltdl.c  -fPIC -o .libs/ltdl.o
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c ltdl.c -o ltdl.o >/dev/null 2>&1
/bin/sh ./libtool --mode=link gcc  -g -O2  -o libltdl.la -rpath /usr/local/lib -no-undefined -version-info 4:0:1 ltdl.lo -ldl
./libtool: line 3965: ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib ): command not found
./libtool: line 3965: ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib ): command not found
./libtool: line 3965: ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib ): command not found
./libtool: line 3965: ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib ): command not found
产生原因:源码包中LIBTOOL版本过低。
解决方法:让编译时调用系统的LIBTOOL。修改Makefile文件,LIBTOOL=$(SHELL)$(top_builddir)/libtool 为LIBTOOL=$(SHELL) /usr/bin/libtool
2.---------------------------
本文.很多的配置文件.使用的都是默认的.
为了能让大家更好的来了解各个软件.希望大家都真的能自己去阅读一下软件的配置文件
要根据实际情况来调整配置文件. 这才是根本.
3.---------------------------
本文的操作系统.请参照之前的博文
如果包不匹配.极有可能无法完整安装.
有一部分东西. 我是放在操作系统安装的时候处理的.
4.---------------------------
切记.  要去理解文章. 而不是完全的照抄
5.---------------------------
本文是我自己的安装笔记. 有个别的东西有修改 请仔细阅读
-----------------------------------------------------
################ mysql 5.5.27 ################
# 编译安装的方法
# 使用yum安装bison
yum install -y bison
# 下载地址
# mysql 下载地址 官网的列表 需要自己去选择
# http://dev.mysql.com/downloads/mirrors.html
# cmake 下载地址 官网的列表 需要自己去选择
# http://www.cmake.org/cmake/resources/software.html
# 下载mysql 和 cmake
wget ftp://ftp.cs.pu.edu.tw/Unix/mysql/Downloads/MySQL-5.5/mysql-5.5.27.tar.gz
wget http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
# 解压
tar zxf cmake-2.8.8.tar.gz
tar zxf mysql-5.5.27.tar.gz
# 进入cmake 目录
cd cmake-2.8.8
# 编译 安装
./configure && make && make install
cd ../
# 进入mysql 目录
cd mysql-5.5.27
# 使用 cmake 编译
cmake \
-DCMAKE_INSTALL_PREFIX=/soft/mysql-5.5.27 \
-DMYSQL_DATADIR=/data/mysql-5.5.27/ \
-DSYSCONFDIR=/soft/mysql-5.5.27/etc/ \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_EXTRA_CHARSETS=complex \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITH_DEBUG=0
# 编译 安装
make && make install
# 建立mysql组 并 建立mysql用户并加入到mysql组
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql -s /sbin/nologin
# 建立数据路径
mkdir -p /data/mysql-5.5.27/
# 修改目录权限
chown -R mysql:mysql /data/mysql-5.5.27
mkdir -p /soft/mysql-5.5.27/etc/
# 复制配置文件到/etc目录
cp support-files/my-medium.cnf /soft/mysql-5.5.27/etc/my.cnf
# 复制服务文件到 /etc/init.d目录
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
# 增加mysql 路径到 /etc/profile 目录 (功能是增加环境变量)
echo "PATH=\$PATH:/soft/mysql-5.5.27/bin" >> /etc/profile
# 增加mysql的lib到环境变量
echo "/soft/mysql-5.5.27/lib/" >>  /etc/ld.so.conf.d/mysql_lib.conf && /sbin/ldconfig
# 重读 profile 让环境变量立刻生效
. /etc/profile
# 初始化数据库
/soft/mysql-5.5.27/scripts/mysql_install_db --user=mysql --basedir=/soft/mysql-5.5.27/ --datadir=/data/mysql-5.5.27/
# 开启mysql
service mysqld start
# 清理MYSQL默认数据 清除主机名 清除主机默认IP地址 清除权限
mysql -uroot -e "drop database test; \
drop user root@test; \
drop user root@'::1'; \
drop user ''@'localhost'; \
drop user ''@'test';"
# 载入 pma_create_tables.sql 方便phpmyadmin的使用.
mysql -uroot -e "SOURCE ../pma_create_tables.sql;"
# 注意修改密码. 这个是给phpmyadmin使用的 请仔细去参考phpmyadmin
mysql -uroot -e "GRANT ALL ON phpmyadmin.* TO phpmyadmin@'%' IDENTIFIED BY 'phpmyadmin';"
# 修改mysql root 密码为 123456
mysqladmin -u root password '123456'
# 将mysql 加入服务 设置启动
chkconfig --add mysqld
chkconfig mysqld on
# 重启mysql
service mysqld restart
cd ../
# 开启防火墙
iptables -A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
service iptables save
################ nginx 1.2.3 ################
# 官方地址 http://nginx.org/en/download.html
# nginx 反向代理会使用的模块.需要单独加载 根据实际情况使用
# ngx_cache_purge-1.6.tar.gz
# http://labs.frickle.com/nginx_ngx_cache_purge/
wget http://labs.frickle.com/files/ngx_cache_purge-1.6.tar.gz
wget http://nginx.org/download/nginx-1.2.3.tar.gz
# 解压
tar zxf nginx-1.2.3.tar.gz
tar zxf ngx_cache_purge-1.6.tar.gz
# 进入nginx目录
cd nginx-1.2.3
# 编译参数 无 ngx_cache_purge
./configure \
--user=www \
--group=www \
--prefix=/soft/nginx-1.2.3 \
--with-http_stub_status_module \
--with-http_realip_module \
--with-http_ssl_module \
--with-http_sub_module \
--with-http_flv_module  \
--with-http_addition_module \
--with-http_gzip_static_module
# 带 ngx_cache_purge
./configure \
--user=www \
--group=www \
--prefix=/soft/nginx-1.2.3 \
--with-http_stub_status_module \
--add-module=../ngx_cache_purge-1.6 \
--with-http_realip_module \
--with-http_ssl_module \
--with-http_sub_module \
--with-http_flv_module  \
--with-http_addition_module \
--with-http_gzip_static_module
# 编译安装
make && make install
# 建立 nginx 所使用的用户
/usr/sbin/groupadd www
/usr/sbin/useradd -g www www -s /sbin/nologin
cd /soft/nginx-1.2.3/conf/
rm -fr *.default nginx.conf
# 上传配置文件
cd /etc/init.d/
# rz nginx
chmod +x nginx
mkdir -p /data/wwwroot/proxy_temp_dir /data/wwwroot/web /soft/nginx-1.2.3/logs/
# 日志分割脚本
cd /soft/nginx-1.2.3/sbin/
# rz cut_nginx_log.sh
chmod +x  cut_nginx_log.sh
# 赋予目录 写权限
chmod +w /data/wwwroot/ /soft/nginx-1.2.3/logs/
# 赋予目录及子目录 www组www用户读权限 
chown -R www:www /data/wwwroot/
chown -R web:web /soft/nginx-1.2.3
service nginx check
service nginx start
cd ../
chkconfig --add nginx
chkconfig nginx on
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
service iptables save
################ php-5.4.6 ################
# libiconv-1.14.tar.gz
http://www.gnu.org/software/libiconv/
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
# libmcrypt-2.5.8.tar.gz
http://sourceforge.net/projects/mcrypt/files/Libmcrypt/
wget http://cdnetworks-kr-2.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
# mhash-0.9.9.9
http://sourceforge.net/projects/mhash/files/
wget http://cdnetworks-kr-2.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
# mcrypt-2.6.8.tar.gz
http://sourceforge.net/projects/mcrypt/
wget http://cdnetworks-kr-1.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
# php php-5.4.6.tar.gz
http://www.php.net/downloads.php
wget http://cn.php.net/get/php-5.4.6.tar.gz/from/this/mirror
# memcache-3.0.6.tgz
http://pecl.php.net/package/memcache
wget http://pecl.php.net/get/memcache-3.0.6.tgz
# eaccelerator-0.9.6.1.zip 这个请注意..... 要下载最新版本 不然高版本的php不兼容
http://eaccelerator.net/
# wget http://cdnetworks-kr-2.dl.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.zip
# ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
# http://www.zend.com/en/products/guard/downloads
# wget http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
# php_screw-1.5.tar.gz
http://sourceforge.net/projects/php-screw/
wget http://cdnetworks-kr-1.dl.sourceforge.net/project/php-screw/php-screw/1.5/php_screw-1.5.tar.gz
# pear
# http://pear.php.net/
wget http://pear.php.net/go-pear.phar
yum -y install autoconf libjpeg-devel libpng-devel freetype-devel libxml2-devel zlib-devel glibc-devel \
glib2-devel bzip2-devel curl-devel e2fsprogs-devel krb5-devel libidn-devel libc-client libc-client-devel
# libiconv-1.14.tar.gz
tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure \
--prefix=/soft/libiconv-1.14
make && make install
cd ../
echo "/soft/libiconv-1.14/lib" >> /etc/ld.so.conf.d/php_lib.conf && /sbin/ldconfig
# libmcrypt-2.5.8.tar.gz
tar zxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure --prefix=/soft/libmcrypt-2.5.8
make && make install
/sbin/ldconfig
cd libltdl/
./configure \
--prefix=/soft/libmcrypt-2.5.8/libltdl \
--enable-ltdl-install
make && make install
cd ../../
echo "/soft/libmcrypt-2.5.8/lib" >> /etc/ld.so.conf.d/php_lib.conf
echo "/soft/libmcrypt-2.5.8/libltdl/lib" >> /etc/ld.so.conf.d/php_lib.conf && /sbin/ldconfig
# mhash-0.9.9.9
tar zxf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure \
--prefix=/soft/mhash-0.9.9.9
make && make install
cd ../
echo "/soft/mhash-0.9.9.9/lib" >> /etc/ld.so.conf.d/php_lib.conf && /sbin/ldconfig
# mcrypt-2.6.8.tar.gz
tar zxf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
# 安装mcrypt,
# ./configure时可能会报这个错:/bin/rm: cannot remove `libtoolT’: No such file or directory。
# 解决方法:修改configure文件,删除$RM “$cfgfile”这一行(在19744行)。重新再运行./configure就可以了。
# 看了下configure文件,其实可以忽略这个错。configure文件中cfgfile=”${ofile}T”定义的这里变量值是不存在的(${ofile}T的值为libtoolT),最后所以报错了。
export LD_LIBRARY_PATH=/soft/libmcrypt-2.5.8/lib:/soft/mhash-0.9.9.9/lib
export LDFLAGS="-L/soft/mhash-0.9.9.9/lib -I/soft/mhash-0.9.9.9/include/"
export CFLAGS="-I/soft/mhash-0.9.9.9/include/"
./configure \
--prefix=/soft/mcrypt-2.6.8 \
--with-libmcrypt-prefix=/soft/libmcrypt-2.5.8/
make && make install
cd ../
# php-5.4.6.tar.gz
tar zxf php-5.4.6.tar.gz
cd php-5.4.6/
# 有 mysql 客户端 --enable-inline-optimization \ zend如果失败 使用这个开关
./configure \
--prefix=/soft/php-5.4.6 \
--with-config-file-path=/soft/php-5.4.6/etc \
--with-mysql=/soft/mysql-5.5.27 \
--with-mysqli=/soft/mysql-5.5.27/bin/mysql_config \
--with-pdo-mysql=/soft/mysql-5.5.27 \
--with-iconv=/soft/libiconv-1.14 \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-bz2 \
--with-libxml-dir=/usr \
--with-curl \
--with-curlwrappers \
--with-mhash=/soft/mhash-0.9.9.9/ \
--with-mcrypt=/soft/libmcrypt-2.5.8/ \
--with-gd \
--with-openssl \
--with-imap \
--with-kerberos \
--with-imap-ssl \
--with-xmlrpc \
--with-gettext \
--enable-mbregex \
--enable-mbstring \
--enable-pcntl \
--enable-soap \
--enable-exif \
--enable-ftp \
--enable-zip \
--enable-sockets \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-gd-native-ttf \
--enable-calendar \
--enable-fpm
# 无mysql客户端 使用 mysqlnd
./configure \
--prefix=/soft/php-5.4.6 \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-config-file-path=/soft/php-5.4.6/etc \
--with-iconv=/soft/libiconv-1.14 \
--with-mhash=/soft/mhash-0.9.9.9/ \
--with-mcrypt=/soft/libmcrypt-2.5.8/ \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-bz2 \
--with-libxml-dir=/usr \
--with-curl \
--with-curlwrappers \
--with-gd \
--with-openssl \
--with-imap \
--with-kerberos \
--with-imap-ssl \
--with-xmlrpc \
--with-gettext \
--enable-mbregex \
--enable-mbstring \
--enable-pcntl \
--enable-soap \
--enable-exif \
--enable-ftp \
--enable-zip \
--enable-sockets \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-gd-native-ttf \
--enable-inline-optimization \
--enable-calendar \
--disable-rpath \
--enable-fpm
make ZEND_EXTRA_LIBS='-liconv'
make install
# cp php.ini-production /soft/php-5.4.6/etc/
cd ../
#wget http://pear.php.net/go-pear.phar
#/soft/php-5.4.6/bin/php go-pear.phar
# memcache-3.0.6.tgz
tar zxf memcache-3.0.6.tgz
cd memcache-3.0.6
/soft/php-5.4.6/bin/phpize
./configure \
--with-php-config=/soft/php-5.4.6/bin/php-config
make && make install
cd ../
# eaccelerator-0.9.6.1.zip 这个 0.9.6.1 不能在这个php版本使用
# 请下载最新的 eaccelerator,编译步骤不变
unzip eaccelerator-0.9.6.1.zip
cd eaccelerator-0.9.6.1/
/soft/php-5.4.6/bin/phpize
./configure \
--enable-eaccelerator=shared \
--with-php-config=/soft/php-5.4.6/bin/php-config
make && make install
cd ../
# ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
#tar zxf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
#cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so /soft/php-5.4.6/lib/php/extensions/no-debug-non-zts-20090626/
# php_screw-1.5.tar.gz
tar zxf php_screw-1.5.tar.gz
cd php_screw-1.5
/soft/php-5.4.6/bin/phpize
./configure \
--with-php-config=/soft/php-5.4.6/bin/php-config
make
# 注:这个是密码文件,用户自己设置加密的密码
# vi my_screw.h
#  如果make 出现  这个错误--------------
# /root/php_screw-1.5/php_screw.c: In function ‘zm_startup_php_screw’:
# /root/php_screw-1.5/php_screw.c:124: 错误:‘struct _zend_compiler_globals’ 没有名为 ‘extended_info’ 的成员
# /root/php_screw-1.5/php_screw.c: In function ‘zm_shutdown_php_screw’:
# /root/php_screw-1.5/php_screw.c:133: 错误:‘struct _zend_compiler_globals’ 没有名为 ‘extended_info’ 的成员
# make: *** [php_screw.lo] 错误 1
# --------------------------------------
# vi php_screw.c
# CG(extended_info) = 1;
# 修改为:
# CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
cp modules/php_screw.so /soft/php-5.4.6/lib/php/extensions/no-debug-non-zts-20090626/
cd tools
make
# 生成 screw 为二进制文件
cd ../
# php.ini 加入
# extension=/soft/php-5.4.6/lib/php/extensions/no-debug-non-zts-20090626/php_screw.so
mkdir -p /soft/php-5.4.6/cache
cd /soft/php-5.4.6/etc/
# rz 配置文件
chown -R web:web /soft/php-5.4.6
chown www:www /soft/php-5.4.6/cache
chmod +x /etc/init.d/php-fpm
service php-fpm start
chkconfig --add php-fpm
chkconfig php-fpm on
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: