[root@localhost opt]#tar zxf apr-1.6.2.tar.gz
[root@localhost opt]#tar zxf apr-util-1.6.0.tar.gz
[root@localhost opt]#tar jxf httpd-2.4.29.tar.bz2
[root@localhost opt]#cd httpd-2.4.29/
[root@localhost httpd-2.4.29]#yum -y install \> gcc \ #C语言的编译器
> gcc-c++ \ #C++的编译器
> make \
> pcre-devel \ #perl的接口开发包
> expat-devel \ #用于支持网站解析HTML、XML文件
> perl #perl语言编译器
[root@localhost httpd-2.4.29]# ./configure \
> --prefix=/usr/local/httpd \
> --enable-so \
> --enable-rewrite \
> --enable-charset-lite \
> --enable-cgi \
> --enable-deflate
##复制
[root@localhost bin]#cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
##修改脚本
[root@localhost bin]#vim /etc/init.d/httpd
# chkconfig: 35 85 21 //35级别自动运行 第85个启动 第21个关闭
# description: Apache is a World Wide Web server
#//将httpd加入到SERVICE管理器
[root@localhost bin]#chkconfig --add httpd
##修改配置文件
[root@localhost bin]#vi /usr/local/httpd/conf/httpd.conf
注释掉52行,修改第51行
#51行,监听地址为自己的ip地址
Listen 192.168.192.10:80
#197行
ServerName www.yxp.com:80
[root@localhost bin]#ln -s /usr/local/httpd/conf/httpd.conf /etc/
[root@localhost bin]#ln -s /usr/local/httpd/bin/* /usr/local/bin/
[root@localhost bin]#systemctl stop firewalld.service
[root@localhost bin]#setenforce 0
[root@localhost bin]#httpd -t
Syntax OK #说明语法没问题
#开启服务
[root@localhost bin]#service httpd start
[root@localhost bin]#netstat -anpt | grep 80
tcp 0 0 192.168.59.105:80 0.0.0.0:* LISTEN 39007/httpd
[root@localhost opt]#yum install -y ncurses-devel autoconf cmake
[root@localhost opt]#tar zxf mysql-5.7.17.tar.gz
[root@localhost opt]#cd mysql-5.6.26/ #切换解压后的至目录
[root@localhost mysql-5.6.26]#cmake \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DDEFAULT_CHARSET=utf8 \
#指定默认使用的字符集编码,如 utf-8
> -DDEFAULT_COLLATION=utf8_general_ci \
#指定默认使用的字符集校对规则
> -DEXTRA_CHARSETS=all \
#指定支持其他字符集编码
> -DSYSCONFIDIR=/etc \
#/etc/mysql --->系统中有一个默认的配置/etc/my.cnf
> -DMYSQL_DATADIR=/home/mysql/ \
#数据文件
> -DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock
#指定连接数据库的通讯文件(启动数据库的时候会生成)
#安装过程会有点漫长,请耐心等待
[root@localhost opt]#make && make install -j4
useradd -M -s /sbin/nologin mysql
[root@localhost mysql-5.7.17]#source /etc/profile
[root@localhost mysql-5.7.17]#echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin
[root@localhost mysql-5.7.17]#
/usr/local/mysql/scripts/mysql_install_db \
--user=mysql \
--ldata=/var/lib/mysql \
--basedir=/usr/local/mysql \
--datadir=/home/mysql
#修改配置文件
[root@localhost mysql-5.7.17]#vim /etc/init.d/mysqld
##修改46,47行
basedir=/usr/local/mysql
datadir=/home/mysql
#启动mysql
[root@localhost mysql-5.7.17]#service mysqld start
Starting MySQL. SUCCESS!
[root@localhost mysql-5.7.17#ss -ntap|grep "3306"
LISTEN 0 80 :::3306 :::* users:(("mysqld",pid=55337,fd=10))
[root@localhost mysql-5.7.17]#
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
cd /opt
tar jxvf php-7.1.10.tar.bz2
cd php-7.1.10
./configure \
--prefix=/usr/local/php \
--with-mysql-sock=/usr/local/mysql/mysql.sock \
--with-mysqli \
--with-zlib \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-openssl \
--enable-fpm \
--enable-mbstring \
--enable-xml \
--enable-session \
--enable-ftp \
--enable-pdo \
--enable-tokenizer \
--enable-zip
make && make install
ln -s /usr/local/php/bin/* /usr/local/bin/
ln -s /usr/local/php/sbin/* /usr/local/sbin/
php有三个配置文件:
php.ini 主配置文件
php-fpm.conf 进程服务配置文件
www.conf 扩展配置文件
#调整主配置文件:
cp /opt/php-7.1.10/php.ini-development /usr/local/php/lib/php.ini
vim /usr/local/php/lib/php.ini
--1170行--修改
mysqli.default_socket = /usr/local/mysql/mysql.sock
--939行--取消注释,修改
date.timezone = Asia/Shanghai
php -m #验证安装的模块
#调整进程服务配置文件:
cd /usr/local/php/etc/
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf
--17行--去掉";"注释
pid = run/php-fpm.pid
#调整扩展配置文件:
cd /usr/local/php/etc/php-fpm.d/
cp www.conf.default www.conf
/usr/local/php/sbin/php-fpm -c /usr/local/php/lib/php.ini
netstat -anpt | grep 9000
#PHP-FPM(FastCGI Process Manager:FastCGI 进程管理器)是一个 PHPFastCGI 管理器, 由于Nginx服务器不能处理动态页面,需要由 Nginx 把动态请求交给 php-fpm 进程进行解析。
cd /opt/php-7.1.10/sapi/fpm
cp php-fpm.service /usr/lib/systemd/system/php-fpm.service
systemctl restart php-fpm.service
vim /usr/local/nginx/conf/nginx.conf
--65行--取消注释,修改
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; #将 /scripts 修改为nginx的工作目录
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #$document_root 代表当前请求在root指令中指定的值
include fastcgi_params;
}
systemctl restart nginx.service
vim /usr/local/nginx/html/index.php
<?php
phpinfo();
?>
mysql -u root -p
CREATE DATABASE bbs;
GRANT all ON bbs.* TO 'bbsuser'@'%' IDENTIFIED BY 'admin123';
GRANT all ON bbs.* TO 'bbsuser'@'localhost' IDENTIFIED BY 'admin123';
flush privileges;
vim /usr/local/nginx/html/index.php #替换原来的测试页内容
<?php
$link=mysqli_connect('172.16.10.101','bbsuser','admin123');
if($link) echo "Success!!
";
else echo "Fail!!";
?>
浏览器访问
http://172.16.10.101/index.php
cd /opt
unzip Discuz_X3.4_SC_UTF8.zip -d /opt/dis
cd /opt/dis/dir_SC_UTF8/
cp -r upload/ /usr/local/nginx/html/bbs/
cd /usr/local/nginx/html/bbs/
chmod -R 777 ./config/
chmod -R 777 ./data/
chmod -R 777 ./uc_client/
chmod -R 777 ./uc_server/
数据库服务器:localhost ###本地架设就用localhost,如何不是在在本机上就要填写IP地址和端口号
数据库名字:bbs
数据库用户名:bbsuser
数据库密码:admin123
管理员账号:admin
管理员密码:admin123