安装Centos6.5
一、VirtualBox虚拟机安装Centos6.5
1、新建虚拟电脑、选择一些参数以及配置
2、进入Centos6.5的引导界面,选择”Install or upgrade an existing system”
3、按照步骤一步步走下去,到了选择安装方式的时候,选择URL方式。
5、继续按照步骤走,设置网络安装镜像
http://mirrors.ustc.edu.cn/centos/6.5/os/x86_64/images/install.img
6、接收安装
7、下面的一系列步骤按照提示一步一步好了。
8、重要的一步:分区,选择“创建自定义布局”。
/boot 分区:200M
/ 根分区:20000M
/opt 分区:剩下的
SWAP :2048
9、继续一步一步跟着选择下去。选择安装包,我们选择“Basic Server”
10、进入安装过程,等待安装。
11、重启完成。
安装MySQL
1、安装MySQL之前,需要安装cmake,因为cmake对软件源码进行编译。
前提:通过挂载把U盘中所需要的软件全部拷贝到系统的/root/soft
cmake源码包cmake-2.8.8.tar.gz,/root/soft/soft目录下
[root@localhost ~]# cd /root/soft/soft
[root@localhost /root/soft/soft]# tar -xzvf cmake-2.8.8.tar.gz
[root@localhost /root/soft/soft]# cd cmake-2.8.8
[root@localhost cmake-2.8.8]# ./bootstrap
---------------------------------------------
CMake 2.8.4, Copyright 2000-2009 Kitware, Inc.
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C compiler on this system.
Please specify one using environment variable CC.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors: /usr/local/src/cmake-2.8.4/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------
出现以上错误提示:缺少C的编译器
解决方案
安装gcc编译器
可以简单地用yum安装
[root@localhost ~]# yum install gcc
继续cmake的安装
[root@localhost cmake-2.8.8]# ./bootstrap
---------------------------------------------
CMake 2.8.4, Copyright 2000-2009 Kitware, Inc.
C compiler on this system is: cc
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C++ compiler on this system.
Please specify one using environment variable CXX.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors: /usr/local/src/cmake-2.8.4/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------
再次报错:缺少C++编译器。
安装gcc-c++编译器
简单地用yum安装
[root@localhost ~]# yum install gcc-c++
[root@localhost cmake-2.8.8]# ./bootstrap
没有报错后,编译安装
[root@localhost cmake-2.8.8]# gmake
[root@localhost cmake-2.8.8]# gmake install
检查安装 which cmake看结果可知安装是否正确
2、正式安装MySQL
mysql的源码包mysql-5.5.24.tar.gz 在/root/soft/soft目录下
[root@localhost ~]# cd /root/soft/soft
[root@localhost /root/soft/soft]# tar -xzvf mysql-5.5.24.tar.gz
root@localhost /root/soft/soft]# cd mysql-5.5.24
[root@localhost mysql-5.5.24]# cmake .
报错:
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH) CMake Error at cmake/readline.cmake:82 (MESSAGE): Curses library not found. Please install appropriate package, remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel. Call Stack (most recent call first): cmake/readline.cmake:126 (FIND_CURSES) cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT) CMakeLists.txt:250 (MYSQL_CHECK_READLINE) -- Configuring incomplete, errors occurred!
解决办法:
[root@localhost mysql-5.5.24]# yum -y install ncurses-devel*
[root@localhost mysql-5.5.24]# rm CMakeCache.txt
[root@localhost mysql-5.5.24]# cmake .
还是有个警告:
[root@localhost mysql-5.5.24]# yum install bison
[root@localhost mysql-5.5.24]# cmake .
[root@localhost mysql-5.5.24]# make && make install(完成编译安装)
添加mysql用户和用户组
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -g mysql mysql
进入安装目录,将程序二进制的所有权改为root,数据目录的所有权改为mysql用户,更新授权表
[root@localhost mysql-5.5.24]# cd /usr/local/mysql
[root@localhost mysql]# chown -R root .
[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .
[root@localhost mysql]# scripts/mysql_install_db --user=mysql (初始化数据库)
[root@localhost mysql]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data (安全启动mysql )
[root@localhost mysql]# ./bin/mysqld_safe --user=mysql(关闭mysql )
[root@localhost mysql]# ./bin/mysqladmin -u root shutdown -p
默认密码为空--方便调用,为mysql设置一个软链接
[root@localhost ~]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
其他设置处理:
设置选项文件,将配置文件拷贝到/etc下
[root@localhost mysql]# cp support-files/my-medium.cnf /etc/mysql.cnf 设置开机自启动
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql [root@localhost mysql]# chmod +x /etc/init.d/mysql
[root@localhost mysql]# chkconfig –add mysqld
[root@localhost mysql]# chkconfg mysqld on
现在可以通过服务来启动和关闭Mysql服务器
[root@localhost ~]# service mysql start
[root@localhost ~]# service mysql shutdown
连接服务器
[root@localhost ~]# mysql -u root -p
安装Apache
[root@localhost ~]#cd /root/soft/soft
[root@localhost soft]#tar -zxvf httpd-2.0.64.tar.gz//解压apache的压缩包
[root@localhost soft]#cd httpd-2.0.64 //定位到httpd-2.0.64 文件夹下
[root@localhost httpd-2.0.64#ls
[root@localhost httpd-2.0.64]#./configure --prefix=/opt/ws/apache --enable-so // 配置apache路径
[root@localhost httpd-2.0.64]#make //编译apache
[root@localhost httpd-2.0.64]#make install //安装apache
[root@localhost httpd-2.0.64]#cd /opt/ws/apache //进入apache的目录
[root@localhost apache]# cd conf/
[root@localhost conf]#cp -a httpd.conf httpd.conf- //备份apache配置文件
[root@localhost conf]#chkconfig --list httpd //查看httpd服务是否已存在
[root@localhost conf]#chkconfig httpd off //关闭系统自带了httpd的服务,如果存在httpd服务
[root@localhost conf]#service httpd status //查看自带httpd服务状态
[root@localhost conf]#/opt/ws/apache/bin/apachectl -k start //linux启动apache命令
[root@localhost conf]#netstat -an | grep :80 //查看linux80端口是否开启
[root@localhost conf]#ps -aux | grep httpd //linux下查看apache进程
[root@localhost conf]#cd ../..
[root@localhost local]#cp /opt/ws/apache/bin/apachectl /etc/rc.d/init.d/apache //拷贝apache启动脚本
[root@localhost local]#vi /etc/rc.d/init.d/apache // 这里是编辑apache启动脚本
在开头的#!/bin/sh 下面加上 www.111cn.net
#chkconfig: 2345 85 15
[root@localhost local]#chkconfig --add apache //添加apache服务
[root@localhost local]#chkconfig --list apache //列出apache服务
[root@localhost local]#service apache stop //停止apache服务
[root@localhost local]#netstat -an | grep :80 //查看linux的80端口是否关闭
[root@localhost local]#ps -aux | grep httpd //查看是否存在httpd服务,若果之前自带httpd服务启动的话会导致新添加的apache服务启动失败
[root@localhost local]#service apache start //启动apache服务
安装PHP
(在安装php之前必须先安装libxml2,因此可以通过下载libxml2安装包)
[root@localhost ~]#cd /root/soft/soft
[root@localhost soft]#tar -zxvf p.h.p.5.4.3tar.gz
[root@localhost soft]#cd p.h.p.5.4.3
[root@localhost p.h.p.5.4.3]#./configure --prefix=/opt/ws/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php --enable-mbstring=all
[root@localhost p.h.p.5.4.3]#make
[root@localhost p.h.p.5.4.3]#make install
LAMP环境之配置参数
配置 httpd.conf 让apache支持PHP:
Vim /usr/local/apache/conf/httpd.conf
添加如下:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
修改php.ini文件 register_globals = On