Centos7.4 LAMP(A2.2.29_M5.5.12_P5.3.10)

基础环境准备:
操作系统: Centos 7.4
软件: httpd-2.2.29 mysql 5.5.12 php 5.3.10
基础设置: firewall selinux 禁止
一、httpd-2.2.29安装
1.1、安装依赖包:
yum install gcc gcc-c++ make pcre-devel expat-devel perl bzip2 vim wget -y
1.2、安装httpd-2.2.29
cd /soft
wget http://www.xchinagroup.top/softdown/centos7/12_Apache/httpd-2.2.29.tar.bz2
tar jxvf httpd-2.2.29.tar.bz2
cd httpd-2.2.29/
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi

--prefix=/usr/local/httpd //指定将httpd程序安装到/usr/local/httpd目录下 
 --enable-so //启用动态加载模块功能 
 --enable-rewrite //启用网页地址重写功能,用于网站优化及目录迁移 
 --enable-charset-lite //启用字符集支持,以便支持使用各种字符集编码的网页 
 --enable-cgi //启用CGI脚本程序支持,便于扩展网站的应用访问能力
make && make install
1.3、配置
ln -s /usr/local/httpd/bin/* /usr/local/bin/
vim /usr/local/httpd/conf/httpd.conf



1.4、启动httpd
apachectl start

如果你的防火墙是开启的,需要执行下面语句,允许http服务。
firewall-cmd --add-service=http
firewall-cmd --add-service=http --permanent


firewall-cmd --reload


1.5、IE打开 测试


1.6、配置开机启动:
chmod +x /etc/rc.d/rc.local
echo "apachectl start" >>/etc/rc.local

二、安装mysql 5.5.12
2.1、安装依赖包:
yum remove mariadb* -y
yum install make gcc gcc-c++ cmake bison bison-devel ncurses-devel libaio libaio-deve perl-Data-Dumper net-tools -y

2.2、安装mysql 5.5.12
mkdir -p /usr/local/mysql/data
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
chown -R mysql:mysql /usr/local/mysql
cd /soft
wget http://www.xchinagroup.top/softdown/centos7/03_mysql/5.5.12/mysql-5.5.12.tar.gz
tar zxvf mysql-5.5.12.tar.gz
cd mysql-5.5.12

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DMYSQL_USER=mysql

make && make install
chown -R mysql:mysql /usr/local/mysql
2.3、初始化数据库
vim /etc/my.cnf
[mysqld]
port=3306
datadir=/usr/local/mysql/data
basedir=/usr/local/mysql
log-bin=mysql-bin
##############################

cd /usr/local/mysql/scripts
./mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

2.4、配置启动脚本
cp /soft/mysql-5.5.12/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld start
chkconfig mysqld on

2.5、配置环境变量
vim /etc/profile
在最后面加上
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
export PATH
保存退出。
source /etc/profile
如果你的防火墙是开启的,需要执行下面语句,允许mysql
firewall-cmd --add-port=3306/tcp
firewall-cmd --add-port=3306/tcp --permanent
firewall-cmd --reload

三、安装php-5.3.10
3.1、安装依赖包以及php编译需要用到的软件
yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libxml2 libxml2-devel oepnssl openssl-devel bzip2 bzip2-devel curl curl-devel libpng libpng-devel freetype-devel libtool libtool-ltdl-devel -y

cd /soft
wget https://sourceforge.mirrorservice.org/m/mc/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && make install
+++++++++++++++++++++++++++++
cd /soft
wget https://nchc.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make && make install
++++++++++++++++++++++++++++++++++++++++
wget https://excellmedia.dl.sourceforge.net/project/lnmpaio/web/mcrypt/mcrypt-2.6.8.tar.gztar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
LD_LIBRARY_PATH=/usr/local/lib ./configure
make && make install
+++++++++++++++++++++++
cd /soft
wget http://mirror.hust.edu.cn/gnu/libiconv/libiconv-1.14.tar.gz
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14/
./configure --prefix=/usr/local/libiconv
make
报错信息如下:


解决办法:
cd srclib/
vim stdio.h    ## 这个stdio.h 文件是在执行make 时候,才会生成的一个文件。





保存退出。
再执行 make
make install
++++++++++++++++++++++++++++++++++++++++++++++++
3.2、安装php5.3.10
cd /soft
wget http://www.xchinagroup.top/softdown/centos7/01_php/php5.3.10/php-5.3.10.tar.gz
tar zxvf php-5.3.10.tar.gz
cd php-5.3.10
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/httpd/bin/apxs --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-openssl --with-zlib --with-bz2 --with-gettext --with-mhash --with-mcrypt --with-iconv=/usr/local/libiconv --with-curl --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --enable-gd-native-ttf --enable-bcmath --enable-mbstring --enable-zip --enable-soap --enable-sockets --enable-ftp --without-pear

make


解决办法:下载php补丁
cd /root
curl -o php-5.3.10.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt
yum install patch -y
cd /soft/php-5.3.10
patch -p0 -b </root/php-5.3.10.patch



再次执行 make
make install
3.3、配置php.ini
vim /etc/php.ini





保存退出。

3.4、配置Apache 与 php 关联
vim /usr/local/httpd/conf/httpd.conf





保存退出,重启Apache服务
apachectl restart
3.5、测试PHP
cd /usr/local/httpd/htdocs
vim test.php
<?php 
 phpinfo(); 
 ?>
保存退出。