说明:在本帖中,#代表shell的提示符,所有操作均在root环境变量下面执行
一,系统的安装
系统安装的是centos6.0版本,磁盘大小300G
安装好之后,配置ip地址,ssh,iptables等服务,安装系统的原则:最小化安装,尽量不安装图形界面和不必要的软件包。
二,软件包的准备
mysql-5.6.2-m5,php-5.3.6,httpd-2.2.21
下载地址
- #cd /usr/local/src
- #wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.2-m5.tar.gz
- #wget http://mirrors.sohu.com/php/php-5.3.6.tar.gz
- #wget http://mirrors.sohu.com/apache/httpd-2.2.21.tar.gz
三,本机yum源的配置
- #vim /etc/yum.repos.d/myyum.repo
- [Packages]
- name=CentOS-$releasever - Plus
- baseurl=file:///mnt/cd/ #本地文件路径,如果是网络源,请更改
- gpgcheck=1 #gpg校验
- enabled=1 #yum的开关
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
- #yum clean all
- #yum list
四,安装系统编译环境所需要的软件包
for base in gcc gcc-c++ make cmake apr apr-util postgresql-libs zlib* openssl openssl-devel autoconf automake ncurses* libtool* libxslt libxslt-devel libxml* curl* bzip2* gd gd-devel freetype freetype-devel libpng* cairo-devel libxml2-devel pango pango-devel libmcrypt libpng jpeg bison mysql-develdo rpm -qa |grep $base;retval=$?
[ "$retval" != 0 ] && yum install $base done
注意,以上步骤需要把yum源等配置好,然后复制紫色字体到脚本运行 (主要是安装gcc make以及GD及库相关 curl libpng zlib freetype libxslt jpegsrc gd libxml )五,apache的编译安装
- #service httpd stop //为了防止系统安装的时候默认安装过apache
- #rpm -e --nodeps httpd
- #tar xvf httpd-2.2.21.tar.gz
- #cd httpd-2.2.21
- #groupdel Apache
- #groupdel apache
- #userdel apache
- #groupadd --gid=48 apache
- #useradd -s /sbin/nologin -d /usr/local/apache2 -g apache --uid=48 apache
- #./configure --prefix=/usr/local/apache2 --enable-deflate --enable-headers --enable-so --with-mpm=worker --enable-rewrite --enable-cgi --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache --enable-static-ab --enable-static-htpasswd --enable-expires --enable-authn-dbm --with-ssl --enable-ssl --disable-userdir --disable-cgid --enable-expires --enable-speling
- #make && make install
- #ln -s /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
- #chown -R apache:apache /usr/local/apache2
- #service httpd restart
- ------------------------------------------------------
- #echo 'service httpd restart' >> /etc/rc.d/rc.local 如果前面有ln -s 此处去掉
- ------------------------------------------------------
- #sed -i 's/User\ daemon/User\ apache/g' /usr/local/apache2/conf/httpd.conf
- #sed -i 's/Group\ daemon/Group\ apache/g' /usr/local/apache2/conf/httpd.conf
- #cd ..
六,mysql的安装过程
- #tar xvf mysql-5.6.2-m5.tar.gz
- #cd mysql-5.6.2-m5
- #mkdir /usr/local/mysql
- #groupdel mysql
- #userdel mysql
- #groupadd mysql
- #useradd -d /var/lib/mysql -s /bin/bash -g mysql mysql
- -----------------------------------------------------------------
- #wget http://googletest.googlecode.com/files/gtest-1.5.0.tar.gz
- #cp gtest-1.5.0.tar.gz mysql-5.6.2-m5/source_downloads
- ------------------------------------------------------------------
- **********此处需要注意的是如果没有下载gtest,安装的过程会自动去下载gtest,需要将以下的参数改变成这样-DENABLE_DOWNLOADS=1
- # cmake . -DINSTALL_LIBDIR=/usr/local/mysql -DMYSQL_DATADIR=/var/mysql/data -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_ COLLATION=utf8_general_ci -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLE_DOWNLOADS=0 -DENABLED_LOCAL_INFILE=1 -DWITH_MY ISAM_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DWITH_LIBWRA P=1 -DWITH_DEBUG=0
- #chown -R mysql /usr/local/mysql
- #chgrp -R mysql /usr/local/mysql
- #make && make install
- #cp support-files/my-medium.cnf /etc/my.cnf
- #cp support-files/mysql.server /etc/init.d/mysqld
- #chmod 755 /etc/init.d/mysqld
- #chown -R root:mysql /usr/local/mysql/
- #chown -R mysql:mysql /usr/local/mysql/data
- #sed -i '/^\[mysqld\]$/a set-variable=max_connections=2000' /usr/local/mysql/etc/my.cnf
- #cp extra/my_print_defaults /usr/local/mysql/bin/
- #mkdir -p /var/lib/mysql/data
- #mkdir /var/run/mysqld
- #chown -R mysql:mysql /var/run/mysqld
- #chmod 755 -R /var/mysql/data/
- #chkconfig --add mysqld
- #chkconfig mysqld on
- #/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/var/mysql/data
- #/usr/local/mysql//bin/mysqld_safe &
- #ln -s /usr/local/mysql/bin/mysql /bin/mysql
- #service mysqld restart &&
- #cd ..
- 需要注意的是:本处只是把mysql安装好了,对系统参数并没有做设置,大家可以参考其他mysql调优
- 资源进行相关的设置
七,php的安装过程
- #tar xvf libmcrypt-2.5.8.tar.gz
- #cd libmcrypt-2.5.8
- #./configure --prefix=/usr/local/
- #make && make install
- #cd ..
- #tar xvf mhash-0.9.9.9.tar.gz
- #cd mhash-0.9.9.9
- #./configure --prefix=/usr/local/
- #make && make install
- #cd ..
- #tar xvf mcrypt-2.6.8.tar.gz
- #cd mcrypt-2.6.8
- #LD_LIBRARY_PATH=/usr/local/lib ./configure --prefix=/usr/local/
- #make && make install
- #cd ..
- #wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
- #tar xvf libiconv-1.14.tar.gz
- #cd libiconv-1.14
- # ./configure --prefix=/usr/local
- #make && make install
- #cd ..
- #tar xvf freetype-2.4.0.tar.gz
- #cd freetype-2.4.0
- #./configure
- #make && make install
- #cd ..
- # wget http://downloads.sourceforge.net/project/libpng/libpng14/older-releases/1.4.2/libpng-1.4.2.tar.gz
- #tar xvf libpng-1.4.2.tar.gz
- #cd libpng-1.4.2
- #./configure
- #make && make install
- #wget http://www.netpurgatory.com/web_stuff/zeusmp_releases/jpegsrc.v6b.tar.gz
- #./configure --enable-static --enable-shared
- #mkdir /usr/local/man/man1
- #----If your system was install libxml2, you do not need to install it.----
- #wget ftp://xmlsoft.org/libxml2/libxml2-2.7.6.tar.gz
- #tar xvf libxml2-2.7.6.tar.gz
- #cd libxml2-2.7.6
- #./configure
- #make && make install
- *******************************install php*********************************
- #tar xvf php-5.3.6.tar.gz
- #cd php-5.3.6
- ****************注意此处进行2处链接,同时将--with-mysql=/usr/local/mysql改为--with-mysql=/usr,防止提示configure: error: Cannot find libmysq
- lclient under /usr/local/mysql的错误*******************
- #ln -s /usr/local/mysql/libmysqlclient_r.a /usr/lib/libmysqlclient_r.a
- #ln -s /usr/local/mysql/libmysqlclient.a /usr/lib/libmysqlclien.a
- #./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/ --with-mysql=/usr --with-mysql-sock=/tmp/mysql.
- sock --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-bz2 --with-jpeg-dir --with-png-dir --with-freetype-dir --w
- ith-libxml-dir=/usr/local --with-zlib-dir --with-gd --enable-gd-native-ttf --with-xsl --with-openssl-dir --with-mcrypt --e
- nable-zip --enable-sqlite-utf8 --enable-sockets --enable-soap --enable-ucd-snmp-hack --enable-ftp --enable-safe-mode --enab
- le-bcmath --enable-sysvsem &&
- ***********加此参数防止make的时候报make: *** [sapi/cli/php] Error 1的错误********
- 用sed命令替换如下
- #sed -i 's/\-lm\ \-lxslt\ \-lxml2\ \-lz\ \-lm\ \-lcrypt/\-lm\ \-lxslt\ \-lxml2\ \-lz\ \-lm\ \-lcrypt\ \-liconv/g' Makefile
- #make && make install
- #cp php.ini-development /usr/local/php5/php.ini
- ******php测试页面的自动生成,如果各位自行定义了apche的路径,下面的语句也需要改变*****
- #echo -e "<?php\nphpinfo();\n?>" >/usr/local/apache2/htdocs/test.php
- ********让apache对php进行支持,需要更改3个地方******
- #sed -i '/AddType\ application\/x-gzip .gz \.tgz$/a \ AddType\ application\/x-httpd-php\ \.php\ \.phtml' /usr/local/apache
- 2/conf/httpd.conf
- #sed -i '/AddType\ application\/x-httpd-php\ \.php\ \.phtml$/a \ AddType\ application\/x-httpd-php-source\ \.phps' /usr/lo
- cal/apache2/conf/httpd.conf
- #sed -i '/Group\ apache$/a LoadModule php5_module libexec/libphp5.so' /usr/local/apache2/conf/httpd.conf
- sed -i '/\\ LoadModul foo_modules\ modules\/mod_foo.so$/a \ LoadModule php5_module libexec/libphp5.so' /usr/local/apache2/c
- onf/httpd.conf
- #service httpd restart
八,测试调优:通过以上步骤的安装,系统框架已经可以搭建好了,接下来需要各位自己对各参数进行相关的优化设置请大家自己设置,本文不再详述,如有不足之处,请大家指教。
itnihao 2011年9月整理,10发表,于成都