环境配置
从官网下载稳定的源码包
解压
预编译
编译
编译安装
启动服务

环境配置

# yum install -y vim wget links //安装一下基本工具
# systemctl stop firewalld //关防火墙
# setenforce 0 //关SELinux
# yum install apr-devel apr-util-devel gcc c ncurses-devel cmake libaio bison gcc-c++ git -y //安装编译所需

第一步源码安装apache

# cd /usr/src/ //进入这个目录
# wget https://sourceforge.net/projects/pcre/files/pcre/8.42/pcre-8.42.tar.gz //下载
# tar xzf pcre-8.42.tar.zg //解压
# cd pcre-8.42 //进入目录
# ./configure –prefix=/usr/local/pcre //预编译
# make //编译成二进制文件
# make install //安装

# cd /usr/src/ //进入这个目录
# wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.29.tar.gz //下载httpd
# tar xzf httpd-2.4.29 //解压
# cd httpd-2.4.29 //进入目录
# ./configure –prefix=/usr/local/apache –enable-so –enable-rewrite –with-pcre=/usr/local/pcre //预编译
# make //编译
# make install //编译安装

# sed -i ‘/:80/aServerName localhost:80’ /usr/local/apache/conf/httpd.conf //
# /usr/local/apache/bin/apachectl start //启动httpd
# links http://192.168.1.18 //把ip换成自己的IP地址,成功显示“It works!”

第二部源码安装MySQL

# cd /usr/src //进入这个目录
# wget http://down1.chinaunix.net/distfiles/mysql-5.5.20.tar.gz //下载mysql
# tar xzf mysql-5.5.20.tar.gz //解压
# cd mysql-5.5.20 //进入目录
# yum install apr-devel apr-util-devel gcc c ncurses-devel cmake libaio bison gcc-c++ git -y
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql55/ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DWITH_XTRADB_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DWITH_EXTRA_CHARSETS=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BIG_TABLES=1 -DWITH_DEBUG=0
# make //编译
# make install //编译安装
#
配置
# cd /usr/local/mysql55 //进入这个目录
# \cp -f support-files/my-large.cnf /etc/my.cnf //拷贝配置文件
# \cp -f support-files/mysql.server /etc/init.d/mysqld //拷贝配置文件
# chkconfig –add mysqld //创建开机启动
# chkconfig –level 35 mysqld on //开机启动权限35
# mkdir -p /data/mysql //创建mysql数据目录
# useradd mysql //创建mysql用户
# /usr/local/mysql55/scripts/mysql_install_db –user=mysql –datadir=/data/mysql/ –basedir=/usr/local/mysql55/ //配置mysql参数
# ln -s /usr/local/mysql55/bin/* /usr/bin/ //连接bin目录
# service mysqld start //启动
# ps -ef|grep mysql //查看启动进程

# mysql //登录数据库
# show databases; //列出数据库
# exit //退出数据库
# /usr/bin/mysqladmin -u root password ‘root’ //初始化数据库,

php源码安装
# cd /usr/src/ //进入这个目录
# wget http://mirrors.sohu.com/php/php-7.2.4.tar.gz //下载php源码包
# tar xzf php-7.2.4.tar.g //加压php
# cd php-7.2.4 //进入php目录
# yum -y install php-mcrypt libmcrypt libmcrypt-devel autoconf freetype gd jpegsrc libmcrypt libpng libpng-devel libjpeg libxml2 libxml2-devel zlib curl curl-devel //不懂为啥安装这个,照做就行
# ./configure –prefix=/usr/local/php7 –with-mysql=mysqlnd –with-mysqli=mysqlnd –with-pdo-mysql=mysqlnd –with-apxs2=/usr/local/apache/bin/apxs(apx是和Apache通讯的) //预编译
# make
# make install
#
# vim /usr/local/apache/conf/httpd.conf //编辑httpd配置文件
添加一行
AddType application/x-httpd-php .php
# /index.html //查找到index.html,在后面添加index.php
# cd /usr/local/apache/htdocs/ //进入httpd
# rm * -rf
# vim inedx.php //添加<?php phpinfo();?>

/usr/local/apache/bin/apachectl start //启动httpd
# links http://192.168.1.18 //测试php是否工作正常

开启虚拟网站

# vim /usr/local/apache/conf/httpd.conf //编辑httpd配置文件开启虚拟网站配置文件
在末行添加下面配置
Include conf/extra/httpd-vhosts.conf

# vim /usr/local/apache/conf/extra/httpd-vhosts.conf //编辑虚拟用户配置文件
删除默认的两个虚拟机,直接复制如下配置
<VirtualHost *:80>
DocumentRoot “/usr/local/apache/htdocs/discuz/”
ServerName discuz.jfedu.com
ErrorLog “logs/discuz.jfedu.com-error_log”
CustomLog “logs/discuz.jfedu.com-access_log” common
</VirtualHost>

<VirtualHost *:80>
DocumentRoot “/usr/local/apache/htdocs/wordpress/”
ServerName wordpress.jfedu.com
ErrorLog “logs/wordpress.jfedu.com-error_log”
CustomLog “logs/wordpress.jfedu.com-access_log” common
</VirtualHost>

#
# cd /usr/local/apache/htdocs //进入网站目录
# rm -rf* //删除网站目录下所有文件
# mkdir discuz wordpress //创建连个虚拟网站的目录
# /usr/local/apache/bin/apachectl restart //如果能成功重启httpd,不报错就说明配置文件没有问题,你没有偏差

为了测试虚拟网站能不能正常工作,需要修改宿主机下的hosts配置文件,文件地址如下
C:\Windows\System32\drivers\etc\hosts

在宿主机的hosts文件里面添加:
192.168.1.18 discuz.jfedu.com
192.168.1.18 wordpress.jfedu.com
#
# vim discuz/index.html //添加discuz
# vim wordpress/index.html //添加wordpress
#
在宿主机访问:discuz.jfedu.com,wordpress.jfedu.com会出现不同的内容。如果测试成功。那么虚拟机配置也没有问题

部署网站-discuz
# cd /usr/local/apache/htdocs/
# rm -rf ./discuz/*
# rm -rf ./wordpress/*
# wget http://download.comsenz.com/DiscuzX/3.3/Discuz_X3.3_SC_UTF8.zip
# yum install unzip //安装解压软件
# unzip Discuz_X3.3_SC_UTF8.zip //解压网站
# cp -r ./upload/* /usr/local/apache/htdocs/discuz/ //拷贝discuz网站到discuz目录
# chmod o+w -R /usr/local/apache/htdocs/discuz/ //给网站目录写入权限递归到子目录
在宿主机中打开discuz.jfedu.com,全部默认操作。下一步、下一步。

部署网站-wordpress
# wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz //
# tar xzf wordpress-4.9.4-zh_CN.tar.gz //
# cp -r ./wordpress/* /usr/local/apache/htdocs/wordpress/ //
# chmod -R o+w /usr/local/apache/htdocs/wordpress/ //
# mysql -u root -p //登录数据库,密码root
# create database wordpress charset=utf8; //添加一个表
# grant all on wordpress.* to root@’localhost’ identified by “root”; //
# quit //
#
#

实验结束:
最后用客户端访问即可

版权声明:本文为fengdejiyixx原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/fengdejiyixx/p/9028348.html