目录
一、安装Apache
1.cd 到opt目录下面,将压缩包拉进Xhell
2.解压缩apr和httpd压缩包
tar xf apr-1.6.2.tar.gz
tar xf apr-util-1.6.0.tar.gz
tar xf httpd-2.4.29.tar.bz2
3.将apr-1.6.2 移动到httpd-2.4的srclib的apr目录下
mv apr-1.6.2 httpd-2.4.29/srclib/apr
4.将apr-2.4 移动到srclib的apr-util目录下
mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util
5.然后移动到httpd-.4.29下面,并且要安装相关依赖包
cd httpd-2.4.29/
yum install gcc gcc-c++ make pcre pcre-devel expat-devel perl -y
6.编辑一些配置
./configure --prefix=/usr/local/httpd \
--enable-so \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi
7.然后安装,因为我有4核,所以make -j 4
make -j 4 && make install
8.切换目录
cd /usr/local/httpd
cd conf/
9.做软链接
ln -s /usr/local/httpd/conf/httpd.conf /etc/
ln -s /usr/local/httpd/bin/* /usr/local/bin/
10.做验证,看命令可不可以用
11.下面开始加入系统服务
cd /lib/systemd/system
将下面内容填写到httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/httpd/logs/httpd.pid
ExecStart=/usr/local/bin/apachectl $OPTIONS
ExecReload=/bin/kill -HUP $MAINPID
systemctl start httpd.service //启动服务
12.切换目录,做备份
cd /usr/local/httpd/conf/
cp httpd.conf{,_bak}
13.修改httpd.conf的配置文件
vim httpd.conf
14.
ls /usr/local/httpd/htdocs/
cat /usr/local/httpd/htdocs/index.html
netstat -antulp|grep 80
15.接下来可以登录192.168.234.55登录看看
二、安装Mysql
1.安装依赖包
yum install ncurses ncurses-devel bison cmake -y
2.创建程序用户管理
useradd -s /sbin/nologin mysql
3.然后我们再解压自己的包(注意在有压缩包的目录下面)
tar zxvf mysql-5.7.17.tar.gz
tar zxvf boost_1_59_0.tar.gz
4.移动目录
mv boost_1_59_0 /usr/local/boost
5.去mysql目录下,安装东西
cd mysql-5.7.17/
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DSYSCONFDIR=/etc \
-DSYSTEMD_PID_DIR=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_BOOST=/usr/local/boost \
-DWITH_SYSTEMD=1
最后安装
make && make install
6.要给权限
chown -R mysql:mysql /usr/local/mysql/
chown mysql:mysql /etc/my.cnf
7.修改配置文件
vim /etc/my.cnf
------------------------------
[client]
port = 3306
default-character-set=utf8
socket=/usr/local/mysql/mysql.sock
[mysql]
port = 3306
default-character-set=utf8
socket=/usr/local/mysql/mysql.sock
auto-rehash
[mysqld]
user = mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port = 3306
character-set-server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket=/usr/local/mysql/mysql.sock
bind-address = 0.0.0.0
skip-name-resolve
max_connections=2048
default-storage-engine=INNODB
max_allowed_packet=16M
server-id = 1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES
8.设置环境变量,申明/宣告mysql命令便于系统识别
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile
9.初始数据库
cd /usr/local/mysql/bin/
./mysqld \
--initialize-insecure \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
10.
cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
systemctl daemon-reload #刷新识别
systemctl start mysqld.service #开启服务
systemctl enable mysqld #开机自启动
netstat -anpt | grep 3306 #查看端口
11.#给root账号设置密码
mysqladmin -u root -p password "123456"
————》直接回车
12.可以用这个远程登录试一下
mysql -u root -p
三、安装PHP
1.先安装各种依赖包
yum -y install \
gd \
libjpeg libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libxml2 libxml2-devel \
zlib zlib-devel \
curl curl-devel \
openssl openssl-devel
2.去压缩包的所在目录,解压缩,不要忘记后缀tar.gz
cd /opt
tar zxvf php-7.1.24.tar.gz
3.移动到php-7.1.24,然后配置,然后安装
cd /opt/php-7.1.24/
./configure \
--prefix=/usr/local/php7 \
--with-apxs2=/usr/local/httpd/bin/apxs \
--with-mysql-sock=/usr/local/mysql/mysql.sock \
--with-config-file-path=/usr/local/php7 \
--with-mysqli \
--with-zlib \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-openssl \
--enable-mbstring \
--enable-xml \
--enable-session \
--enable-ftp \
--enable-pdo \
--enable-tokenizer
make && make install
4.复制模板文件,并修改
cp /opt/php-7.1.24/php.ini-development /usr/local/php/php.ini
vim /usr/local/php/php.ini
--1170行--修改
mysqli.default_socket = /usr/local/mysql/mysql.sock
--939行--取消注释,修改
date.timezone = Asia/Shanghai
5.做软连接
ln -s /usr/local/php/bin/* /usr/local/bin/
6.修改Apache配置文件让Apache支持PHP
vi /etc/httpd.conf
#添加index.php
255 <IfModule dir_module>
256 DirectoryIndex index.html index.php
257 </IfModule>
#在392行下方插入一下内容,让Apache可以支持.php的网页文件
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
##检查156行默认支持php7的模块是否存在
LoadModule php7_module modules/libphp7.so
wq保存
7.创建、编辑php页面文件,并且重启http服务
rm -rf /usr/local/httpd/htdocs/index.html
vim /usr/local/httpd/htdocs/index.php
<?php
phpinfo();
?>
8.最后可以在网页测试
http://192.168.234.55/index.php
四、安装论坛
1.首先切换到opt下面,给解压压缩包
cd /opt/
unzip Discuz_X3.4_SC_UTF8.zip -d /opt/dis
2.移动但dir_的目录,进入mysql数据库
cd dis/
cd dir_SC_UTF8/
mysql -u root -p123456
3.查看当前数据库有哪些,并创建一个新的数据库
show databases;
create database bbs;
4.把bbs数据库里面所有表的权限授予给bbsuser,并设置密码,刷新数据库
grant all on bbs.* TO 'bbsuser'@'%' identfied by 'admin123';
flush privileges;
5.退出,拷贝文件
exit
cp -r upload/ /usr/local/httpd/htdocs/bbs
6.切换论坛目录
cd /usr/local/httpd/htdocs/bbs
7.然后切到浏览器,安装
http://192.168.234.55/bbs/install/
8.有很多东西不能写,要自己授权
chown -R daemon ./config
chown -R daemon ./data
chown -R daemon ./uc_client
chown -R daemon ./uc_server/data
然后就可以就可写了
9.模拟按照这个配置
数据库服务器: localhost #本地架设就用localhost,如何不是在在本机上就要填写IP地址和端口号
数据库名字: bbs
数据库用户名: bbsuser
数据库密码: admin123
管理员账号: admin
管理员密码: admin123
10.最后登录一下
http://192.168.10.80/bbs/