关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
安装软件包
yum -y install pcre-devel zlib-devel gcc gcc-c++ make
上传压缩包解压缩
tar zxvf nginx-1.12.0.tar.gz -C /opt/
创建用户
useradd -M -s /sbin/nologin nginx
# 进入nginx目录中
cd nginx-1.12.0/
# 编译
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module
# 安装
make -j2 && make install
# 软链接到sbin目录
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
# 给文件权限
chmod 754 /lib/systemd/system/nginx.service
systemctl start nginx.service
systemctl enable nginx.service
# 搜索服务
netstat -anpt | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 11805/nginx: master
yum -y install ncurses ncurses-devel bison cmake
创建用户
编码
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=boost \
-DWITH_SYSTEMD=1
安装
make -j8 &&make install
编辑文件
# 内容替换为以下
[client]
port = 3306
socket=/usr/local/mysql/mysql.sock
[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
修改属主属组
chown -R mysql:mysql /usr/local/mysql/
chown mysql:mysql /etc/my.cnf
设置路径环境变量
echo 'export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
source /etc/profile
mysqld \
--initialize-insecure \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
添加服务
# 复制服务文件
cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service
/usr/lib/systemd/system/
# 刷新识别
systemctl daemon-reload
systemctl start mysqld.service
systemctl enable mysqld
授权远程登录
mysql -u root -p
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
上传压缩包并解压缩
./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
安装
主配置文件
# 修改1170行
1170 mysqli.default_socket = /usr/local/mysql/mysql.sock
# 修改939行
939 date.timezone = Asia/Shanghai
进程服务文件
# 修改17行
pid = run/php-fpm.pid
调整扩展配置文件
/usr/local/php/sbin/php-fpm -c /usr/local/php/lib/php.ini
# 查看端口号
netstat -anpt | grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 6903/php-fpm: maste
65 location ~ \.php$ {
66 root html;
67 fastcgi_pass 127.0.0.1:9000;
68 fastcgi_index index.php;
69 fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
70 include fastcgi_params;
71 }
<?php
phpinfo();
?>
http://192.168.253.33/index.php
mysql -u root -p
Enter password: # 输入密码进入mysql
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('192.168.253.33','bbsuser','admin123');
if($link) echo "Success!!
";
else echo "Fail!!";
?>
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/
chown -R root:nginx ./config/
chown -R root:nginx ./data/
chown -R root:nginx ./uc_client/
chown -R root:nginx ./uc_server/
chmod -R 777 ./config/
chmod -R 777 ./data/
chmod -R 777 ./uc_client/
chmod -R 777 ./uc_server/
创建论坛信息
数据库服务器:localhost
数据库名字:bbs
数据库用户名:bbsuser
数据库密码:admin123
管理员账号:admin
管理员密码:admin123