一、环境配置
1、进入到/opt目录下配置(可以在其他目录下进行)
[[email protected] /]# cd /opt
2、安装插件
[[email protected] opt]# yum install -y lrzsz
[[email protected] opt]# yum install -y links
3、关闭防火墙和selinux
二、安装Apache
1、安装wget links测试工具
[[email protected] /]# yum install -y wget links
2、关闭防火墙与selinux
[[email protected] /]# systemctl stop firewalld
[[email protected] /]# vi /etc/sysconfig/selinux
3、安装编译环境
[[email protected] /]# yum install apr-devel apr-util-devel gcc c ncurses-devel cmake libaio bison gcc-c++ git -y
4、下载好pcre主键,并解压
[[email protected] /]# tar xzf pcre-8.42.tar.gz
5、进入到/usr/src目录中安装插件
[[email protected] /]# cd /usr/src
[[email protected] src]# yum install -y lrzsz
6、传入http包并解压
[[email protected] /]# tar xzf httpd-2.4.43.tar.gz
7、将prce、http文件移动到/usr/src目录下
[[email protected] /]# mv httpd-2.4.43 /usr/src
[[email protected] /]# mv pcre-8.42 /usr/src
8、进入到pcre包内
[[email protected] /]# cd pcre-8.42
预编译:
[[email protected] pcre-8.42]# ./configure --prefix=/usr/local/prce
编译:
[[email protected] pcre-8.42]# make
安装:
[[email protected] pcre-8.42]# make install
9、进入到http包内
[[email protected] src]# cd httpd-2.4.43
预编译:
[[email protected] httpd-2.4.43]# ./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --with-pcre=/usr/local/prce
编译:
[[email protected] httpd-2.4.43]# make
安装:
[[email protected] httpd-2.4.43]# make install
10、修改主配置文件
[[email protected] httpd-2.4.43]# vi /usr/local/apache/conf/httpd.conf
11、启动服务
[[email protected] httpd-2.4.43]# /usr/local/apache/bin//apachectl start
12、将启动文件拷贝到启动目录下
[[email protected] httpd-2.4.43]# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
[[email protected] httpd-2.4.43]# cp /usr/local/apache/bin/apachectl /usr/local/bin/httpd
13、创建软链接,设置自启动
[[email protected] ~]# ln -s /etc/init.d/httpd /etc/rc.d/rc5.d/s61httpd
[[email protected] ~]# ln -s /etc/init.d/httpd /etc/rc.d/rc4.d/s61httpd
[[email protected] ~]# ln -s /etc/init.d/httpd /etc/rc.d/rc3.d/s61httpd
14、编辑启动脚本
[[email protected] ~]# vi /etc/init.d/httpd
15、将服务添加到启动服务中
[[email protected] ~]# chkconfig --add httpd
16、查看服务
[[email protected] ~]# chkconfig --list httpd
17、开启服务
[[email protected] ~]# systemctl restart httpd
18、测试成功
[[email protected] ~]# links http://192.168.6.66
三、安装MySQL
1、解压,并进入其目录
[[email protected] /]# tar xzf mysql-5.5.46.tar.gz
[[email protected] /]# cd mysql-5.5.46
2、预编译
[[email protected] mysql-5.5.46]# 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
3、编译
[[email protected] mysql-5.5.46]# make
4、安装
[[email protected] mysql-5.5.46]# make install
5、进入该目录拷贝配置文件
[[email protected] /]# cd /usr/local/mysql55/support-files/
[email protected] support-files]# cp -f mysql.server /etc/init.d/mysqld
[[email protected] support-files]# cp -f my-large.cnf /etc/my.cnf
6、使其开机自启
[email protected] support-files]# chkconfig --add mysqld
[[email protected] support-files]# chkconfig mysqld on
7、添加用户
[[email protected] support-files]# useradd mysql
8、创建数据库目录
[[email protected] support-files]# mkdir /data/mysql -p
9、连接bin目录
[[email protected] support-files]# /usr/local/mysql55/scripts/mysql_install_db --user=mysql --datadir=/data/mysql/ --basedir=/usr/local/mysql55/
10、创建软链接
[[email protected] support-files]# ln -s /usr/local/mysql55/bin/* /usr/bin/
11、启动服务
[[email protected] support-files]# systemctl restart mysqld
[[email protected] support-files]# ps -ef |grep mysql 查看进程
12、进入数据库
[[email protected] support-files]# mysql
mysql> show databases; 查看数据库表
[[email protected] support-files]# /usr/bin/mysqladmin -u root password ‘123456’ 初始化数据库
[[email protected] support-files]# mysql -h 127.0.0.1 -uroot -p123456 进入数据库
mysql> grant all on . to [email protected]’%’ identified by “123456” ; 授权
mysql> flush privileges; 刷新
13、测试连接成功
四、安装php
1、将php包移动到/opt目录下(其他软件包在根目录下)
[[email protected] /]# mv php-7.2.4.tar.gz /opt
2、解压
[[email protected] opt]# tar xzf php-7.2.4.tar.gz
[[email protected] opt]# yum install -y httpd-devel 安装插件
3、进入到php包内安装
[[email protected] php-7.2.4]# yum -y install php-mcrypt libmcrypt libmcrypt-devel autoconf freetype gd jpegsrc libmcrypt libpng libpng-devel libjpeg libxml2 libxml2-devel zlib curl curl-devel
4、预编译、编译、安装
[[email protected] php-7.2.4]# ./configure --prefix=/usr/local/php7 --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-apxs2=/usr/local/apache/bin/apxs
[[email protected] php-7.2.4]#make
[[email protected] php-7.2.4]#make install
5、编辑配置文件
[[email protected] php-7.2.4]# vi /usr/local/apache/conf/httpd.conf
AddType application/x-httpd-php .php
DirectoryIndex index.html index.php
6、进入目录编辑php文件
[[email protected] php-7.2.4]# cd /usr/local/apache/htdocs/
[[email protected] htdocs]# rm * -rf
[[email protected] htdocs]# vi index.php
7、启动http服务
[[email protected] htdocs]#/usr/local/apache/bin/apachectl start 或
[[email protected] htdocs]# systemctl restart httpd
8、测试连接php成功
[[email protected] htdocs]# links http://192.168.100.66
9、192.168.100.66:8080测试成功
五、部署网站
1、修改配置文件(在末尾添加)
[[email protected] /]# vi /usr/local/apache/conf/httpd.conf
2、编辑虚拟用户配置文件
[[email protected] /]# vi /usr/local/apache/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot “/usr/local/apache/htdocs/discuz/”
ServerName discuz.edu.com
ErrorLog “logs/discuz.edu.com-error_log”
CustomLog “logs/discuz.edu.com-access_log” common
<VirtualHost :80>
DocumentRoot "/usr/local/apache/htdocs/wordpress/"ll
ServerName wordpress.edu.com
ErrorLog “logs/wordpress.edu.com-error_log”
CustomLog “logs/wordpress.edu.com-access_log” common
3、进入到网站目录,删除所有文件,创建虚拟网站目录
[[email protected] /]# cd /usr/local/apache/htdocs
[[email protected] htdocs]# rm -rf *
[[email protected] htdocs]# mkdir discuz wordpress
[[email protected] htdocs]# /usr/local/apache/bin/apachectl restart 重启
4、修改host文件
5、编辑网站首页
[[email protected] htdocs]# vi discuz/index.html
[[email protected] htdocs]# vi wordpress/index.html
6、测试成功
7、部署网站discuz
(1)进入目录
[[email protected] htdocs]# cd /usr/local/apache/htdocs/
(2)将原目录存在的网站文件删除
[[email protected] htdocs]# rm -rf ./discuz/
[[email protected] htdocs]# rm -rf ./wordpress/*
(3)安装解压软件
[[email protected] htdocs]# yum install unzip
[[email protected] /]# unzip Discuz_X3.3_SC_UTF8.zip
(4)拷贝discuz网站到discuz目录
[[email protected] /]# cp -r ./upload/* /usr/local/apache/htdocs/discuz/
(5)给网站目录写入权限递归到子目录
[[email protected] /]# chmod o+w -R /usr/local/apache/htdocs/discuz/
(6)进入测试成功
(wordpress网站部署同上)