配置阿里云的步骤,前面的博客已经说过,在此不介绍了。
安装nginx (确保你的阿里云开放了80端口)
apt update
apt upgrade
apt install nginx
下载阿里云nginx的配置信息(这里是下载到d盘的)
pscp root@阿里云ip:/etc/nginx/nginx.conf d:
打开并修改配置信息
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
server {
listen 80;
server_name 121.41.98.23;
root /opt/www;
index index.html;
}
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
修改好的配置信息上传到阿里云
pscp d:\CodeWeb\nginx.conf root@阿里云ip:/etc/nginx
重启nginx
service nginx reload
接下来上传一个文件测试nginx
上传文件到阿里云opt目录下的www
pscp d:\CodeWeb\www\index.html root@阿里云ip:/opt/www
上传文件夹阿里云opt目录下的www
pscp -r d:\dd\dd root@阿里云ip:/opt/www
上传成功后,在浏览器打开你的阿里云ip就可以看到效果了。
扩展:
安装mongodb:
查看
service mongodb status
安装
apt install mongodb
安装 JDK:
apt install openjdk-11-jdk-headless
查看
java -version
查看运行的服务
netstat -tap
后台运行java.jar (进入所在目录)
& ( 在后台运行该程序/进程,不占用/阻塞 当前的 shell
java -jar todos.jar &
搜索运行的服务
netstat -tap | grep java
杀掉服务 (1725 为进程数)
kill 1725
以上就是阿里云nginx的配置,小伙伴们可以通过这个搭建属于自己的网站。有问题的欢迎留言!!!