Centos7.4源码搭建LAMP环境

CENTOS 7.4源码搭建LAMP

目录

一、源码安装apache2.4.33. 2

1.1、使用wget下载号所需的包

1.2、解压源码包并编译安装apache以及所需依赖包

1.3、启动apache服务

二、源码安装mysql

2.1、源码安装mysql

2.2、编译安装完成,对数据库进行初始化

2.3、启动数据库

2.4、创建数据库,给discuz用户授权

三、源码安装PHP并与apache进行整合

四、安装discuz论坛

一、 源码安装apache2.4.33

下载apache源码包,以及apache所依赖的软件包。

Apache源码包:http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.33.tar.bz2

APR:http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.bz2

APRU: http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2

PCRE: https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz

1.1、 使用wget下载号所需的包,如下图所示

Centos7.4源码搭建LAMP环境

1.2、 解压源码包并编译安装apache以及所需依赖包

编译安装apr并指定安装路径

Centos7.4源码搭建LAMP环境

编译安装apru并指定安装路径

Centos7.4源码搭建LAMP环境

编译安装pcre并指定安装路径

Centos7.4源码搭建LAMP环境

编译安装apche并制定安装路径和参数

Centos7.4源码搭建LAMP环境

1.3、 启动apache服务

Centos7.4源码搭建LAMP环境

Centos7.4源码搭建LAMP环境

二、 源码安装mysql

mysql包: http://ftp.jaist.ac.jp/pub/mysql/Downloads/MySQL-5.5/mysql-5.5.60.tar.gz

Centos7.4源码搭建LAMP环境

2.1、源码安装mysql
Centos7.4源码搭建LAMP环境

Centos7.4源码搭建LAMP环境

2.2、编译安装完成,对数据库进行初始化
执行如下命令 \cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf

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

chkconfig --add mysqld

chkconfig --level 35 mysqld on

mkdir /usr/local/mysql/data/mysql

useradd -s /sbin/nologin mysql

chown -R /usr/local/mysql/*

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

ln -s /usr/local/mysql/bin/* /usr/bin/

2.3、启动数据库
启动数据库报错,须在mysql配置文件mysqld添加basedir=/usr/local/mysql/

datadir=/data/mysql/

Centos7.4源码搭建LAMP环境

Centos7.4源码搭建LAMP环境

Centos7.4源码搭建LAMP环境

2.4、创建数据库,给discuz用户授权
Centos7.4源码搭建LAMP环境

Centos7.4源码搭建LAMP环境

三、源码安装PHP并与apache进行整合
PHP源码包: http://cn2.php.net/get/php-5.6.36.tar.bz2/from/this/mirror

Centos7.4源码搭建LAMP环境

源码编译安装PHP并指定参数整合到apache

预编译如果报如线错:

  1. Perl is not installed
  2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
  3. Apache was not built using --enable-so (the apxs usage page is displayed)

则需要修改配置文件/usr/local/apache/bin/apxs将#!/replace/with/path/to/perl/interpreter -w替换为#!/usr/bin/perl -w

安装PHP需要的依赖包: yum install -y libxml2 libxml2-devel

Centos7.4源码搭建LAMP环境

代码如下: ./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/ph/etc --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --enable-cli && make && make install

将PHP与apache整合/usr/local/apache/conf/httpd.conf文件中增加红色标记的代码:

Centos7.4源码搭建LAMP环境

Centos7.4源码搭建LAMP环境

重启apache

在apache的发布目录创建一个php测试脚本

Centos7.4源码搭建LAMP环境

测试php与apache整合成功

Centos7.4源码搭建LAMP环境

四、 安装discuz论坛

Discuz安装包: http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip

Centos7.4源码搭建LAMP环境

将discuz包解压到apache的发布目录将upload目录中的文件移动到apache发布目录:

unzip Discuz_X3.2_SC_UTF8.zip -d /usr/local/apache/htdocs/

Centos7.4源码搭建LAMP环境

使用浏览器安装discuz:http://服务器IP/index.php

Centos7.4源码搭建LAMP环境

Centos7.4源码搭建LAMP环境

需给以上的目录写权限

chmod -R 757 ./config/ ./data/ ./uc_server/ ./uc_client/

刷新后页面正常,无报错。

Centos7.4源码搭建LAMP环境

Centos7.4源码搭建LAMP环境

Centos7.4源码搭建LAMP环境

Centos7.4源码搭建LAMP环境

Centos7.4源码搭建LAMP环境

猜你喜欢

转载自blog.51cto.com/8772980/2136743