1.安装node js
-yum install gcc gcc-c++
-sudo yum install epel-release
-sudo yum install nodejs
如果出现下面问题
node-gyp: relocation error: node-gyp: symbol SSL_set_cert_cb, version libssl.so.10 not defined in file libssl.so.10 with link time reference
执行
-yum update openssl
-npm rebuild
2.安装pm2
npm install pm2 -g
3.安装json server
全局npm install -g json-server
单个npm install json-server –save-dev
PHP Mysql WordPress
Python
WordPress的主题
wordpress本身已经足够慢了。。直到我装了一个主题,wordpress安装排行第一的。
Hestia
首先,把我服务器CPU占爆满,没办法重启服务器。
然后,加载巨慢。。简直无语的速度。
然后看到别人使用的Node.js架构的博客简直流畅的如丝滑。我都忍不住要重新换个用了。
推荐下https://hexo.io/ 贼流畅,不过想想把文章移过去的麻烦和一些插件不能用。就懒得折腾了。
Nginx反向代理Nodejs服务通过SSL证书实现微信小程序Post
安装Nginx,Nodejs 安装过程
启动Nodejs服务。express 或者别的什么后台服务
比如启动以后的服务地址 localhost:3000
配置Nginx
/etc/nginx/nginx.conf
server { listen 80 default_server; listen [::]:80 default_server; listen 443 ssl; ssl_certificate /etc/nginx/ssl/xxxx.crt; #你的CRT ssl_certificate_key /etc/nginx/ssl/xxxx.key; #你的Key server_name xxx.com; #域名 ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_protocols SSLv3 TLSv1; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { proxy_pass http://127.0.0.1:3000; #Node的服务 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_set_header X-Forward-Proto https; proxy_http_version 1.1; # for websocket proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; }
然后重启Nginx
sudo systemctl restart nginx
在小程序里Post
wx.request({
url: “https://xxx.com:443/posts”,
…….
OK~
PS:上面是腾讯云的设置,阿里云的略有所不同。
Centos 7 安装 Nginx
Step One—Add Nginx Repository
第一步,添加Nginx 库
sudo yum install epel-release
Step Two—Install Nginx
第二步安装
sudo yum install nginx
输入Y
Step Three—Start Nginx
第三步运行
Nginx does not start on its own. To get Nginx running, type:
sudo systemctl start nginx
如果没什么问题就可以输入网站地址测试。成功的话就见到下面的的图。
因为我同时安装了Apache,所以80端口被占用了。启动的时候报错
Unit start.service could not be found. ● nginx.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since 三 2018-01-17 18:34:14 CST; 10s ago Process: 4237 ExecStart=/usr/sbin/nginx (code=exited, status=1/FAILURE) Process: 4234 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS) Process: 4233 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS) 1月 17 18:34:12 VM_66_141_centos nginx[4237]: nginx: [emerg] bind() to 0.0....) 1月 17 18:34:12 VM_66_141_centos nginx[4237]: nginx: [emerg] bind() to 0.0....) 1月 17 18:34:13 VM_66_141_centos nginx[4237]: nginx: [emerg] bind() to 0.0....) 1月 17 18:34:13 VM_66_141_centos nginx[4237]: nginx: [emerg] bind() to 0.0....) 1月 17 18:34:14 VM_66_141_centos nginx[4237]: nginx: [emerg] bind() to 0.0....) 1月 17 18:34:14 VM_66_141_centos systemd[1]: nginx.service: control process...1 1月 17 18:34:14 VM_66_141_centos nginx[4237]: nginx: [emerg] still could no...) 1月 17 18:34:14 VM_66_141_centos systemd[1]: Failed to start The nginx HTTP.... 1月 17 18:34:14 VM_66_141_centos systemd[1]: Unit nginx.service entered fai.... 1月 17 18:34:14 VM_66_141_centos systemd[1]: nginx.service failed. Hint: Some lines were ellipsized, use -l to show in full.
这个时候修改配置文件/etc/nginx/nginx.conf
server { listen 8088 default_server; listen [::]:8088 default_server;
然后执行下面命令测试一下
nginx -t -c /etc/nginx/nginx.conf
执行下面命令加入启动项
sudo systemctl enable nginx
Over.
Centos7开启GZIP压缩页面提升VUE加载
先说下效果,未开启的时候,加载Venderjs的速度380K加载了12s
开启Gzip后,提升了一倍多。平均2秒到3秒。。verygood