L LAMP环境搭建与配置(二)

四 MariaDB安装

1)下载到:cd /usr/local/src

wget https://downloads.mariadb.com/MariaDB/mariadb-10.2.6/bintar-linux-glibc_214-x86_64/mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz

我的用wget下载的比较慢,我用浏览器下载的,再copy到centos上面。

2)解压tar zxvf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz

3)移动到和mysql一个地址

mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb

4)cd /usr/local/mariadb

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

安装成功

5)拷贝配置文件到basedir

cp support-files/my-small.cnf /usr/local/mariadb/my.cnf

拷贝启动文件

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

编辑配置文件

vim /usr/local/mariadb/my.cnf不需要改动

vim /etc/init.d/mariadb,//定义basedir、datadir、conf以及启动参数

改下面两处:

6)启动/etc/init.d/mariadb start

在这里加上datadir=/data/mariadb更改数据mariadb地址

五 安装Apache

Apache是一个基金会的名字,httpd才是我们要安装的软件包,早期它的名字就叫apache

1)下载,Apache官网www.apache.org

wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.28.tar.gz

wget http://mirrors.hust.edu.cn/apache/apr/apr-1.6.3.tar.gz

wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.6.1.tar.gz

apr和apr-util是一个通用的函数库,它让httpd可以不关心底层的操作系统平台,可以很方便地移植(从linux移植到windows)

2)解压

tar zxvf httpd-2.4.28.tar.gz

tar zxvf apr-util-1.6.1.tar.gz

tar zxvf apr-1.6.3.tar.gz

3)选安装apr

cd apr-1.6.3/

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

make && make install

4)cd /usr/local/src/apr-util-1.5.4

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

make && make install

报错:

xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory

#include <expat.h>

^

compilation terminated.

make[1]: *** [xml/apr_xml.lo] Error 1

make[1]: Leaving directory `/usr/local/src/apr-util-1.6.1'

make: *** [all-recursive] Error 1

安装yum install –y expat-devel重新运行以上两步解决问题。

5)cd /usr/local/src/httpd-2.4.27

./configure \ //这里的反斜杠是脱义字符,加上它我们可以把一行命令写成多行

--prefix=/usr/local/apache2.4 \

--with-apr=/usr/local/apr \

--with-apr-util=/usr/local/apr-util \

--enable-so \支持动态扩展模块

--enable-mods-shared=most//表示以共享的方式安装大多数功能模块

 

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

 

解决:yum install –y pcre-devel

make && make install

6)查看安装后的文件

ls /usr/local/apache2.4/modules //下面会列出很多的.so文件,这些文件是enable-mods-shared=most表示以共享的方式安装大多数功能模块。

这些模块并不会全部加载,如果想使用哪个模块,在配置文件里配置即可。

/usr/local/apache2.4/bin/httpd -M //查看加载的模块

7)启动Apache,命令/usr/local/apache2.4/bin/apachectl start

六 安装PHP5

PHP官网www.php.net

当前主流版本为5.6/7.1

1)下载cd /usr/local/src/

wget http://cn2.php.net/distributions/php-5.6.32.tar.gz

2)解压tar zxf php-5.6.32.tar.gz

3)编译cd php-5.6.32

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --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

 

报错1:configure: error: xml2-config not found. Please check your libxml2 installation.

解决:yum install –y libxml2-devel

继续编译报错2:configure: error: Cannot find OpenSSL's <evp.h>

解决:yum install –y openssl-devel

继续编译有报错3:checking for BZip2 in default path... not found

configure: error: Please reinstall the BZip2 distribution

解决:yum install -y bzip2-devel

继续编译报错4:If configure fails try --with-vpx-dir=<DIR>

checking for jpeg_read_header in -ljpeg... yes

configure: error: png.h not found.

解决:yum install –y libpng-devel

继续编译又出错5:If configure fails try --with-xpm-dir=<DIR>

configure: error: freetype-config not found.

解决:yum install -y freetype-devel

继续编译又出错6:configure: error: mcrypt.h not found. Please reinstall libmcrypt.

解决:yum install -y libtomcrypt-devel

如果之前没有安装epel,现在要安装yum install -y epel-release

centos默认yum源没有libtomcrypt-devel这个包,所以稚嫩个借助epel yum扩展源。

继续编译成功。

4)安装

#make && make install

5)查看安装后的文件

/usr/local/php/bin/php –m下的模块都是静态的。

php和Apache结合起来是通过libphp.so文件实现的。

/usr/local/apache2.4/bin/httpd –M查看Apache的模块,发现下面有了php5_module (shared)

命令/usr/local/php/bin/php -i |less可以查看PHP的一些信息

cp php.ini-production /usr/local/php/etc/php.ini

php.ini-production是生产环境,php.ini-development是开发环境,拷贝生产环境就可以了。

自动加载了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值