DELL R420服务器搭建LAMP环境

一直都是在虚拟机中做实验,头一次在真机安装CentOS6.6 x86_64位系统,并安装LAMP环境。提前安装必备的软件包,在安装过程中未出现错误;可以使用一键安装LAMP脚本执行。

DELL R420服务器配置 E5-2403双cpu,4核心8线程;
[root@localhost ~]# grep "model name" /proc/cpuinfo |uniq
model name: Intel(R) Xeon(R) CPU E5-2403 v2 @ 1.80GHz
[root@localhost ~]# grep  -c "processor" /proc/cpuinfo
8
[root@localhost ~]# grep "core id" /proc/cpuinfo |sort |uniq|wc -l
4

Linux版本及内核版本
[root@localhost ~]# cat /etc/issue
CentOS release 6.6 (Final)
Kernel \r on an \m
[root@localhost ~]# uname -r
2.6.32-504.el6.x86_64

安装LAMP环境之前需要安装必备的包
yum install wget gcc gcc-c++ make re2c curl curl-devel libxml2 libxml2-devel libjpeg libjpeg-devel libpng libpng-devel libmcrypt libmcrypt-devel zlib zlib-devel openssl openssl-devel freetype freetype-devel gd gd-devel perl perl-devel ncurses ncurses-devel bison bison-devel libtool gettext gettext-devel cmake bzip2 bzip2-devel pcre pcre-devel

软件版本:
apache 2.4.12版本下载
MySQL 5.6.24版本下载
php5.6.8 版本下载
apr apr-util下载地址:
libmcrypt下载地址:ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt

编译安装mysql 5.6.24
#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
# make && make install 
# echo $?
# 0

创建mysql用户,数据库目录,更改权限
1234 # useradd -M -s /sbin/nologin mysql
# mkdir -p /data/mysql 
# chown -R mysql:mysql /data/mysql/
# chown -R mysql:mysql /usr/local/mysql/

初始化数据库
# cd /usr/local/mysql/scripts/ 
#  ./mysql_install_db --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql

拷贝配置文件,修改my.cnf
#  cp /usr/local/mysql/my.cnf /etc/my.cnf 
#  vi /etc/my.cnf
[mysqld]
user=mysql 
datadir=/data/mysql
default-storage-engine=MyISAM

拷贝启动脚本

# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

添加iptables规则,允许3306端口,并保存防火墙设置。
12 # iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
# /etc/init.d/iptables save

启动mysqld服务,并加入开机启动;

# service mysqld start
# chkconfig --add mysqld
# chkconfig mysqld on

设置环境变量,最后一行加入以下内容,保存退出后,source生效;

# vi /etc/profile
PATH=$PATH:/usr/local/mysql/bin
export PATH
# source /etc/profile

编辑mysqld启动脚本,找到basedir和datadir添加路径;
#vi /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/data/mysql

编译安装apache2.4.12
CentOS6 yum安装的apr版本已经不适用httpd-2.4版本了。所以,需要源码编译安装apr以及apr-util
#cd /usr/local/src/
#wget
#wget

编译安装apr

[root@localhost src]# tar zxf apr-1.5.2.tar.gz 
[root@localhost src]# cd apr-1.5.2
[root@localhost apr-1.5.2]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.5.2]# make && make install
[root@localhost apr-1.5.2]# echo $?
0

编译安装apr-util

[root@localhost src]# tar zxf apr-util-1.5.4.tar.gz 
[root@localhost src]# cd apr-util-1.5.4
[root@localhost apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@localhost apr-util-1.5.4]# make && make install
[root@localhost apr-util-1.5.4]# echo $?
0

检查开发环境,没有安装的话使用yum安装;
[root@localhost ~]# rpm -qa gcc cmake pcre-devel libmcrypt
libmcrypt-2.5.8-9.el6.x86_64
gcc-4.4.7-11.el6.x86_64
cmake-2.8.12.2-4.el6.x86_64
pcre-devel-7.8-6.el6.x86_64

编译安装apache

[root@localhost src]# tar zxf httpd-2.4.12.tar.gz 
[root@localhost src]# cd httpd-2.4.12
[root@localhost httpd-2.4.12]# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre --enable-mods-shared=most --enable-so
[root@localhost httpd-2.4.12]# echo $?
0

apache执行命令目录加入配置文件,生效;
[root@localhost ~]# vi /etc/profile
PATH=$PATH:/usr/local/apache2/bin
[root@localhost ~]# . /etc/profile

添加iptables规则,允许80端口,并保存防火墙设置。
# iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
# /etc/init.d/iptables save

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

转载注明出处:https://www.heiqu.com/c4fa350f744804401d2adb57f448e169.html