OS status:nginx-1.10.2 php-5.6.29 Discuz_X3.2 mariadb-10.1.19
安装nginx
创建运行nginx用户
[root@linuxea-com ~]# groupadd -r -g 499 nginx
[root@linuxea-com ~]# useradd -u 499 -s /sbin/nologin -c 'web server' -g nginx nginx -M
下载nginx
[root@linuxea-com ~]# cd /usr/local
[root@linuxea-com /usr/local]# curl -s http://nginx.org/download/nginx-1.10.2.tar.gz -o/usr/local/nginx-1.10.2.tar.gz
解压
[root@linuxea-com /usr/local]# cd /usr/local && tar xf nginx-1.10.2.tar.gz && rm -rf nginx-1.10.2.tar.gz
安装依赖包
[root@linuxea-com /usr/local]# yum install openssl-devel pcre pcre-devel gcc make -y
开始编译
[root@linuxea-com /usr/local]# cd nginx-1.10.2 && ./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --user=nginx --group=nginx --error-log-path=/data/logs/nginx/error.log --http-log-path=/data/logs/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_mp4_module --with-http_realip_module --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi && make && make install
创建所需的目录
[root@linuxea-com /usr/local]# mkdir -p /var/tmp/nginx/{client,fastcgi,proxy,uwsgi} /data/logs/nginx /data/wwwroot
下载配置文件
[root@linuxea-com /usr/local]# rm -rf /etc/nginx/nginx.conf
[root@linuxea-com /usr/local]# curl -Lks4 https://raw.githubusercontent.com/LinuxEA-Mark/nmp/master/nginx.conf -o /etc/nginx/nginx.cnf
下载启动脚本
[root@linuxea-com /usr/local]# curl -Lks4 https://raw.githubusercontent.com/LinuxEA-Mark/nmp/master/nginx -o /etc/init.d/nginx && chmod +x /etc/init.d/nginx
安装php-fpm
php install
下载php
[root@linuxea-com /usr/local]# curl -s http://tw1.php.net/distributions/php-5.6.29.tar.gz -o /usr/local/php-5.6.29.tar.gz && cd /usr/local
解压
[root@linuxea-com /usr/local]# tar xf php-5.6.29.tar.gz && rm -rf php-5.5.26.tar.gz
[root@linuxea-com /usr/local]# cd php-5.6.29
创建php用户
[root@linuxea-com /usr/local]# groupadd -g 498 -r php-fpm && useradd -u 498 -g php-fpm -r php-fpm -s /sbin/nologin
安装依赖包
[root@linuxea-com /usr/local]# yum install epel-release -y && yum install -y gcc automake autoconf libtool make libxml2-devel openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel libcurl-devel libcurl libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt-devel libmcrypt libtool-ltdl-devel libxslt-devel mhash mhash-devel axel
编译安装:
[root@linuxea-com /usr/local]# cd php-5.6.29 && ./configure --prefix=/usr/local/php --disable-pdo --disable-debug --disable-rpath --enable-inline-optimization --enable-sockets --enable-sysvsem--enable-sysvshm --enable-pcntl --enable-mbregex --enable-xml --enable-zip --enable-fpm --enable-mbstring --with-pcre-regex --with-mysql --with-mysqli --with-gd --with-jpeg-dir --with-bz2 --with-zlib --with-mhash --with-curl --with-mcrypt --with-jpeg-dir --with-png-dir && make && make install
创建日志路径
[root@linuxea-com /usr/local]# mkdir /data/logs/php-fpm
复制php.ini文件
[root@linuxea-com /usr/local]# cp /usr/local/php-5.6.29/php.ini-production /usr/local/php/lib/php.ini
修改php.ini时区
[root@linuxea-com /usr/local]# sed -i 's/;date.timezone =/date.timezone = Asia/Shanghai/' /usr/local/php/lib/php.ini
下载php启动文件
[root@linuxea-com /usr/local]# curl -Lks4 https://raw.githubusercontent.com/LinuxEA-Mark/nmp/master/php-fpm -o /etc/init.d/php-fpm && chmod +x /etc/init.d/php-fpm
下载php-fpm.conf配置文件
[root@linuxea-com /usr/local]# curl -Lks4 https://raw.githubusercontent.com/LinuxEA-Mark/nmp/master/php-fpm.conf -o /usr/local/php/etc/php-fpm.conf
安装mariadb
安装mariadb
下载mariadb
[root@linuxea-com /usr/local]# cd /usr/local && axel -n 30 http://sgp1.mirrors.digitalocean.com/mariadb//mariadb-10.1.19/bintar-linux-x86_64/mariadb-10.1.19-linux-x86_64.tar.gz
解压
[root@linuxea-com /usr/local]# tar xf mariadb-10.1.19-linux-x86_64.tar.gz && ln -s mariadb-10.1.19-linux-x86_64 mysql
创建用户
[root@linuxea-com /usr/local]# groupadd -g 497 -r mysql && useradd -u 497 -g mysql -r mysql -s /sbin/nologin && mkdir /data/mysql
开始二进制安装
[root@linuxea-com /usr/local]# cd mysql && scripts/mysql_install_db --user=mysql --datadir=/data/mysql
修改权限
[root@linuxea-com /usr/local]# chown -r mysql.mysql /data/mysql
复制启动脚本
[root@linuxea-com /usr/local]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld && chown +x /etc/init.d/mysqld
#cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
下载mysql配置文件
[root@linuxea-com /usr/local]# curl -Lks4 https://raw.githubusercontent.com/LinuxEA-Mark/nmp/master/my.cnf -o /etc/my.cnf
创建mysql软连接
[root@linuxea-com /usr/local]# ln -s /usr/local/mysql/bin/mysql /usr/bin/
启动mysql ,nginx ,php-fpm
[root@linuxea-com /usr/local]# systemctl start mysqld && systemct start nginx && systemcrt start php-fpm
授权数据库
数据库授权
[root@linuxea-com /usr/local]# mysql -e "DELETE FROM mysql.user WHERE User='';"
[root@linuxea-com /usr/local]# mysql -e "DELETE FROM mysql.db WHERE Db LIKE 'test%';"
[root@linuxea-com /usr/local]# mysql -e "DROP DATABASE test;"
创建库bbs,密码8K79Xucb5uXC,root密码:abc8K7123
[root@linuxea-com /usr/local]# mysql -e "CREATE DATABASE bbs charset='utf8';"
[root@linuxea-com /usr/local]# mysql -e "GRANT ALL PRIVILEGES ON bbs.* To 'bbs'@'%' IDENTIFIED BY '8K79Xucb5uXC';"
[root@linuxea-com /usr/local]# mysql -e "UPDATE mysql.user SET password = password('abc8K7123') WHERE user = 'root';"
[root@linuxea-com /usr/local]# mysql -e "flush privileges;"
[root@linuxea-com /usr/local]# myqsl -uroot -pabc8K7123 -e "flush privileges;"
部署discuz
下载Discuz
[root@linuxea-com /usr/local]# cd /data/wwwroot
[root@linuxea-com /data/wwwroot]# wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip && unzip Discuz_X3.2_SC_UTF8.zip
删除一些无用的文件[root@linuxea-com /data/wwwroot]# rm -rf readme utility/ Discuz_X3.2_SC_UTF8.zip
将网页文件复制到当前目录并修改权限[root@linuxea-com /data/wwwroot]# mv upload/* ./ && chown -R nginx.nginx /data/wwwroot/
打开web输入ip,同意即可下一步,通常这一步也不会报错下一步,全新安装输入之前创建的库和账号密码和论坛邮箱密码安装完成登录
源图片的路径存放在网站根目录data/attachment/forum/下
[root@DS-VM-Node49 /data/wwwroot]# ll data/attachment/forum/201612/16/114158ponqltotvq9ouuwl.jpg
-rw-r--r-- 1 nginx nginx 68028 12月 16 11:41 data/attachment/forum/201612/16/114158ponqltotvq9ouuwl.jpg
[root@DS-VM-Node49 /data/wwwroot]#
删掉安装目录 rm -rf install/
开启伪静态
开启伪静态:如图所示点击查看当前的 Rewrite 规则URL,在弹出的新页面中,复制nginx配置的server段中,如下图所示在重新加载配置/etc/init.d/nginx reload.如下图所示: