安装Apache
解压工具包
cd /opt
tar xf apr-util-1.6.0.tar.gz
tar xf httpd-2.4.29.tar.bz2
tar xf apr-1.6.2.tar.gz
mv apr-1.6.2 httpd-2.4.29/srclib/apr
mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util
安装编译环境
yum -y install gcc gcc-c++ make pcre-devel expat-devel perl
cd httpd-2.4.29
./configure \
--prefix=/usr/local/httpd \
--enable-so \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi
编译
make && make install
修改配置文件
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
vim /etc/init.d/httpd
添加#号,如下
#chkconfig: 35 85 21
#description: Apache is a World Wide Web server
将httpd服务添加进service便于系统进行管理
chkconfig --add httpd
修改配置文件
vi /usr/local/httpd/conf/httpd.conf
这边进入配置文件进行修改,不是额外添加
ServerName www.yun.com:80
Listen 192.168.139.97:80
配置软连接
ln -s /usr/local/httpd/conf/httpd.conf /etc/
ln -s /usr/local/httpd/bin/* /usr/local/bin/
关闭防火墙和核心防护
systemctl stop firewalld.service
setenforce 0
测试语法
httpd -t
apachectl -t
开启httpd服务
service httpd start
安装MySQL
安装环境包
yum install -y ncurses-devel autoconf cmake
解压缩包
tar xzvf mysql-5.6.26.tar.gz
进行配置
cd mysql-5.6.26
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DSYSCONFIDIR=/etc \
-DMYSQL_DATADIR=/home/mysql/ \
-DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock
编译安装
make && make install
文件覆盖,因为系统中原本就有这个文件
cp support-files/my-default.cnf /etc/my.cnf
托管
cp support-files/mysql.server /etc/init.d/mysqld
权限赋予
chmod +x /etc/rc.d/init.d/mysqld
添加MySQL服务
chkconfig --add /etc/init.d/mysqld
设置开机启动
chkconfig mysqld --level 35 on
添加命令到环境变量中
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile
添加用户
useradd -s /sbin/nologin mysql
修改主组文件
chown -R mysql.mysql /usr/local/mysql/
初始化数据库
/usr/local/mysql/scripts/mysql_install_db \
--user=mysql \
--ldata=/var/lib/mysql \
--basedir=/usr/local/mysql \
--datadir=/home/mysql
编辑文件
vi /etc/init.d/mysqld
修改,如下
basedir=/usr/local/mysql
datadir=/home/mysql
启动
service mysqld start
设置数据库管理员账号密码
mysqladmin -u root -p password "abc123"
安装PHP
安装环境
yum -y install gd libpng libpng-devel pcre pcre-devel libxml2-devel libjpeg-devel
解压缩包
tar xjvf php-5.6.11.tar.bz2
配置
cd php-5.6.11
./configure --prefix=/usr/local/php5 --with-gd --with-zlib --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/ust/local/php5 --enable-mbstaring
编译安装
make && make install
复制
cp php.ini-development /usr/local/php5/php.ini
创建软连接
ln -s /usr/local/php5/bin/* /usr/local/bin/
修改httpd配置文件
vim /etc/httpd.conf
查找命令/AddType,修改如下:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
查找命令/index,修改如下:
Directorylndex index.php index.html
编写一个PHP测试文件
vi /usr/local/httpd/htdocs/index.php
<?php
phpinfo();
?>
重启httpd服务
systemctl restart httpd
网页打开 http://192.168.157.97/index.php
安装BBS论坛
创建数据库
mysql -u root -p
mysql> CREATE DATABASE bbs;
mysql> GRANT all on bbs.* TO 'bbsuser'@'%' IDENTIFIED BY 'admin123';
mysql> flush privileges;
exit
进入 目录,解压缩包
cd /opt
unzip Discuz_X2.5_SC_UTF8.zip -d
将论坛源放入htdocs站点中
cd /opt/dis
cp -r upload/ /usr/local/httpd/htdocs/bbs
赋予权限
cd /usr/local/httpd/htdocs/bbs
chown -R daemon ./config
chown -R daemon ./data
chown -R daemon ./uc_client
chown -R daemon ./uc_server/data