nginx的静态网页部署
将一个前端项目部署到nginx上,利用nginx服务器进行访问即nginx的静态网页部署
先用wincp访问远程服务器主机名:47.115.3.102
47.115.3.102 是你购买的云服务器IP
我的nginx目录在/etc/nginx下,在sites-available中配置如下
server {
listen 80;
server_name 47.115.3.102;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root html;
index index.html; # 默认加载根路径文件
}
location /ace {
root /var/www;
index login.html; # 默认加载根路径文件
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
更改配置文件后要重启nginx服务
遇到问题是nginx.service:control process exited进程已经存在了
需要找到nginx的进程号:ps -ef | grep nginx
执行命令:kill -QUIT pid
然后重启:service nginx restart
重启后在浏览器输入47.115.3.102/ace 即可访问login.html登陆页面
ace文件夹放置在/var/www下 login.html为ace下的文件
ace项目 https://github.com/XinLiangCoder/AceAdmin.git
可以通过git clone https://github.com/XinLiangCoder/AceAdmin.git下载到本地仓库
浏览器输入47.115.3.102/ace/index.html 就能打开主页页面