一、准备工作:
1、全新安装redhat6.5系统,修改主机名,修改网络配置,设置可使用外网,设置用户账户密码;
2、iptables -F清除防火墙规则,sevices iptables save保存防火墙规则;
3、使用xshell 5进行ssh连接;
4、因无法使用红帽yum源使用winscp传送163yum源到/etc/yum.repo.d/目录下
5、编辑CentOS6-Base-163.repo文件,开户yum源开关,具体配置如下:
[root@redhat yum.repos.d]# vi /etc/yum.repos.d/CentOS6-Base-163.repo
[base]
name=CentOS-$releasever - Base - 163.com
baseurl=http://mirrors.163.com/centos/6/os/x86_64/
enabled=1
gpgcheck=0
[updates]
name=CentOS-$releasever - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6/updates/x86_64/
enabled=1
gpgcheck=0
[extras]
name=CentOS-$releasever - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/x86_64/
enabled=1
gpgcheck=0
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=0
enabled=0
6、yum安装上传下载工具yum install -y lrzsz
二、开始安装mysql
1、下载mysql到/usr/local/src目录,我已经下载好mysql
cd /usr/local/src/
使用rz命令将mysql上传到src目录
2、解压:tar -xvf mysql-5.1.72-linux-x86_64-glibc23.tar.gz
3、把解压完的数据移动到/usr/local/目录下并重全名为mysql
mv mysql-5.1.72-linux-x86_64-glibc23 /usr/local/mysql 4、建立mysql用户 useradd -s /sbin/nologin mysql 5、初始化mysql数据库 cd /usr/local/mysql mkdir -p /data/mysql ; chown -R mysql:mysql /data/mysql ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
6、卸载自带的mysql数据库 yum remove mysql
7、拷贝启动角本并修改属性 cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
8、修改启动角本
vim /etc/init.d/mysqld
修改basedir 和datadir目录
basedir=/usr/local/mysql
datadir=/data/mysql
把启动脚本加入系统服务项,并设定开机启动,启动mysql
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start
使用ps aux |grep mysqld查看mysql是否启动
三、安装apache
1、下载apache软件并上传到/usr/local/src
2、解压apache
tar zxvf httpd-2.2.16.tar.gz
3、配置编译参数
cd httpd-2.2.16
./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre 使用echo $?查看返回值是否为0为0是成功编译
4、编译 make 使用echo $?查看编译是否成功
5、安装 make install 使用echo $?查看是否安装成功
6、使用-t参数查看apache配置文件是否正确
/usr/local/apache2/bin/apachectl -t 返回值ok配置正解
7、启动apache /usr/local/apache2/bin/apachectl start
四、安装php
1、下载php文件并上传到src目录
2、配置编译参数
cd php-5.4.36
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6
3、因为缺少需要的库文件编译参数不成功提示: mcrypt.h not found. Please reinstall libmcrypt
下载libmcrypt 的rpm安装包安装
rpm -ivh libmcrypt-2.5.8-9.el6.x86_64.rpm libmcrypt-devel-2.5.8-9.el6.x86_64.rpm
重新配置编译文件,当出现以下结果时说明配置成功:
Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
也可以使用echo $?查看是否成功
4、编译 make 编译完成会有如下提示,
Build complete.
Don‘t forget to run ‘make test‘.
5、安装 make install 使用echo $?查看返回值为0安装成功
6、拷贝配置文件 cp php.ini-production /usr/local/php/etc/php.ini
6、编辑apache主配置文件使apache结合php
vim /usr/local/apache2/conf/httpd.conf
找到该行AddType application/x-gzip .gz .tgz下面添加一行
AddType application/x-httpd-php .php
找到该行<IfModule dir_module>
修改该行下面的字符为
DirectoryIndex index.html index.htm index.php
找到
#ServerName www.example.com:80
修改为ServerName localhost:80
本文出自 “愺艮搥豩” 博客,请务必保留此出处http://riverxyz.blog.51cto.com/533303/1782426
原文地址:http://riverxyz.blog.51cto.com/533303/1782426