{"id":25960,"date":"2021-12-29T17:29:22","date_gmt":"2021-12-29T10:29:22","guid":{"rendered":"https:\/\/doc.bnix.vn\/?p=25960"},"modified":"2024-10-06T07:25:29","modified_gmt":"2024-10-06T00:25:29","slug":"cach-cai-dat-nginx-only-tren-directadmin","status":"publish","type":"post","link":"https:\/\/doc.bnix.vn\/cach-cai-dat-nginx-only-tren-directadmin\/","title":{"rendered":"C\u00e1ch c\u00e0i \u0111\u1eb7t nginx only tr\u00ean Directadmin"},"content":{"rendered":"\n\n
\n \n
\n \n
\n
\n \n\n
<\/div>\n <\/div>\n
\n \n\n
<\/div>\n <\/div>\n
\n \n\n
<\/div>\n <\/div>\n
\n \n\n
<\/div>\n <\/div>\n
\n \n\n
<\/div>\n <\/div>\n <\/div>\n \n
\n
\n \n\n
<\/div>\n <\/div>\n
\n \n\n
<\/div>\n <\/div>\n
\n \n\n
<\/div>\n <\/div>\n
\n \n\n
<\/div>\n <\/div>\n
\n \n\n
<\/div>\n <\/div>\n <\/div>\n<\/div>\n \n\n
\n 5\/5 - (5 b\u00ecnh ch\u1ecdn) <\/div>\n <\/div>\n\n

Theo m\u1eb7c \u0111\u1ecbnh, Directadmin s\u1ebd c\u00e0i \u0111\u1eb7t webserver l\u00e0 Apache. Apache c\u00f3 m\u1ed9t b\u1ed9 t\u00ednh n\u0103ng r\u1ea5t l\u1edbn (m\u1ed9t trong nh\u1eefng t\u00ednh n\u0103ng quan tr\u1ecdng nh\u1ea5t l\u00e0 c\u00e1c t\u1eadp tin .htaccess), <\/b>Tuy nhi\u00ean v\u1ec1 hi\u1ec7u su\u1ea5t, t\u1ed1c \u0111\u1ed9 kh\u00f4ng th\u1ec3 n\u00e0o so v\u1edbi nginx.<\/p>\n\n\n\n

N\u1ebfu b\u1ea1n th\u00edch t\u1ed1c \u0111\u1ed9 c\u1ee7a nginx v\u00e0 kh\u00f4ng d\u00f9ng g\u00ec t\u1edbi htaccess th\u00ec h\u00e3y l\u00e0m theo h\u01b0\u1edbng d\u1eabn n\u00e0y. L\u00e0m xong s\u1ebd th\u1ea5y hi\u1ec7u su\u1ea5t website c\u1ee7a m\u00ecnh thay \u0111\u1ed5i r\u00f5 r\u1ec7t.<\/p>\n\n\n\n

B\u01b0\u1edbc 1: K\u1ebft n\u1ed1i VPS\/Server qua SSH<\/h3>\n\n\n\n

\u0110\u1ec3 c\u00e0i \u0111\u1eb7t c\u00e1c nginx ho\u1eb7c c\u1ea5u h\u00ecnh cho Directadmin, c\u00e1c b\u1ea1n ph\u1ea3i login SSH v\u1edbi quy\u1ec1n root nh\u00e9.<\/p>\n\n\n\n

B\u01b0\u1edbc 2: Ch\u1ea1y l\u1ec7nh chuy\u1ec3n \u0111\u1ed5i ch\u1ebf \u0111\u1ed9<\/h3>\n\n\n\n

\u1ede \u0111\u00e2y m\u00ecnh s\u1ebd chuy\u1ec3n webserver sang nginx, phi\u00ean b\u1ea3n c\u00e1c php s\u1ebd sang php-fpm<\/p>\n\n\n\n

<\/circle><\/circle><\/circle><\/g><\/svg><\/span><\/path><\/path><\/svg><\/span>
cd<\/span> <\/span>\/usr\/local\/directadmin\/custombuild<\/span><\/span>\n.\/build<\/span> <\/span>set<\/span> <\/span>webserver<\/span> <\/span>nginx<\/span><\/span>\n.\/build<\/span> <\/span>set<\/span> <\/span>php1_mode<\/span> <\/span>php-fpm<\/span><\/span>\n.\/build<\/span> <\/span>set<\/span> <\/span>php2_mode<\/span> <\/span>php-fpm<\/span><\/span>\n.\/build<\/span> <\/span>set<\/span> <\/span>php3_mode<\/span> <\/span>php-fpm<\/span><\/span>\n.\/build<\/span> <\/span>set<\/span> <\/span>php4_mode<\/span> <\/span>php-fpm<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n

B\u01b0\u1edbc 3: C\u00e0i \u0111\u1eb7t nginx v\u00e0 php<\/h3>\n\n\n\n

Sau khi thi\u1ebft l\u1eadp xong m\u00ecnh s\u1ebd ti\u1ebfn h\u00e0nh c\u00e0i m\u1edbi nginx v\u00e0 c\u00e0i l\u1ea1i php cho t\u01b0\u01a1ng th\u00edch v\u1edbi nginx.<\/p>\n\n\n\n

<\/circle><\/circle><\/circle><\/g><\/svg><\/span><\/path><\/path><\/svg><\/span>
.\/build<\/span> <\/span>nginx<\/span><\/span>\n.\/build<\/span> <\/span>php<\/span> <\/span>n<\/span><\/span>\n.\/build<\/span> <\/span>rewrite_confs<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n

B\u01b0\u1edbc 4: C\u1ea5u h\u00ecnh nginx tr\u00e1nh l\u1ed7i 404 tr\u00ean wordpress<\/h3>\n\n\n\n

C\u1ea5u h\u00ecnh nginx m\u1eb7c \u0111\u1ecbnh tr\u00ean Directadmin s\u1ebd g\u00e2y l\u1ed7i 404. C\u00e1c b\u1ea1n th\u1ef1c hi\u1ec7n c\u00e1c b\u01b0\u1edbc sau \u0111\u1ec3 s\u1eeda l\u1ed7i n\u00e0y nh\u00e9.<\/p>\n\n\n\n

<\/circle><\/circle><\/circle><\/g><\/svg><\/span><\/path><\/path><\/svg><\/span>
mkdir<\/span> <\/span>\/usr\/local\/directadmin\/data\/templates\/custom<\/span><\/span>\ncd<\/span> <\/span>\/usr\/local\/directadmin\/data\/templates\/custom<\/span><\/span>\ncp<\/span> <\/span>..\/nginx_php.conf<\/span> <\/span>.<\/span><\/span>\nnano<\/span> <\/span>\/usr\/local\/directadmin\/data\/templates\/custom\/nginx_php.conf<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n

Sau \u0111\u00f3 b\u1ea1n th\u00eam \u0111o\u1ea1n code sau v\u00e0o cu\u1ed1i c\u00f9ng c\u1ee7a file<\/strong>. Th\u00eam xong th\u00ec b\u1ea5m Ctrl + O \u0111\u1ec3 save l\u1ea1i v\u00e0 Ctrl + X \u0111\u1ec3 tho\u00e1t ra<\/p>\n\n\n\n

<\/circle><\/circle><\/circle><\/g><\/svg><\/span><\/path><\/path><\/svg><\/span>
location<\/span> \/ {<\/span><\/span>\n   <\/span> try_files <\/span>$uri $uri\/ \/index.php?$args ;<\/span><\/span>\n}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n

Cu\u1ed1i c\u00f9ng l\u00e0 ch\u1ea1y c\u00e1c l\u1ec7nh sau \u0111\u1ec3 t\u1ea1o l\u1ea1i file c\u1ea5u h\u00ecnh nginx cho t\u1ea5t c\u1ea3 t\u00ean mi\u1ec1n \u0111ang s\u1eed d\u1ee5ng<\/p>\n\n\n\n

<\/circle><\/circle><\/circle><\/g><\/svg><\/span><\/path><\/path><\/svg><\/span>
chown<\/span> <\/span>diradmin:diradmin<\/span> <\/span>nginx_php.conf<\/span><\/span>\ncd<\/span> <\/span>\/usr\/local\/directadmin\/custombuild<\/span><\/span>\n.\/build<\/span> <\/span>rewrite_confs<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n

Qu\u00e1 tr\u00ecnh c\u00e0i \u0111\u1eb7t s\u1ebd t\u1ed1n kh\u00e1 nhi\u1ec1u th\u1eddi gian. H\u00e3y ki\u00ean nh\u1eabn v\u00e0 kh\u00f4ng l\u00e0m gi\u00e1n \u0111o\u1ea1n khi c\u00e0i \u0111\u1eb7t ho\u1eb7c n\u00f3 r\u1ea5t c\u00f3 th\u1ec3 s\u1ebd th\u1ea5t b\u1ea1i v\u00e0 ph\u00e1 v\u1ee1 c\u00e1c m\u00e1y ch\u1ee7.<\/p>\n\n\n\n

Bonus<\/h3>\n\n\n\n

Ngo\u00e0i ra, \u0111\u1ec3 tr\u00e1nh b\u1ecb gi\u00e1n \u0111o\u1ea1n qu\u00e1 tr\u00ecnh c\u00e0i \u0111\u1eb7t do m\u1ea5t k\u1ebft n\u1ed1i m\u1ea1ng. C\u00e1c b\u1ea1n d\u1ee5ng ch\u1ebf \u0111\u1ed9 screen trong qu\u00e1 tr\u00ecnh c\u00e0i \u0111\u1eb7t nh\u00e9.<\/p>\n\n\n\n

<\/circle><\/circle><\/circle><\/g><\/svg><\/span><\/path><\/path><\/svg><\/span>
yum<\/span> <\/span>-y<\/span> <\/span>install<\/span> <\/span>screen<\/span><\/span>\nscreen<\/span> <\/span>-S<\/span> <\/span>setupnginx<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n

Gi\u1ea3 s\u1eed m\u1ea5t m\u1ea1ng trong qu\u00e1 tr\u00ecnh c\u00e0i \u0111\u1eb7t, h\u00e3y k\u1ebft n\u1ed1i SSH l\u1ea1i. Sau \u0111\u00f3 ch\u1ea1y l\u1ec7nh sau \u0111\u1ec3 m\u1edf l\u1ea1i m\u00e0n h\u00ecnh c\u00e0i \u0111\u1eb7t<\/p>\n\n\n\n

<\/circle><\/circle><\/circle><\/g><\/svg><\/span><\/path><\/path><\/svg><\/span>
screen<\/span> <\/span>-r<\/span> <\/span>-d<\/span> <\/span>setupnginx<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n

Ch\u00fac c\u00e1c b\u1ea1n c\u00e0i \u0111\u1eb7t th\u00e0nh c\u00f4ng<\/p>\n","protected":false},"excerpt":{"rendered":"

Theo m\u1eb7c \u0111\u1ecbnh, Directadmin s\u1ebd c\u00e0i \u0111\u1eb7t webserver l\u00e0 Apache. Apache c\u00f3 m\u1ed9t b\u1ed9 t\u00ednh…<\/p>\n","protected":false},"author":3,"featured_media":25939,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[195,49],"tags":[193,209,208],"class_list":["post-25960","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cai-dat-vps-directadmin","category-linux","tag-nginx","tag-nginx-on-directadmin","tag-nginx-only"],"_links":{"self":[{"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/posts\/25960","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/comments?post=25960"}],"version-history":[{"count":0,"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/posts\/25960\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/media\/25939"}],"wp:attachment":[{"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/media?parent=25960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/categories?post=25960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/doc.bnix.vn\/wp-json\/wp\/v2\/tags?post=25960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}