CentOS5 编译安装LNMP步骤

# 手动安装lnmp
包含 libiconv libunwind gperftools libmcrypt mhash mcrypt libpng freetype jpeg
gd pcre libmemcached php_memcached(memcached.so)  eaccelerator ZendOptimizer
MySQL5.5 php5.3 nginx1.2.7 memcached tokyocabinet tokyotyrant
#路径
程序存放      /data/service
lib or common /data/service/common
数据存放      /data/data
日志存放      /data/logs


# yum源更改
rm -f CentOS6-Base-163.repo \
rm -f /etc/yum.repos.d/CentOS6-Base-163.repo
yum install -y wget   
wget -4 --no-cache \
-O /etc/yum.repos.d/CentOS6-Base-163.repo


mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak


yum makecache && yum update -y && rm -f /etc/yum.repos.d/CentOS-Base.repo


yum install ntp wget cpp gcc gcc-c++ gcc-g77 make unzip libtool \
libtool-ltdl-devel libc-client-devel libstdc++-devel db4-utils libcap-devel \
expat-devel perl pam-devel perl-Time-HiRes libaio-devel bzr patch bzip2-devel \
cmake bison libevent-devel ncurses-devel openssl-devel zlib-devel curl-devel \
libxml2-devel tcp_wrappers-devel nasm lemon flex libXpm-devel fontconfig-devel \
pcre-devel sqlite-devel perl-ExtUtils-Embed neon-devel


# centos 5
yum install libmcrypt-devel mhash-devel


# 系统自带png, jpeg, freetype
yum install libpng-devel libjpeg-devel freetype-devel


# libiconv
./configure
make && make install
echo "/usr/local/lib" >> \
/etc/ld.so.conf.d/service_lib.conf && /sbin/ldconfig


# libunwind
CFLAGS=-fPIC ./configure
make CFLAGS=-fPIC && make CFLAGS=-fPIC install


# gperftools
./configure --enable-frame-pointers
make && make install
/sbin/ldconfig


# mysql 5.5
groupadd mysql -g 1002
useradd mysql -u 1002 -g mysql -s /sbin/nologin


rm -f CMakeCache.txt
cmake \
. -DCMAKE_INSTALL_PREFIX=/data/service/mysql \
-DMYSQL_DATADIR=/data/data/mysql \
-DSYSCONFDIR=/data/service/mysql/etc \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_TCP_PORT=3306 \
-DWITH_DEBUG=0
make && make install


# mysql5.1
./configure \
--prefix=/data/service/mysql \
--localstatedir=/data/data/mysql \
--sysconfdir=/data/service/mysql/etc \
--with-mysqld-user=mysql \
--without-debug \
--with-big-tables \
--with-unix-socket-path=/tmp/mysql.sock \
--with-charset=gbk \
--with-collation=gbk_chinese_ci \
--with-extra-charsets=all \
--with-plugins=partition \
--enable-static \
--with-client-ldflags=-all-static \
--with-tcp-port=3306


ln -s /data/service/mysql/lib /data/service/mysql/lib64
echo "/data/service/mysql/lib64/" >> \
/etc/ld.so.conf.d/service_lib.conf && /sbin/ldconfig


mkdir -p /data/service/mysql/etc && mkdir -p /data/data/mysql
cp -f support-files/my-medium.cnf /data/service/mysql/etc/my.cnf
# add gperftools
sed -i 's/executing\ mysqld_safe$/&\nexport\ LD_PRELOAD="\/usr\/local\/lib\/libtcmalloc.so"/' \
/data/service/mysql/bin/mysqld_safe


cp -f support-files/mysql.server /data/service/mysql/mysqld
chmod 755 /data/service/mysql/mysqld
chown -R mysql.mysql /data/data/mysql


[mysqld]
pid-file        = /data/data/mysql/mysqld.pid
datadir        = /data/data/mysql


max_connections = 500
max_connect_errors=10000
slow_query_log=1
slow_query_log_file = /data/data/mysql/slowsql.log
long_query_time = 2
log-queries-not-using-indexes


innodb_file_per_table = 1
innodb_data_home_dir = /data/data/mysql
innodb_data_file_path = ibdata1:10M:autoextend:max:2000M
innodb_log_group_home_dir = /data/data/mysql
innodb_file_per_table = 1
innodb_buffer_pool_size = 256M
innodb_additional_mem_pool_size = 2M
innodb_log_buffer_size = 8M
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
sync_binlog = 1
innodb_flush_log_at_trx_commit = 0
innodb_lock_wait_timeout = 50


log-bin=mysql-bin
binlog_format = mixed
expire_logs_days = 7


[mysqld_safe]
log-error = /data/data/mysql/mysql.log

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/12bf002bdec73b8aff3344bce56b6a12.html