使用nginx部署Discuz

首先第一步:

如果有 epel就不需要安装,没有就安装

yum -y install epel-release

安装LNMP架构的依赖:

​
yum -y install make  cmake gcc gcc-c++ flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel gd freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel gettext gettext-devel ncurses-devel gmp-devel unzip libcap lsof  epel-release  autoconf automake pcre-devel libxml2-devel 

​

第二步上传pcre的软件包

对pcre软件包进行解压指定路径

tax  xf pcre-8.41.tar.gz -C /usr/local/src/

第三步创建用户nginx用户

useradd -M -s /sbin/nolgin  nginx   或者useradd -M -s /bin/false nginx

第四步:解压nginx到/usr/local/src文件中

tar xf nginx-1.18.0.tar.gz -C /usr/local/src

cd切换到  /usr/local/src/nginx-1.18.0

使用./configure

 ./configure --prefix=/usr/local/nginx  --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gunzip_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-pcre=/usr/local/src/pcre-8.41 --user=nginx --group=nginx

编译:

make -j 8 && make -j 8 install

 启动nginx服务

进入/usr/local/sbin

使用   ./nginx  -s  reload

安装mysql

第一步:上传mysql安装包

创建mysql用户

useradd -M -s /sbin/nolgin  msyql   或者useradd -M -s /bin/false mysql

指定路径进行解压

tar xf  mysql-5.7.19.tar.gz  -C   /usr/local/src 

第二步:创建安装目录和数据库存放的位置并改权限

mkdir -p /usr/local/mysql

mkdir -p /usr/local/mysql/data

chown -R mysql.mysql /usr/local/mysql 

安装环境

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/src/mysql-5.7.19/boost/boost_1_59_0

先进入cd/usr/local/src/mysql-5.7.19编译:

make -j 8 && make -j 8 install 

mysql的配置文件加上在配置文件/etc/my.cnf

[client]
socket=/usr/local/mysql/mysql.sock
port=3306
[mysqld]
 
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
default-storage-engine=INNODB
character_set_server=utf8mb4
collation_server=utf8mb4_general_ci 
port=3306
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/usr/local/mysql/log/mysqld3306.log
pid-file=/usr/local/mysql/mysqld3306.pid
log_bin=mysql3306-bin
server_id=1
binlog_format=ROW
max_connections = 1000
expire_logs_days = 15
innodb_file_per_table = 1 
innodb_buffer_pool_size = 2048M
innodb_log_file_size = 512M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2
lower_case_table_names=1

创建 日志文件

mkdir /usr/local/mysql/log

chown -R mysql.mysql  /usr/local/mysql/log

生成服务启动脚本

cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysql

chmod +x /etc/init.d/mysql

配置环境变量

使用vim /etc/porfile

export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin

要使其生效使用命令是

source /etc/profile

初始化数据库启动

/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --port=3306

进入cd /usr/local/mysql/data/中

启动:/etc/init.d/mysqld start

修改数据库密码

mysqladmin -u root password "123456"

如果进入成功就说明没有问题

然后安装php

上传或者下载php软件包

然后解压到指定路径

tar zxvf php-7.1.10.tar.gz  -C /usr/local/src/

进入的php-7.1.10目录中

配置环境

./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets --with-pdo-mysql=/usr/local/mysql --with-gd --without-pear --enable-fpm

编译:

make -j 8 &&  make -j 8 install

生成配置文件

cp php.ini-production /usr/local/php/etc/php.ini

创建软连接

ln -s /usr/local/php/bin/* /usr/local/bin/

ln -s /usr/local/php/sbin/* /usr/local/sbin/

nginx连接php需要的启动 php-fpm

cd /usr/local/php/etc/

cp -a php-fpm.conf.default php-fpm.conf

修改php-fpm的配置文件

vim php-fpm.conf

修改指定目录 的参数

pid = run/php-fpm.pid

cd /usr/local/php/etc/php-fpm.d/

cp -a www.conf.default www.conf

 vim www.conf

修改用户主和组 

将nobody修改为nginx

user = nginx

group = nginx

创建脚本:vim nginx_php.sh

#!/bin/bash
#Author:wcfeng
#chkconfig: 2345 88 35
#description: nginx server control tools
ngxc="/usr/local/nginx/sbin/nginx"
pidf="/usr/local/nginx/logs/nginx.pid"
ngxc_fpm="/usr/local/php/sbin/php-fpm"
pidf_fpm="/usr/local/php/var/run/php-fpm.pid"
case "$1" in
start)
$ngxc -t &> /dev/null
if [ $? -eq 0 ];then
$ngxc
$ngxc_fpm
echo "nginx service start success!"
else
$ngxc -t
fi
;;
stop)
kill -s QUIT $(cat $pidf)
kill -s QUIT $(cat $pidf_fpm)
echo "nginx service stop success!"
;;
restart)
$0 stop
$0 start
;;
reload)
$ngxc -t &> /dev/null
if [ $? -eq 0 ];then
kill -s HUP $(cat $pidf)
kill -s HUP $(cat $pidf_fpm)
echo "reload nginx config success!"
else
$ngxc -t
fi
;;
*)
echo "please input stop|start|restart|reload."
exit 1
esac

给脚本权限

 chmod a+x nginx_php.sh 

将脚本复制到/etc/init.d/nginx_php

cp nginx_php.sh /etc/init.d/nginx_php

启动服务:/etc/init.d/nginx_php start

修改nginx配置文件,在vim /usr/local/nginx/conf/nginx.conf文件下添加

location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi.conf;
        }

重启服务

/etc/init.d/nginx_php start

添加php的测试页

 cd /usr/local/nginx/html/

vim index.php 
<?php
   phpinfo();

?>

/etc/init.d/nginx_php stop &&  /etc/init.d/nginx_php start 

最后就是测试

出现这种错误解决办法就是杀死

pkill -9 nginx

pkill -9 php-fpm

然后重启服务就好了

/etc/init.d/nginx_php start

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值