首先强调一点:当前Discuz! Q还是很早期的版本,主要是面向开发者,让开发者提前介入模板和插件的开发。或者有经验的站长,作为早期体验和选型。
-
一个腾讯云实名认证过的账号,并且使用了DNSPod,在DNSPod至少有一个域名。(并不是为了强绑腾讯云,而是为了保证初期内测使用的用户都是强需求的) -
一台船新的腾讯云的CVM,操作系统可以是CentOS或者Ubuntu或者Debian,最新版本即可。当然阿里云或者华为云或者本地虚拟机也可以。但一定要干净,没装过任何东西。 -
在腾讯云账号中心的API密钥管理,获取到SecretId和SecretKey。注意:请千万不要泄露这两个东西给到任何你不信赖的人,避免你的腾讯云账号被控制,受到损失。 -
如果(建议,强烈建议)要使用HTTPS,可以到腾讯云申请免费的SSL证书。 -
申请Discuz! Q内测资格:
https://www.dnspod.cn/promo/discuzq。
# yum install -y wget
Ubuntu或者Debian运行
# apt-get install wget
# wget http://soft.vpser.net/lnmp/lnmp1.6.tar.gz
# tar zxvf lnmp1.6.tar.gz
# cd lnmp1.6
# ./install.sh
安装选项如下:
-
MariaDB 10.3.15 -
PHP 7.3.6 -
Jemalloc
./addons.sh
-
3: Memcached(选择后,二级选项要选php-memcached,千万别选错!不要选带有Discuz的那个) -
5: Redis -
7: imageMagick
# sed -i 's/^disable_functions.*/disable_functions = /' /usr/local/php/etc/php.ini
# mkdir -p /var/hosts/com/naizhao
# cd /var/hosts/com/naizhao
然后我们修改下composer的源为腾讯云(composer的官方源在国外,很慢)
# composer config -g repos.packagist composer https://mirrors.cloud.tencent.com/composer/
# composer create-project --prefer-dist qcloud/discuz --repository=https://cloud.discuz.chat q
# cd q
# ls -lha
你应该会看到下面的内容
total 388K
drwxr-xr-x 11 root root 4.0K Mar 16 18:23 .
drwxr-xr-x 3 root root 4.0K Mar 16 18:21 ..
drwxr-xr-x 28 root root 4.0K Mar 16 18:21 app
-rw-rw-rw- 1 root root 917 Mar 15 19:57 composer.json
-rw-r--r-- 1 root root 319K Mar 16 18:23 composer.lock
drwxr-xr-x 2 root root 4.0K Mar 16 18:21 config
drwxr-xr-x 4 root root 4.0K Mar 16 18:21 database
-rw-rw-rw- 1 root root 362 Mar 15 19:57 disco
-rw-rw-rw- 1 root root 213 Mar 15 19:57 .editorconfig
drwxr-xr-x 4 root root 4.0K Mar 16 18:21 .github
-rw-rw-rw- 1 root root 108 Mar 15 19:57 .gitignore
-rw-rw-rw- 1 root root 1.4K Mar 15 19:57 .php_cs
drwxr-xr-x 5 root root 4.0K Mar 16 18:21 public
-rw-rw-rw- 1 root root 2.3K Mar 15 19:57 readme.md
drwxr-xr-x 7 root root 4.0K Mar 16 18:21 resources
drwxr-xr-x 2 root root 4.0K Mar 16 18:21 routes
drwxr-xr-x 11 root root 4.0K Mar 16 18:21 storagedrwxr-xr-x 56 root root 4.0K Mar 16 18:23 vendor
最后,我们还要改一下storage和config目录为可写
# chmod -R 777 storage config
# lnmp vhost add
输入内容,可以参考下面
Please enter domain(example: www.lnmp.org): q.naizhao.com
Your domain: q.naizhao.com #输入网站的域名
Enter more domain name(example: lnmp.org *.lnmp.org):
Please enter the directory for the domain: q.naizhao.com
Default directory: /home/wwwroot/q.naizhao.com: /var/hosts/com/naizhao/q/public #输入网站的根目录,记得后面要加上public
Virtual Host Directory: /var/hosts/com/naizhao/q/public
Allow Rewrite rule? (y/n) y
Please enter the rewrite of programme,
wordpress,discuzx,typecho,thinkphp,laravel,codeigniter,yii2 rewrite was exist.
(Default rewrite: other): laravel #rewrite规则选择laravel
You choose rewrite: laravel
Enable PHP Pathinfo? (y/n) y
Enable pathinfo.
Allow access log? (y/n) y
Enter access log filename(Default:q.naizhao.com.log):
You access log filename: q.naizhao.com.log
Create database and MySQL user with same name (y/n) y #创建MySQL数据库
Enter current root password of Database (Password will not shown): #输入MySQL的root密码
OK, MySQL root password correct.
Enter database name: dzq #输入要创建的数据库名字
Your will create a database and MySQL user with same name: dzq
Please enter password for mysql user dzq: dzq #输入数据库密码
Your password: dzq
Add SSL Certificate (y/n) y #是否打开SSL支持
1: Use your own SSL Certificate and Key
2: Use Let's Encrypt to create SSL Certificate and Key
Enter 1 or 2: 2 #SSL证书安装方式,如果前面在腾讯云申请了,选1。或者选2用Let's Encrypt提供的免费3个月证书。但一定要提前把域名指向你的服务器,否则申请不成功!!!It will be processed automatically.
server {
listen 80;
server_name q.naizhao.com; #网站域名
return 301 https://$host$request_uri; # 强制把HTTP跳转到HTTPS
}
server {
listen 443 ssl http2;
server_name q.naizhao.com; #网站域名
root /var/hosts/com/naizhao/q/public; #网站目录,切记指到public
ssl_certificate /usr/local/nginx/conf/ssl/q.naizhao.com/fullchain.cer; #ssl证书的证书链
ssl_certificate_key /usr/local/nginx/conf/ssl/q.naizhao.com/q.naizhao.com.key; #ssl证书的key
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 24h;
ssl_prefer_server_ciphers on;
ssl_ciphers EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ecdh_curve secp521r1:secp384r1;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;
ssl_buffer_size 4k;
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
index index.html;
include enable-php-pathinfo.conf;
location /install {
try_files $uri $uri/ /index.php?$query_string;
}
location /api {
try_files $uri $uri/ /index.php?$query_string;
}
location / {
try_files $uri $uri/ /index.html;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;}
# lnmp restart
https://q.naizhao.com/install,按照上面的提示,输入MySQL的信息、管理员信息,点击安装
https://q.naizhao.com/admin ,就可以管理站点了。
https://q.bra.cm/