Skip to content

Nginx Cheetsheet

Nginx官网:nginx.org

阿里云centos7安装Nginx

参考链接:阿里云centos7安装Nginx

  1. 查看资源库中软件包信息
shell
yum info nginx
  1. 安装Nginx
shell
yum install nginx
  1. 确认安装成功
shell
nginx -v /* 查看安装版本 */

nginx -t /* 查看配置文件是否准确 */
  1. 查找相关目录
shell
whereis nginx
  1. 启动nginx服务
shell
systemctl start nginx.service
  1. 关闭nginx服务
shell
systemctl stop nginx.service
  1. 重启nginx服务
shell
systemctl reload nginx
  1. 查看nginx状态
shell
systemctl status nginx
  1. 编辑配置文件
shell
vim /etc/nginx/nginx.conf
  1. 输入网址测试

在浏览器中输入 http://ip:80 (nginx配置文件默认80端口)

Nginx安装成功

Nginx配置https域名证书

参考链接:nginx配置域名https - 腾讯云开发者社区 - 腾讯云

nginx
server {
    listen 		    443 ssl;
    server_name 	xukaiwen.com; 
    root	        /home/xukaiwen/www/html;    	

    ssl_certificate     /root/crt/xukaiwen.com.pem;
    ssl_certificate_key     /root/crt/xukaiwen.com.key;

}

server {
    listen       	80;
    server_name  	xukaiwen.com;
    return 301      https://$host$request_uri;  
}