1.你得有一台自己的服务器,阿里或者腾讯,学生很便宜。
2.买一个域名,.com/cn/…都行
3.登录你的腾讯云服务器
3.1.xshell操作Linux界面
3.2. secureCRT或xftp操作文件传输,其实只用xshell是可以传输的,不过只能传输压缩包。
3.3.如果可以,您还可以下载一个EditPlus,方便直接传文件到目录,更重要的是,用它连接服务器外网IP可以直接改文件呢。
4.last but not least; keep your eyes.
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--with-http_ssl_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi\
--with-http_stub_status_module
be care for
先给出这一部分我们再继续后面的操作,注意安装Nginx时你找的上面这一部分代码是否有这一句
–with-http_ssl_module
因为后面访问域名时会提示这块即SSL证书,https协议。
4.1 先建几个文件夹
mkdir /usr/local/nginx
/var/run/
/var/temp/
mkdir /var/temp/nginx/client -p
4.2 步骤,安装
1.OpenSSL
yum install -y openssl openssl-devel
2.安装 gcc 的环境
yum install gcc-c++
3.第三方的开发包
yum install -y pcre pcre-devel
- zlib
yum install -y zlib zlib-devel
5.因为我的centos腾讯服务器不支持命令安装,所以下载安装包
可以通过命令下载
wget http://nginx.org/download/nginx-1.7.12.tar.gz
我的是下载在本地上传到服务器的
官网:http://nginx.org/
通过xshell上传到根目录
6.解压
tar zxvf nginx-1.8.0.tar.gz
7.进入nginx-1.8.0目录 使用 configure 命令创建一 makeFile 文件。
即上面的那一堆代码:
configure参数
./configure
–prefix=/usr \ 指向安装目录
–sbin-path=/usr/sbin/nginx \ 指向(执行)程序文件(nginx)
–conf-path=/etc/nginx/nginx.conf \ 指向配置文件
–error-log-path=/var/log/nginx/error.log \ 指向log
–http-log-path=/var/log/nginx/access.log \ 指向http-log
–pid-path=/var/run/nginx/nginx.pid \ 指向pid
–lock-path=/var/lock/nginx.lock \ (安装文件锁定,防止安装文件被别人利用,或自己误操作。)
–user=nginx
–group=nginx
–with-http_ssl_module \ 启用ngx_http_ssl_module支持(使支持https请求,需已安装openssl)
–with-http_flv_module \ 启用ngx_http_flv_module支持(提供寻求内存使用基于时间的偏移量文件)
–with-http_stub_status_module \ 启用ngx_http_stub_status_module支持(获取nginx自上次启动以来的工作状态)
–with-http_gzip_static_module \ 启用ngx_http_gzip_static_module支持(在线实时压缩输出数据流)
–http-client-body-temp-path=/var/tmp/nginx/client/ \ 设定http客户端请求临时文件路径
–http-proxy-temp-path=/var/tmp/nginx/proxy/ \ 设定http代理临时文件路径
–http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \ 设定http fastcgi临时文件路径
8.安装编译
make&make install
9.cd /usr/local/ngiux/sbin
启动./nginx
10.启动后查看进程
ps aux|grep nginx
11.关闭 nginx:
./nginx -s stop
五.配置Nginx conf文件
1.将你申请的SSL证书下载到本地
把Nginx文件夹下的xxx.crt及xxx.key文件上传到conf文件夹下面
2.配置Nginx.conf文件
server {
listen 443 ssl;
server_name 域名;
ssl_certificate xxx.crt;
ssl_certificate_key xxx.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
#ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root 资源根目录;
index index.html index.htm;
}
}
3.上传你事先准备打的页面资源
4.访问你的域名
ps:注意腾讯云后台安全组的访问端口要打开。