Ali cloud server (centos) deployment and configuration https nginx

Reprinted https://liaolongdong.com/2018/11/16/alicloud-nginx.html

 

Ali cloud service installation nginx
1, first of all, upgrade all packages, CentOS kernel update to the latest version, centos yum package management using the command

yum -y update // -y (when prompted to select the installation process all "yes")
Note: The difference yum -y update and yum -y upgrade of

yum -y update (all upgrade and change): Upgrade all packages, system and kernel version, change the software settings and system settings
yum -y upgrade (the same kernel and settings, and system version upgrade package): all packages and system upgrades version, does not change the core, software and system settings

2, install nginx

-y install nginx yum
3, nginx test installation was successful

nginx startup directory: / usr / sbin
nginx websites in the default directory: / usr / report this content share / nginx / HTML
nginx configuration file default path: /etc/nginx/nginx.conf

Use whereis nginx nginx Related Category View, go to the next / usr / sbin / directory, execute start nginx nginx, as shown:

In the browser address bar enter the cloud server public IP address, see the following page:

linux command operations related introduction:

View port occupancy: netstat -apn | grep [port number]
View occupy the port processes: ps -ef | grep [occupied port process id]
to kill the process: kill -9 [process id]
4, nginx modify profile information

cd / etc / nginx
vim nginx.conf // View nginx.conf profile information
as shown:

It can be changed by modifying the configuration nginx configuration file, such as the default port 80 into a different port number, etc.

Note: 1, set the port number must be added corresponding Ali cloud server security group, or can not access normal; 2, you must restart nginx, reboot command nginx -s reload;

Ali cloud domain configuration https
general steps to configure the domain https as follows:

Buy - Application - download free certificates
downloaded free certificate file into the installation directory nginx
nginx profile configuration https
buy - Application - Download Free certificate
specific process:

Ali cloud service console, open the "Products and Services" -> "Security (cloud shield)" -> "SSL Certificates"
to enter the "SSL Certificate" page, click on the "Buy Certificate" button, enter the certificate purchase page, choose to purchase the certificate (optional free type certificate)
after the purchase is completed, click "apply" button, fill in the corresponding certificate application information
certificate after the application is successful, you can click on the "download" button to download the certificate
to download a free certificate file into the installation nginx directory
into the Ali cloud services nginx installation directory / etc / nginx
New folder cert, and the two certificates downloaded files in the directory
open nginx.conf configuration file, as follows, after the configuration is complete restart nginx service
# Settings for a TLS enabled server.

server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name _;
# root /usr/share/nginx/html;
root /usr/share/nginx/html/liaolongdong.github.io/_site;

# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
ssl_certificate cert/1506368_liaolongdong.com.pem;
ssl_certificate_key cert/1506368_liaolongdong.com.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location / {
}

error_page 404 /404.html;
location = /40x.html {
}

500 502 503 504 /50x.html error_page;
LOCATION /50x.html = {
}
}
configured ssl_certificate ssl_certificate_key two fields and to the details can refer Nginx / Tengine SSL certificate server installation

Nginx into the startup directory usr / sbin, execute the command to restart nginx nginx -s reload

Completion of the above steps can be normal use https visit friends ~

Copyright reserved by the authors.
Commercial reprint please contact the author authorized, non-commercial reprint please indicate the source.
Original: https://liaolongdong.com/2018/11/16/alicloud-nginx.html

Guess you like

Origin www.cnblogs.com/boonook/p/11641705.html