系统安装说明书
1、安装lnmp
1、 wget https://soft.lnmp.com/lnmp/lnmp2.0.tar.gz 2、./install.sh
2、下载代码
git clone https://gitee.com/sdyansong/zycx_system.git
3、配置nginx.conf
server { listen 80 default_server reuseport; #listen [::]:80 default_server ipv6only=on; server_name _; index index.html index.htm index.php; root /home/wwwroot/zycx_system/public; #error_page 404 /404.html; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } include enable-php.conf; location /nginx_status { stub_status on; access_log off; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /.well-known { allow all; } location ~ /\. { deny all; } access_log /home/wwwlogs/access.log; } #default server { listen 8080 default_server reuseport; #listen [::]:80 default_server ipv6only=on; server_name _; index index.html index.htm index.php; root /home/wwwroot/default; #error_page 404 /404.html; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } include enable-php.conf; location /nginx_status { stub_status on; access_log off; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /.well-known { allow all; } location ~ /\. { deny all; } access_log /home/wwwlogs/access.log; }
4、重启服务器
lnmp restart
5、修改数据库上传文件大小
LNMP环境修改上传文件大小限制
如果网页上传文件大小大于nginx或php设定的值,就会造成无法上传,显示IO error错误。
如何解决这个问题呢?我们需要更改两个配置:
1. nginx配置文件:
vim /usr/local/nginx/conf/nginx.conf
更改client_max_body_size 后面的值。
2. php.ini:
vim /usr/local/php/etc/php.ini
更改post_max_size 和upload_max_filesize 后面的值。
修改完成后,重启nginx和php即可。
6、导入数据库。
将数据库上传到服务器,利用命令导入数据库
source zhengyichuxing.sql
7、编辑nginx.conf文件
server { listen 80 default_server reuseport; add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Methods' 'OPTION, POST, GET'; add_header 'Access-Control-Allow-Headers' 'X-Requested-With, Content-Type'; if ($request_method = 'OPTIONS') { return 204; } #listen [::]:80 default_server ipv6only=on; server_name _; index index.html index.htm index.php; root /home/wwwroot/zycx_system/public; #error_page 404 /404.html; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } include enable-php.conf; include rewrite/thinkphp.conf; location /nginx_status { stub_status on; access_log off; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /.well-known { allow all; } location ~ /\. { deny all; } access_log /home/wwwlogs/access.log; } #default server { listen 8080 default_server reuseport; #listen [::]:80 default_server ipv6only=on; server_name _; index index.html index.htm index.php; root /home/wwwroot/default; #error_page 404 /404.html; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } include enable-php.conf; location /nginx_status { stub_status on; access_log off; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /.well-known { allow all; } location ~ /\. { deny all; } access_log /home/wwwlogs/access.log; }
8、报500错误
修改conf下的fastcgi.conf 注释 #fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";
9、报错
file_put_contents(/home/wwwroot/zycx_system/runtime/temp/dc762373d8f41a72ff77e0c42ad9e62d.php): failed to open stream: Permission denied
chmod -R 777 runtime
10、 报错
致命错误: Call to undefined function captcha_src()
composer require topthink/think-captcha=1.* 官方的5.0版本的扩展库版本号都是1.*,2.0版本均为ThinkPHP5.1版本专用。 如果报错如下,就把根目录下的composer.json和composer.lock删除后再执行。去vendor/topthink/下查看是否有think-captch
11、
Array and string offset access syntax with curly braces is deprecated
原因是因为MySQL7.4版本不再支持{}写法,统一为数组[ ],解决很简单通过修改tp5的Query.php文件的字段中 $seq = (ord($value{0}) % $rule['num']) + 1; 的$value{0}大括号改为$value[0]
12、首页出来后,没有css样式,是因为缺少css样式信息
直接把文件夹复制到里面
后面绑定域名
13 安装ssl证书
https://freessl.cn/acme-deploy?domains=yanshixinxi.top%2Cwww.yanshixinxi.top
手册
https://blog.freessl.cn/acme-quick-start/
cp /root/.acme.sh/www.yanshixinxi.top/www.yanshixinxi.top.cer /etc/nginx/ssl/ cp /root/.acme.sh/www.yanshixinxi.top/www.yanshixinxi.top.key /etc/nginx/ssl/
生成证书后,把证书放到 /etc/nginx/ssl下面
输入命令
acme.sh --install-cert -d yanshixinxi.top --key-file /etc/nginx/ssl/yanshixinxi.top.key --fullchain-file /etc/nginx/ssl/yanshixinxi.top.cer --reloadcmd "service nginx force-reload"
acme.sh --install-cert -d www.yanshixinxi.top --key-file /etc/nginx/ssl/www.yanshixinxi.top.key --fullchain-file /etc/nginx/ssl/www.yanshixinxi.top.cer --reloadcmd "service nginx force-reload"
如果过期
acme.sh --issue -d www.yanshixinxi.top --dns dns_dp --server https://acme.freessl.cn/v2/DV90/directory/ezvxfipdfpyfcuqnn9mi
cp /root/.acme.sh/www.yanshixinxi.top/www.yanshixinxi.top.key /etc/nginx/ssl/
cp /root/.acme.sh/www.yanshixinxi.top/www.yanshixinxi.top.cer /etc/nginx/ssl/
lnmp restart
acme.sh --install-cert -d www.yanshixinxi.top --key-file /etc/nginx/ssl/www.yanshixinxi.top.key --fullchain-file /etc/nginx/ssl/www.yanshixinxi.top.cer --reloadcmd "service nginx force-reload"
上面是过期后的操作
配置nginx.conf
user www www; worker_processes auto; worker_cpu_affinity auto; error_log /home/wwwlogs/nginx_error.log crit; pid /usr/local/nginx/logs/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; multi_accept off; accept_mutex off; } http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 100m; sendfile on; sendfile_max_chunk 512k; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 256k; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss; gzip_vary on; gzip_proxied expired no-cache no-store private auth; gzip_disable "MSIE [1-6]\."; #limit_conn_zone $binary_remote_addr zone=perip:10m; ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section. server_tokens off; access_log off; server { listen 80 default_server reuseport; add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Methods' 'OPTION, POST, GET'; add_header 'Access-Control-Allow-Headers' 'X-Requested-With, Content-Type'; if ($request_method = 'OPTIONS') { return 204; } #listen [::]:80 default_server ipv6only=on; server_name _; index index.html index.htm index.php; root /home/wwwroot/zycx_system/public; #error_page 404 /404.html; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } include enable-php.conf; include rewrite/thinkphp.conf; location /nginx_status { stub_status on; access_log off; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /.well-known { allow all; } location ~ /\. { deny all; } access_log /home/wwwlogs/access.log; } #default server { listen 8080 default_server reuseport; #listen [::]:80 default_server ipv6only=on; server_name _; index index.html index.htm index.php; root /home/wwwroot/default; #error_page 404 /404.html; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } include enable-php.conf; location /nginx_status { stub_status on; access_log off; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /.well-known { allow all; } location ~ /\. { deny all; } access_log /home/wwwlogs/access.log; } server { listen 443 ssl; server_name yanshixinxi.top; ssl_certificate /etc/nginx/ssl/yanshixinxi.top.cer; ssl_certificate_key /etc/nginx/ssl/yanshixinxi.top.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; #listen 80 default_server reuseport; #listen [::]:80 default_server ipv6only=on; add_header 'Access-Control-Allow-Headers' '*'; add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,HEAD,PUT'; add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Credentials' 'true'; if ($request_method = 'OPTIONS') { return 204; } server_name _; index index.html index.htm index.php; #root /home/wwwroot/lqxh/public; root /home/wwwroot/zycx_system/public; #error_page 404 /404.html; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } include enable-php.conf; include rewrite/thinkphp.conf; location /nginx_status { stub_status on; access_log off; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /.well-known { allow all; } location ~ /\. { deny all; } access_log /home/wwwlogs/access.log; } include vhost/*.conf; }
配置定时任务,自动更新
14、配置htym的地址为www.yanshixinxi.top
15、导出数据库,通过source zhengyichuxing.sql 导入数据库
16、登录小程序后台,添加域名。
17、配置域名为www.yanshixinxi.top,编译体验版,进行测试。