相信很多爱折腾的小伙伴到最后都选择了vps服务器,原因无非有三:
第一:可扩展性好,性能可调控,虚拟主机扩容性不佳。(固定的)
第二:完全的ROOT,意味着可以做各种想做的事情(仅限技术)
第三:独立的IP,利于SEO优化,相对于虚拟主机,独立IP需要付费
接下来开始今天的重头戏,搭建生产环境,liunx系统版本仅限主流。
第一种:不带面板的一键集成安装方法
意思就是说,不用一个一个安装组建,去掉繁杂的操作和配置流程,安装好后,可以通过命令管理网站。
搭建命令:
screen -S lnmp
后,再执行:
wget http://soft.vpser.net/lnmp/lnmp1.7.tar.gz -cO lnmp1.7.tar.gz && tar zxf lnmp1.7.tar.gz && cd lnmp1.7 && ./install.sh lnmp
请注意最后面的lnmp参数,如需要lnmpa 或 lamp 模式,请替换lnmp为你要安装的模式。
安装生产环境后,如何添加网站?
第二种:带面板的一键安装方法
screen -S lnmp
后,再执行:
Centos安装命令:
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh
试验性Centos/Ubuntu/Debian安装命令 独立运行环境(py3.7) 可能存在少量兼容性问题 不断优化中
curl -sSO http://download.bt.cn/install/install_panel.sh && bash install_panel.sh
第三种:单组件挨个安装,费时,容易出错
安装Nginx
先更新包、软件、系统内核
yum update
安装ggc
yum install gcc-c++
安装pcre-devel
yum install pcre pcre-devel
安装cmake
wget https://cmake.org/files/v3.6/cmake-3.14.0.tar.gz
tar -xzvf cmake-3.14.0.tar.gz
cd cmake-3.14.0
./bootstrap
gmake
gmake install
安装zlibcd /usr/local/src
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -xzvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make && make install
安装bzipcd /usr/local/src
wget https://nchc.dl.sourceforge.net/project/bzip2/bzip2-1.0.6.tar.gz
tar -xzvf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
为编译做准备,创建libbz2.so动态链接库
make -f Makefile-libbz2_so
编译安装
make && make install
安装ziblip
yum -y remove libzip-devel
wget https://libzip.org/download/libzip-1.5.1.tar.gz
tar -zxvf libzip-1.5.1.tar.gz
cd libzip-1.5.1
mkdir build
cd build
cmake ..
make && make install
安装openssl
cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.1.1b.tar.gz
tar -xzvf openssl-1.1.1b.tar.gz
cd openssl-1.1.1b
制定编译安装后的位置
./config --prefix=/usr/local/openssl
make && make install
查看安装
which openssl
建立软连接
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
执行
cd /usr/local/openssl
ldd /usr/local/openssl/bin/openssl
查看版本
增加用户组
groupadd www
useradd -g www -M www
vi /etc/passwd
找到www,将后面的/bin/bash改为/sbin/nologin即可。
下载安装nginxcd /usr/local/src
wget http://nginx.org/download/nginx-1.14.2.tar.gz
tar -xzvf nginx-1.14.2.tar.gz
cd nginx-1.14.2
配置编译./configure \
--user=www \
--group=www \
--prefix=/alidata/service/nginx \
--pid-path=/alidata/service/nginx/run/nginx.pid \
--with-http_stub_status_module \
--with-threads \
--with-file-aio \
--with-pcre-jit \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_gzip_static_module \
--with-http_sub_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_realip_module \
--with-http_addition_module \
--with-stream \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-stream_realip_module \
--with-http_slice_module \
--with-pcre \
--with-openssl=/usr/local/src/openssl-1.1.1b/ \
--with-openssl-opt=enable-tls1_3 \
--add-module=/usr/local/src/ngx_brotli/
没有问题会提示
Configuration summary
- using threads
- using system PCRE library
- using OpenSSL library: /usr/local/src/openssl-1.1.1b
- using system zlib library nginx path prefix: “/alidata/service/nginx”
nginx binary file: “/alidata/service/nginx/sbin/nginx”
nginx modules path: “/alidata/service/nginx/modules”
nginx configuration prefix: “/alidata/service/nginx/conf”
nginx configuration file: “/alidata/service/nginx/conf/nginx.conf”
nginx pid file: “/alidata/service/nginx/run/nginx.pid”
nginx error log file: “/alidata/service/nginx/logs/error.log”
nginx http access log file: “/alidata/service/nginx/logs/access.log”
nginx http client request body temporary files: “client_body_temp”
nginx http proxy temporary files: “proxy_temp”
nginx http fastcgi temporary files: “fastcgi_temp”
nginx http uwsgi temporary files: “uwsgi_temp”
nginx http scgi temporary files: “scgi_temp”
编译安装
make && make install
启动nginx
/alidata/service/nginx/sbin/nginx -V
配置开机自启动
启动服务
systemctl enable nginx.service
systemctl start nginx.service #启动nginx
systemctl stop nginx.service #结束nginx
systemctl restart nginx.service #重启nginx
至此两种安装方案,全部结束,如果有环境配置问题,请+QQ:137883334