系统版本
CentOS-6.4-x86_64-minimal
系统调整
vi /etc/sysconfig/network-scripts/ifcfg-eth0 ONBOOT=yes service network restart vi /etc/selinux/config SELINUX=disabled vi /etc/init/start-ttys.conf env ACTIVE_CONSOLES=/dev/tty[1-2] vi /etc/sysconfig/init ACTIVE_CONSOLES=/dev/tty[1-2] vi /etc/sysctl.conf #net.bridge.bridge-nf-call-ip6tables = 0 #net.bridge.bridge-nf-call-iptables = 0 service iptables stop && chkconfig iptables off service ip6tables stop && chkconfig ip6tables off service postfix stop && chkconfig postfix off yum update yum install -y vim-common vim-enhanced man gcc-c++ fontconfig cmake openssl-devel
软件获取
mysql-5.6.14 http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.14.tar.gz
apache-2.2.26 http://mirrors.sohu.com/apache/httpd-2.2.26.tar.gz
php-5.5.9 http://mirrors.sohu.com/php/php-5.5.9.tar.gz
libxml2-2.9.0 ftp://xmlsoft.org/libxml2/libxml2-2.9.0.tar.gz
curl-7.36.0 http://curl.haxx.se/download/curl-7.36.0.tar.gz
jpegsrc.v9a http://www.ijg.org/files/jpegsrc.v9a.tar.gz
libpng-1.5.18 ftp://ftp.simplesystems.org/pub/png/src/libpng15/libpng-1.5.18.tar.gz
freetype-2.5.3 http://ftp.twaren.net/Unix/NonGNU/freetype/freetype-2.5.3.tar.gz
libmcrypt-2.5.7 ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
autoconf-2.69 http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
phpMyAdmin-4.1.8-all-languages http://jaist.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.1.8/phpMyAdmin-4.1.8-all-languages.tar.gz
软件安装
安装mysql
[root@lh ~]# yum install -y ncurses-devel [root@lh ~]# tar zxvf /var/ftp/pub/mysql-5.6.14.tar.gz -C /usr/src/ [root@lh mysql-5.6.14]# cmake . [root@lh mysql-5.6.14]# make && make install [root@lh mysql-5.6.14]# groupadd -r mysql [root@lh mysql-5.6.14]# useradd -r mysql -g mysql -s /sbin/nologin [root@lh mysql-5.6.14]# chown -R mysql:mysql /usr/local/mysql/ [root@lh mysql-5.6.14]# ls -ld /usr/local/mysql/ drwxr-xr-x 13 mysql mysql 4096 12月 5 12:38 /usr/local/mysql/ [root@lh scripts]# cd /usr/local/mysql/scripts/ [root@lh scripts]# ./mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/ --basedir=/usr/local/mysql/ [root@lh mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql [root@lh mysql]# chkconfig --add mysql [root@lh mysql]# chkconfig mysql on [root@lh mysql]# chkconfig mysql --list mysql 0:关闭1:关闭2:启用3:启用4:启用5:启用6:关闭 [root@lh mysql]# cp /usr/local/mysql/support-files/my-default.cnf /usr/local/mysql/my.cnf cp:是否覆盖"/usr/local/mysql/my.cnf"? y [root@lh mysql]# vim /usr/local/mysql/my.cnf basedir = /usr/local/mysql datadir = /usr/local/mysql/data port = 3678(默认端口3306) sock = /tmp/mysql.sock [root@lh mysql]# service mysql start [root@lh ~]# mysql -uroot mysql> update mysql.user set password=password('neowave') where User="root"; Query OK, 4 rows affected (0.13 sec) Rows matched: 4 Changed: 4 Warnings: 0 mysql> flush privileges; Query OK, 0 rows affected (0.03 sec)
安装apache
[root@lh pub]# tar zxvf /var/ftp/pub/httpd-2.2.26.tar.gz -C /usr/src/ [root@lh pub]# cd /usr/src/httpd-2.2.26/ [root@lh httpd-2.2.26]# yum install zlib-devel [root@lh httpd-2.2.26]# ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd \ --enable-so --enable-rewrite --enable-charset-lite --enable-cgi \ --enable-mods-shared=all --enable-cache --enable-disk-cache --enable-mem-cache \ --enable-static-support [root@lh httpd-2.2.26]# make && make install [root@lh httpd-2.2.26]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd [root@lh httpd-2.2.26]# vim /etc/init.d/httpd #chkconfig:35 10 90 #description:Activates/Deactivates Apache Web Server [root@lh httpd-2.2.26]# chkconfig httpd --add [root@lh httpd-2.2.26]# chkconfig httpd on [root@lh httpd-2.2.26]# chkconfig httpd --list httpd 0:关闭1:关闭2:启用3:启用4:启用5:启用6:关闭 [root@lh ~]# service httpd start [root@lh httpd-2.2.26]# yum install -y lynx #(centos-indexhtml)
安装PHP
在安装PHP之前,应先安装PHP5需要的最新版本库文件,例如libxml2、libmcrypt以及GD2库等文件。
安装GD2库是为了让PHP5支持GIF、PNG和JPEG图片格式,所以在安装GD2库之前还要先安装最新的zlib、libpng、freetype和jpegsrc等库文件,而且中间还会穿插安装一些软件
批处理解包脚本代码:tar.sh
#!/bin/bash sdir="/root" #tar包所在路径 ddir="/usr/local/src" #解压目标路径 cd $sdir ####### 将find的结果传递给while循环 ################# find . -maxdepth 1 -type f -name "*.tar.*" -print |sed 's/\.\///g' | while read line do tar zxvf $line -C $ddir >> /dev/null #解压tar包 echo $line >> tar.txt #解压过的tar包记录到tar.txt done exit 0
将libxml2、curl、jpeg、libpng、freetype、libmcrypt的tar包复制到root目录,运行tar.sh批量解包,然后切换到/usr/local/src,逐个编译安装
#### 安装libxml2 #### [root@lh src]# cd libxml2-2.9.0/ [root@lh libxml2-2.9.0]# ./configure --prefix=/usr/local/libxml2 && make && make install #### 安装curl #### [root@lh libxml2-2.9.0]# cd ../curl-7.36.0/ [root@lh curl-7.36.0]# ./configure --prefix=/usr/local/curl && make && make install #### 安装jpeg #### [root@lh curl-7.36.0]# cd ../jpeg-9a/ [root@lh jpeg-9a]# ./configure --prefix=/usr/local/jpeg && make && make install #### 安装libpng #### [root@lh jpeg-9a]# cd ../libpng-1.5.18/ [root@lh libpng-1.5.18]# ./configure --prefix=/usr/local/libpng && make && make install #### 安装freetype #### [root@lh libpng-1.5.18]# cd ../freetype-2.5.3/ [root@lh freetype-2.5.3]# ./configure --prefix=/usr/local/freetype && make && make install #### 安装libmcrypt #### [root@lh freetype-2.5.3]# cd ../libmcrypt-2.5.7/ [root@lh libmcrypt-2.5.7]# ./configure --prefix=/usr/local/libmcrypt && make && make install #### 安装PHP #### [root@lh php-5.5.9]# ./configure --prefix=/usr/local/php --with-config-file-path=/etc \ --with-apxs2=/usr/local/httpd/bin/apxs \ --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock \ --with-iconv --with-openssl --with-gd --with-gettext --with-xmlrpc --with-curl=/usr/local/curl \ --with-zlib --with-mcrypt=/usr/local/libmcrypt/ --with-libxml-dir=/usr/local/libxml2/ \ --with-jpeg-dir=/usr/local/jpeg/ --with-png-dir=/usr/local/libpng/ --with-freetype-dir=/usr/local/freetype/ \ --without-pear --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex \ --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --enable-zip \ --enable-soap --enable-session --enable-zend-signals --enable-fpm [root@lh php-5.5.9]# make && make install [root@lh php-5.5.9]# cp php.ini-production /etc/php.ini
编辑apache主配置文件(httpd.conf)添加php支持
[root@lh ~]# vim /etc/httpd/httpd.conf
Addtype application/x-httpd-php .php .phtml
重启httpd
[root@lh ~]# /usr/local/httpd/bin/apachectl restart
安装phpMyadmin
[root@lh ~]# tar zxvf phpMyAdmin-4.1.12-all-languages.tar.gz -C /usr/local/src
[root@lh ~]# mv /usr/local/src/phpMyAdmin-4.1.12-all-languages /usr/local/httpd/htdocs/phpMyAdmin
[root@lh ~]# cd /usr/local/httpd/htdocs/phpMyAdmin/
[root@lh phpMyAdmin]# cp config.sample.inc.php config.inc.php
[root@lh phpMyAdmin]# vim config.inc.php
$cfg['Servers'][$i]['auth_type'] = 'http';将auth_type 由'cookie'改为'http'
测试PHP
[root@lh ~]# vim /usr/local/httpd/htdocs/phpinfo.php
<?php
phpinfo();
?>
访问http://192.168.120.109/phpinfo.php
访问http://192.168.120.109/phpmyadmin/index.php
输入mysql.user中的用户和密码(要有localhost登陆权限)