Permission denied


(son) #1

Chào mọi người , mình mới sử dụng Vps lần đầu , khi mình cài đặt SSl cho hocvps đến bước 2 ( Cấu hình Nginx ) mình dùng lệnh /etc/nginx/conf.d/hocvps.com.conf thi bị báo lỗi permission denied ( mình vẫn đăng nhập là root , chưa cài đặt gì ngoài hocvps)
Mong cao nhân đi ngang qua chỉ giúp gà mới . Cám ơn ạ


(duy) #2

nano /etc/nginx/conf.d/hocvps.com.conf

Có cả nano nữa, file đó để sửa chứ ko phải để chạy, nano là để gọi trình nano sửa file hocvps.com.conf

https://hocvps.com/cach-su-dung-nano-editor/


(son) #3

Cam on bạn nhé , sau 1 buổi cũng vọc được khá khá . Nhưng mà mình vẫn chưa làm chủ được mấy script này , website test ngon lành rồi mình ấn thử resest VPS , sau khi rs website lại không vào được nữa . Như vậy nếu VPS mà bị disconect , toàn bộ website ngừng hoạt động luôn ạ


(Việt Phương) #4

Sau reset mà không chạy nữa là Nginx lỗi rồi
Bạn kiểm tra trạng thái nginx
nginx -t
systemctl status nginx


(son) #5

Cám ơn các cụ , sau hơn 2 chục lần cài đi cài lại em cũng gần setup xong con VPS rồi . Web đã chạy nhưng một vài chức năng ko hoạt động ( trước e dùng apache ) em có đọc là phải sửa file nginx.conf nhưng mỗi lần sửa lần nào là lần đấy lỗi . Các cụ có thể thông não cho em cách viết rules trong đây ko ạ /etc/nginx/conf.d/vhost và file nginx.conf trong /etc/nginx

nginx configuration

location / {
if (!-e $request_filename){
rewrite ^/password-reset/([^/]+)(/|)$ /index.php?link1=welcome&link2=password_reset&user_id=$1;
}
rewrite ^/$ /index.php?link1=home;
rewrite “^/forum/members/([a-zA-Z]{0,1})(/?|)$” /index.php?link1=forum-members-byname&char=$1;
if (!-e $request_filename){
rewrite ^/setting/([A-Za-z0-9_]+)/([A-Za-z0-9_-]+)$ /index.php?link1=setting&user=$1&page=$2;
rewrite ^/setting/([A-Za-z0-9_-]+)$ /index.php?link1=setting&page=$1;
rewrite ^/setting$ /index.php?link1=setting;
}
if (!-e $request_filename){
rewrite ^/@([^/]+)(/|)$ /index.php?link1=timeline&u=$1;
}
if (!-e $request_filename){
rewrite ^/([A-Za-z0-9_]+)/([^/]+)(/|)$ /index.php?link1=timeline&u=$1&type=$2;
}
if (!-e $request_filename){
rewrite ^/([^/]+)(/|)$ /index.php?link1=timeline&u=$1;
}
}

location /admin {
rewrite ^/admin-cp$ /admincp.php;
rewrite ^/admin-cp/(.*)$ /admincp.php?page=$1;
rewrite ^/admin/ads/edit/(\d+)(/?|)$ /index.php?link1=manage-ads&id=$1;
}

location = /admincp {
rewrite ^(.*)$ /admincp.php;
}

location /admincp {
rewrite ^/admincp/(.*)$ /admincp.php?page=$1;
}

location /adminPages/ {
return 301 /admin-panel/;
}

location ~ ^/adminPages/(.*) {
return 301 /admin-panel/$1;
}

location /start {
rewrite ^/start-up$ /index.php?link1=start-up;
}

location /saved {
rewrite ^/saved-posts/(.*)$ /index.php?link1=saved-posts;
rewrite ^/saved-posts$ /index.php?link1=saved-posts;
}

location /activated {
rewrite ^/activated/(.*)$ /index.php?link1=activate&link2=$1;
}

location = /search {
rewrite ^(.*)$ /index.php?link1=search;
}

location /ads {
rewrite ^/ads-create$ /index.php?link1=ads-create;
rewrite ^/ads(/?|)$ /index.php?link1=ads;
rewrite ^/ads/create(/?|)$ /index.php?link1=create-ads;
rewrite ^/ads/edit/(\d+)(/?|)$ /index.php?link1=edit-ads&id=$1;
rewrite ^/ads/chart/(\d+)(/?|)$ /index.php?link1=chart-ads&id=$1;
}

location /send_money {
rewrite ^/send_money$ /index.php?link1=ads-create;
}

location = /most_liked {
rewrite ^(.*)$ /index.php?link1=most_liked;
}

location /suggested {
rewrite ^/suggested-pages(/?|)$ /index.php?link1=suggested-pages;
rewrite ^/suggested-groups(/?|)$ /index.php?link1=suggested-groups;
}

location = /poke {
rewrite ^(.*)$ /index.php?link1=poke;
}

location /search {
rewrite ^/search/([^/]+)(/|)$ /index.php?link1=search&query=$1;
}

location /app {
rewrite ^/app/([^/]+)(/|)$ /index.php?link1=app&app_id=$1;
}

location /messages {
rewrite ^/messages/([^/]+)(/|)$ /index.php?link1=messages&user=$1;
}

location /terms {
rewrite ^/terms/([^/]+)(/|)$ /index.php?link1=terms&type=$1;
}

location /video {
rewrite ^/video-call/([^/]+)(/|)$ /index.php?link1=video-call&call_id=$1;
rewrite ^/video-call-api/([^/]+)(/|)$ /index.php?link1=video-call-api&call_id=$1;
}

location /post {
rewrite ^/post/([^/]+)(/|)$ /index.php?link1=post&id=$1;
}

location /game {
rewrite ^/game/([^/]+)(/|)$ /index.php?link1=game&id=$1;
}

location = /upgraded {
rewrite ^(.*)$ /index.php?link1=upgraded;
}

location = /get_news_feed {
rewrite ^(.*)$ /index.php?link1=get_news_feed;
}

location = /games {
rewrite ^(.*)$ /index.php?link1=games;
}

location /new {
rewrite ^/new-game$ /index.php?link1=new-game;
rewrite ^/new-product$ /index.php?link1=new-product;
}

location /go {
rewrite ^/go-pro$ /index.php?link1=go-pro;
}

location = /oops {
rewrite ^(.*)$ /index.php?link1=oops;
}

location /user {
rewrite ^/user-activation$ /index.php?link1=user-activation;
}

location /hashtag {
rewrite ^/hashtag/([^/]+)(/|)$ /index.php?link1=hashtag&hash=$1;
}

location /follow {
rewrite ^/follow-requests/(.*)$ /index.php?link1=follow-requests;
}

location = /home {
rewrite ^(.*)$ /index.php?link1=home;
}

location = /404 {
rewrite ^(.*)$ /index.php?link1=404;
}

location /welcome {
rewrite ^/welcome(.*)$ /index.php?link1=welcome;
}

location = /register {
rewrite ^(.*)$ /index.php?link1=register;
}

location /confirm {
rewrite ^/confirm-sms$ /index.php?link1=confirm-sms;
rewrite ^/confirm-sms-password(/?|)$ /index.php?link1=confirm-sms-password break;
}

location /forgot {
rewrite ^/forgot-password$ /index.php?link1=forgot-password;
}

location = /activate {
rewrite ^(.*)$ /index.php?link1=activate;
}

location = /pages {
rewrite ^(.*)$ /index.php?link1=pages;
}

location = /groups {
rewrite ^(.*)$ /index.php?link1=groups;
}

location /create {
rewrite ^/create-group$ /index.php?link1=create-group;
rewrite ^/create-page$ /index.php?link1=create-page;
rewrite ^/create-album$ /index.php?link1=create-album;
rewrite ^/create-album/([A-Za-z0-9_-]+)$ /index.php?link1=create-album&album=$1;
rewrite ^/create-blog(/?|)$ /index.php?link1=create-blog;
rewrite ^/create-app$ /index.php?link1=create-app;
}

location = /logout {
rewrite ^(.*)$ /index.php?link1=logout;
}

location /contact {
rewrite ^/contact-us$ /index.php?link1=contact-us;
}

location = /messages {
rewrite ^(.*)$ /index.php?link1=messages;
}

location = /albums {
rewrite ^(.*)$ /index.php?link1=albums;
}

location /albums {
rewrite ^/albums/([A-Za-z0-9_-]+)$ /index.php?link1=albums&user=$1;
}

location /album {
rewrite ^/album/([A-Za-z0-9_-]+)$ /index.php?link1=album&id=$1;
}

location /page {
rewrite ^/page-setting/([^/]+)(/|)$ /index.php?link1=page-setting&page=$1;
rewrite ^/page-setting/([A-Za-z0-9_]+)/([A-Za-z0-9_-]+)$ /index.php?link1=page-setting&page=$1&link3=$2;
}

location /group {
rewrite ^/group-setting/([^/]+)(/|)$ /index.php?link1=group-setting&group=$1;
rewrite ^/group-setting/([A-Za-z0-9_]+)/([A-Za-z0-9_-]+)$ /index.php?link1=group-setting&group=$1&link3=$2;
}

location /edit {
rewrite ^/edit-product/([A-Za-z0-9_]+)$ /index.php?link1=edit-product&id=$1;
rewrite ^/edit-blog/(\d+)(/?|)$ /index.php?link1=edit-blog&id=$1;
}

location = /products {
rewrite ^(.*)$ /index.php?link1=products;
}

location /products {
rewrite ^/products/([A-Za-z0-9_-]+)$ /index.php?link1=products&c_id=$1;
}

location /my {
rewrite ^/my-products$ /index.php?link1=my-products;
rewrite ^/my-blogs(/?|)$ /index.php?link1=my-blogs;
}

location /site {
rewrite ^/site-pages/(.*)$ /index.php?link1=site-pages&page_name=$1;
}

location = /blogs {
rewrite ^(.*)$ /index.php?link1=blogs;
}

location = /sharer {
rewrite ^(.*)$ /index.php?link1=sharer;
}

location /blog {
rewrite ^/blog-category/(\d+)(/?|)$ /index.php?link1=blog-category&id=$1;
}

location /read {
rewrite ^/read-blog/(.*)$ /index.php?link1=read-blog&id=$1;
}

location = /app_api {
rewrite ^(.*)$ /index.php?link1=app_api;
}

location /api {
rewrite ^/api(/?|)$ /api-v2.php;
rewrite ^/api/([^/]+)(/|)$ /api-v2.php?type=$1;
}

location = /authorize {
rewrite ^(.*)$ /index.php?link1=authorize;
}

location /events {
rewrite ^/events(/?|)$ /index.php?link1=events;
rewrite ^/events/create-event(/?|)$ /index.php?link1=create-event;
rewrite ^/events/edit/(\d+)/(/?|)$ /index.php?link1=edit-event&eid=$1;
rewrite ^/events/my(/?|)$ /index.php?link1=my-events;
rewrite ^/events/going(/?|)$ /index.php?link1=events-going;
rewrite ^/events/invited(/?|)$ /index.php?link1=events-invited;
rewrite ^/events/interested(/?|)$ /index.php?link1=events-interested;
rewrite ^/events/past(/?|)$ /index.php?link1=events-past;
rewrite ^/events/(\d+)(/?|)$ /index.php?link1=show-event&eid=$1;
}

location /unusual {
rewrite ^/unusual-login$ /index.php?link1=unusual-login;
}

location /movies {
rewrite ^/movies(/?|)$ /index.php?link1=movies;
rewrite ^/movies/genre/([A-Za-z-]+)(/?|)$ /index.php?link1=movies-genre&genre=$1;
rewrite ^/movies/country/([A-Za-z-]+)(/?|)$ /index.php?link1=movies-country&country=$1;
rewrite ^/movies/watch/(\d+)(/?|)$ /index.php?link1=watch-film&film-id=$1;
}

location /wallet {
rewrite ^/wallet(/?|)$ /index.php?link1=wallet;
}

location /status {
rewrite ^/status/create(/?|)$ /index.php?link1=create-status;
}

location /more {
rewrite ^/more-status(/?|)$ /index.php?link1=more-status;
}

location /friends {
rewrite ^/friends-nearby(/?|)$ /index.php?link1=friends-nearby;
}

location /_ {
rewrite ^/_$ /requests.php;
}

location /graph {
rewrite ^/graph-success$ /index.php?link1=graph-success;
}

location = /developers {
rewrite ^(.*)$ /index.php?link1=developers;
}

location = /apps {
rewrite ^(.*)$ /index.php?link1=apps;
}

location = /graph {
rewrite ^(.*)$ /index.php?link1=graph;
}

location = /oauth {
rewrite ^(.*)$ /index.php?link1=oauth;
}

location /boosted {
rewrite ^/boosted-pages$ /index.php?link1=boosted-pages;
rewrite ^/boosted-posts$ /index.php?link1=boosted-posts;
}