Linux release 7.9+nginx/1.18.0+PHP 7.1.20+mysql-5.5.32+discuz3.4完美搭建(SSL+http重定向需要扩展)

网友投稿 1124 2022-10-11

Linux release 7.9+nginx/1.18.0+PHP 7.1.20+mysql-5.5.32+discuz3.4完美搭建(SSL+http重定向需要扩展)

Linux release 7.9+nginx/1.18.0+PHP 7.1.20+mysql-5.5.32+discuz3.4完美搭建(SSL+http重定向需要扩展)

最近搭建了一个公司自己的BBS论坛。纯属学习。希望大家多多支持我的BBS。

​​release 7.9+nginx/1.18.0+mysql-5.5.32+PHP 7.1.20

linux的搭建,我就不说了吧!我是按的传统分区,空间也不是很大。

sawp  /boot  /  就三个分区,没有分/home 。

大概就是这样。

-------------------------------------------------------------------------------------------------------------------------------

wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gzwget xf nginx-1.18.0.tar.gz

cd nginx-1.18.0/

useradd nginx -s /sbin/nologin -M

这是nginx编译安装的参数。

./configure --prefix=/application/nginx-1.6.2 --user=nginx --group=nginx --with---with-&& make install

echo $?

没问题nginx就安装好了。

我把nginx里的一些配置文件发布出来。

nginx.conf

worker_processes 2;events { worker_connections 1024;}{ include mime.types; default_type application/octet-stream; error_log logs/error.log error; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$' '"$"$ sendfile on; keepalive_timeout 65; #nginx vhosts config include extra/conf; include extra/bbs.conf; include extra/blog.conf; include extra/status.conf;}

然后就是bbs.conf

server { listen 8800; server_name 域名; root html/bbs; location / { index index.php index.html index.htm; } location ~ .*\.(php|php5)?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } access_log logs/access_bbs.log main; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }

nginx就安装好了,到这里大家就测试一下。

然后就是mysql.

大家参考博文、

最后是php。

php还是挺麻烦的,我找了好多资料,因为安装的7.1.20的版本还比较新吧!

先安装php一些必要安装的组件 libiconv-1.14。

tar xf libiconv-1.14.tar.gzlsmv libiconv-1.14 /application/ln -s /application/libiconv-1.14/ /application/libiconvcd /application/cd libiconv./configure --prefix=/usr/local/libiconvecho $?

make && make installecho $?

-------------------------------------------------------------------------------------

yum install zlib-devel libxml2-devel libjpeg-devel libiconv-develyum install freetype-devel libpng-devel gd-devel curl-devel libxslt-develyum install libcurl-devdel libmcrypt-devel mhash mcryptyum install libxslt-devel libmcrypt-develyum install libtool-ltdl.x86_64 libtool-ltdl-devel.x86_64yum install libxslt-devel libmcrypt-develyum install libcurl-devdel libmcrypt-devel mhash mcrypt

yum install libxslt-devel libmcrypt-develyum install libcurl-devdel libmcrypt-devel mhash mcrypt

差不多行了。

tar xf php-7.1.20.tar.gz

cd php-7.1.20/

cd ext/phar/

touch /software/php-7.1.20/ext/phar/phar.phar

echo "/application/mysql/lib" >>/etc/ld.so.conf.d/mysql.conf

cat /etc/ld.so.conf.d/mysql.conf

ldconfig

yum install glibc-headersyum install gcc-c++

yum install libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel mhash autoconf

wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz

cd libmcrypt-2.5.7

./configure --prefix=/usr/local/lib/libmcryptecho $?make && make install

源码安装php7.1.20

cd php-7.1.20/

./configure --prefix=/application/php-7.1.20 --with-config-file-path=/etc --with-mysql=/application/mysql --enable-fpm --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-libxml-dir --with-xmlrpc --with-openssl --with-mcrypt --with-mhash --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear --enable-opcache=yes

echo $?make && make install

cd /application/php/cd etccp php-fpm.conf.default php-fpm.confcd php-fpm.d/lscp conf.default conf

启动php

/application/php/sbin/php-fpm

lsof -i:9000

检查。

设置nginx和php开机启动。

ls /lib/systemd/system/nginx.servicetouch /lib/systemd/system/nginx.servicevim systemctl start nginx.servicelsof -i:80systemctl enable nginx.service

以下是nginx.service

[Unit]Description=nginx serviceAfter=network.target[Service]Type=forkingExecStart=/application/nginx/sbin/nginxExecReload=/application/nginx/sbin/nginx -s reloadExecStop=/application/nginx/sbin/nginx -s quitPrivateTmp=true[Install]WantedBy=multi-user.target

php开机启动

which php-fpmfind / -name php-fpm.confcat /application/php-7.1.20/etc/php-fpm.conf|grep pidls /etc/systemd/system/php-fpm.servicevim /etc/systemd/system/php-fpm.servicesystemctl stop php-fpmlsof -i:9000systemctl stop php-fpm.servicels /etc/systemd/system/php-fpm.servicecat /etc/systemd/system/php-fpm.servicelsof -i:9000killall php-fpmlsof -i:9000systemctl start php-fpm.servicelsof -i:9000systemctl enable php-fpm.servicelsof -i:9000

以下是php-fpm.service

[Unit]Description=The PHP FastCGI Process ManagerAfter=syslog.target network.target[Service]Type=simplePIDFile=run/php-fpm.pidExecStart=/application/php/sbin/php-fpm --nodaemonize --fpm-config /application/php/etc/php-fpm.confExecReload=/bin/kill -USR2 $MAINPIDExecStop=/bin/kill -SIGINT $MAINPID[Install]WantedBy=multi-user.target

lnmp环境搭建好,没有了问题,就可以安装discuz了。

discuz安装好了,就要做一些简单的优化。比如伪静态。

添加到bbs.conf

server { listen 8800; server_name 你的域名; root html/bbs; location / { index index.php index.html index.htm; rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;rewrite ^([^\.]*)/archiver/(fid|tid)-([0-9]+)\.html$ $1/archiver/index.php?action=$2&value=$3 last;if (!-e $request_filename) { return 404;}} location ~ .*\.(php|php5)?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } access_log logs/access_bbs.log main; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }

全局性能优化一下。

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:IntelliJ IDEA设置JVM运行参数的图文介绍
下一篇:使用Apple推送通知服务(APN)的OS X和iOS应用程序和框架
相关文章

 发表评论

暂时没有评论,来抢沙发吧~