基于CentOS 6.7搭建LAMP(httpd

首先确保系统可以联网。设置IP地址以及虚拟机安装linux在此略过。本文采用CentOS 6.7 64位minimal版、php5.6.16、httpd-2.4.18、MySQL-5.5.47版搭建lamp环境。默认设置软件下载目录/usr/local/src,软件安装目录/app/local/下,安装顺序是apache→mysql→php。

通过搜狐镜像获取apache、mysql、php

搜狐镜像:

wget #若是提示没有wget命令则yum -y install wget

wget

wget

wget

wget

wget https://sourceforge.net/projects/pcre/files/pcre/8.10/pcre-8.10.tar.gz

wget

wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz

wget ftp://ftp.cn.debian.org/gentoo/distfiles/zlib-1.2.5.1.tar.gz

wget

wget https://sourceforge.net/projects/libpng/files/libpng12/1.2.56/libpng-1.2.56.tar.xz

wget

wget https://sourceforge.net/projects/freetype/files/freetype2/2.4.12/freetype-2.4.12.tar.bz2

wget https://github.com/libgd/libgd/archive/gd-2.1.1.tar.gz

wget

wget https://github.com/libgd/libgd/releases/download/gd-2.1.1/libgd-2.1.1.tar.bz2

wget https://cmake.org/files/v3.1/cmake-3.1.3.tar.gz

首先安装相应的库文件:
yum -y install xz  libXpm-devel lua-devel libxslt-devel gcc gcc-c++libjpeg libjpeg-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

新建相应的目录和用户和用户组:

mkdir -p /app/local/{php,apache,mysql,data}
groupadd -g 500 www
useradd -u 500 -g 500 -G 500 -s /sbin/nologin www

groupadd mysql

useradd -g mysql mysql -s /bin/false

#cd /usr/local/src/

#tar zxvf  apr-1.5.2.tar.gz

#cd apr-1.5.2

#./configure --prefix=/usr/local/apr

报错提示:cannot remove `libtoolT’: No such file or directory ,

解决办法:编辑 configure文件,查找 $RM "$cfgfile" 这个地方,用#注释掉,然后就可以了

#./configure --prefix=/usr/local/apr

#make && make install

#cd ../

#tar zxvf apr-util-1.5.4.tar.gz

#cd apr-util-1.5.4

#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config

#make && make install

#cd../

#tar zxvf pcre-8.10.tar.gz

#cd pcre-8.10

#./configure --prefix=/usr/local/pcre

#make && make install

#cd ../

安装Apache

#tar zxvf httpd-2.4.18.tar.gz

#cd httpd-2.4.18

#./configure --prefix=/app/local/apache --enable-mods-shared=all --enable-so --enable-proxy-ajp --enable-rewrite --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre

#make && make install

#cd ../

#chown -R www:www /app/local/apache/htdocs/

#chmod 755 /app/local/apache/htdocs/

先配置一下httpd.conf
找到;ServerName :80
改为ServerName localhost:80
#/app/local/apache/bin/apachectl -k start

在浏览器下输入ip地址查看apache是否成功启动

如果没有的话 可能是selinux和防火墙没有做相应设置

vi /etc/sysconfig/iptables

在端口22下一行加入80 3306端口配置(分别是apache和mysql的端口)

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

:wq保存退出

service iptables restart #重启防火墙使配置生效

然后在关闭selinux

vi /etc/sysconfig/selinux

改为SELINUX=disabled

:wq#保存退出

setenforce 0 #使配置立即生效

然后安装mysql,首先安装cmake

#tar zxvf cmake-3.1.3.tar.gz

#cd cmake-3.1.3

#./configure

#make && make install

#cd ../

#tar zxvf mysql-5.5.47.tar.gz

#cd mysql-5.5.47

#cmake -DCMAKE_INSTALL_PREFIX=/app/local/mysql -DMYSQL_DATADIR=/app/local/data -DSYSCONFDIR=/etc

#make && make install

#cd ../

#chown -R mysql:mysql /app/local/data

# cp /app/local/mysql/support-files/my-innodb-heavy-4G.cnf /etc/my.cnf

#ln -s /app/local/mysql/my.cnf /etc/my.cnf

#cd /app/local/mysql/

#./scripts/mysql_install_db --user=mysql --basedir=/app/local/mysql --datadir=/app/local/data

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

#chkconfig mysql on

#service mysql start

#cd /usr/local/src

最后安装php

#tar zxvf libxml2-2.7.4.tar.gz

#cd libxml2-2.7.4

#./configure --prefix=/usr/local/libxml2

报错提示:cannot remove `libtoolT’: No such file or directory ,

解决办法:编辑 configure文件,查找 $RM "$cfgfile" 这个地方,用#注释掉,然后就可以了

#./configure --prefix=/usr/local/libxml2

#make && make install

#cd ../

#tar zxvf libmcrypt-2.5.7.tar.gz

#cd libmcrypt-2.5.7

#./configure --prefix=/usr/local/libmcrypt

#make && make install

#cd ../

#tar zxvf zlib-1.2.8.tar.gz

#cd zlib-1.2.8

#./configure

#make && make install

#cd ../

#xz -d libpng-1.2.56.tar.xz

#tar -xvf libpng-1.2.56.tar

#cd libpng-1.2.56

#./configure --prefix=/usr/local/libpng

#make && make install

#cd ../

#mkdir -p /usr/local/jpeg6/{bin,lib,include,man}

#mkdir /usr/local/jpeg6/man/man1

#tar zxvf jpegsrc.v9b.tar.gz

#cd jpeg-9b/

#./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static

#make && make install

#cd ../

#tar jxvf freetype-2.4.12.tar.bz2

#cd freetype-2.4.12

#./configure -prefix=/usr/local/freetype

#make && make install

#cd ../

#tar zxvf autoconf-2.53.tar.gz

#cd autoconf-2.53

#./configure

#make && make install

#cd ../

#tar jxvf libgd-2.1.1.tar.bz2

#cd libgd-2.1.1

#./configure --prefix=/usr/local/gd2  --with-zlib=/usr/local/zlib --with-jpeg=/usr/local/jpeg6 --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype/

#make && make install

#cd ../

#tar jxvf php-5.6.12.tar.bz2

#cd php-5.6.12

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

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