Công cụ thành viên

Công cụ trang web


web_server:cai-dat-lemp-cho-centos6

Khác biệt

Đây là những khác biệt giữa hai phiên bản của trang.

Liên kết đến bản xem so sánh này

Phiên bản sau
Phiên bản trước
Phiên bản cuốiPhiên bản sau của cả hai bên
web_server:cai-dat-lemp-cho-centos6 [2015/03/25 23:30] – được tạo ra vuthaoweb_server:cai-dat-lemp-cho-centos6 [2016/08/01 18:20] vuthao
Dòng 1: Dòng 1:
 ====== Cài đặt LEMP cho VPS để chạy NukeViet 4 ====== ====== Cài đặt LEMP cho VPS để chạy NukeViet 4 ======
- 
- 
  
 ===== Nạp package cần thiết ===== ===== Nạp package cần thiết =====
-Đầu tiên bạn hãy nhớ rằng, serie này mình viết dành cho hệ điều hành CentOS 6.5 trở lên nên bạn cần có một VPS sử dụng CentOS 6.5 và chưa cài bất cứ cái gì vào, sau đó cập nhật những gói update+Bài viết dành cho hệ điều hành CentOS 6.5 trở lên nên bạn cần có một VPS sử dụng CentOS 6.5 và chưa cài bất cứ cái gì vào, sau đó cập nhật những gói update
  
 <code> <code>
Dòng 129: Dòng 127:
 </code> </code>
  
-(Đang cp nhật)+ 
 +===== Cài đặt MariaDB ===== 
 + 
 +Để cài đặt MariaDB trên CentOS 6.5, bạn cần thêm một repository sau vào hệ thống bằng cách chạy lệnh sau: 
 +<code> 
 +yum install wget 
 +wget -O /etc/yum.repos.d/MariaDB.repo http://mariadb.if-not-true-then-false.com/rhel/$(rpm -E %rhel)/$(uname -i)/10 
 +</code> 
 + 
 +Cài đặt hoặc update MariaDB 
 + 
 +<code> 
 +yum install -y MariaDB MariaDB-server 
 +</code> 
 + 
 + 
 +Khởi động MariaDB và tự động chạy khi boot 
 +<code> 
 +service mysql start 
 +chkconfig --levels 235 mysql on 
 +</code> 
 + 
 +Bắt đầu cài đặt 
 + 
 +Chạy lệnh 
 +<code> 
 +/usr/bin/mysql_secure_installation 
 +</code> 
 +Ngay bước đầu tiên bạn sẽ bị hỏi root password, do mới cài đặt nên tất nhiên chưa có password, nhấn Enter để tiếtục 
 + 
 + Output tương tự như sau: 
 +<code> 
 +NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB 
 +      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY! 
 + 
 +In order to log into MariaDB to secure it, we'll need the current 
 +password for the root user.  If you've just installed MariaDB, and 
 +you haven't set the root password yet, the password will be blank, 
 +so you should just press enter here. 
 + 
 +Enter current password for root (enter for none):  
 +OK, successfully used password, moving on... 
 + 
 +Setting the root password ensures that nobody can log into the MariaDB 
 +root user without the proper authorisation. 
 + 
 +Set root password? [Y/n] y 
 +New password:  
 +Re-enter new password:  
 +Password updated successfully! 
 +Reloading privilege tables.. 
 + ... Success! 
 + 
 + 
 +By default, a MariaDB installation has an anonymous user, allowing anyone 
 +to log into MariaDB without having to have a user account created for 
 +them.  This is intended only for testing, and to make the installation 
 +go a bit smoother.  You should remove them before moving into a 
 +production environment. 
 + 
 +Remove anonymous users? [Y/n] y 
 + ... Success! 
 + 
 +Normally, root should only be allowed to connect from 'localhost' This 
 +ensures that someone cannot guess at the root password from the network. 
 + 
 +Disallow root login remotely? [Y/n] y 
 + ... Success! 
 + 
 +By default, MariaDB comes with a database named 'test' that anyone can 
 +access.  This is also intended only for testing, and should be removed 
 +before moving into a production environment. 
 + 
 +Remove test database and access to it? [Y/n] y 
 + - Dropping test database... 
 + ... Success! 
 + - Removing privileges on test database... 
 + ... Success! 
 + 
 +Reloading the privilege tables will ensure that all changes made so far 
 +will take effect immediately. 
 + 
 +Reload privilege tables now? [Y/n] y 
 + ... Success! 
 + 
 +Cleaning up... 
 + 
 +All done!  If you've completed all of the above steps, your MariaDB 
 +installation should now be secure. 
 + 
 +Thanks for using MariaDB! 
 +</code> 
 + 
 +====== Cài đặt NukeViet 4 ====== 
 +Chạy lần lượt các lệnh sau để download code mới nhất 
 + 
 +<code> 
 +yum install wget unzip 
 +cd /usr/share/nginx/html/ 
 +wget https://github.com/nukeviet/nukeviet/archive/develop.zip 
 +unzip develop.zip  
 +mv nukeviet-develop/* ./ 
 +chown -R nginx:nginx ./ 
 +</code> 
 + 
 +Bây giờ bạn hãy truy cp vào địa chỉ là http://ip-vps/nukeviet rồi thực hiện cài đặbình thường nhé, đến bước kiểm tra rewite không được cứ bỏ qua nó nhé. 
 + 
 +===== Cấu hình rewite ===== 
 + 
 +Hãy mở file default.conf trong thư mục /etc/nginx/conf.d/ 
 +tìm đến đoạn sau (đã sửa lúc trước) 
 +<code> 
 +    location ~ \.php$ { 
 +        root           /usr/share/nginx/html; 
 +        fastcgi_pass   127.0.0.1:9000; 
 +        fastcgi_index  index.php; 
 +        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; 
 +        include        fastcgi_params; 
 +    } 
 +</code> 
 + 
 +Thêm lên trên đoạn sau: 
 +<code> 
 + if ($request_filename ~ /robots.txt$){ 
 + rewrite ^(.*)$ /robots.php?action=$http_host break; 
 + }  
 + 
 + rewrite ^/(.*?)sitemap\.xml$ /index.php?nv=SitemapIndex break; 
 + rewrite "^/(.*?)sitemap\-([a-z]{2})\.xml$" /index.php?language=$2&nv=SitemapIndex break; 
 + rewrite "^/(.*?)sitemap\-([a-z]{2})\.([a-zA-Z0-9-]+)\.xml$" /index.php?language=$2&nv=$3&op=sitemap break; 
 + 
 + if (!-e $request_filename){ 
 + rewrite (.*)(\/|\.html)$ /index.php; 
 + rewrite /(.*)tag/(.*)$ /index.php; 
 +
 +  
 + rewrite ^/seek\/q\=([^?]+)$ /index.php?nv=seek&q=$1 break; 
 + rewrite ^/search\/q\=([^?]+)$ /index.php?nv=news&op=search&q=$1 break; 
 + rewrite ^/([a-zA-Z0-9\-]+)\/search\/q\=([^?]+)$ /index.php?nv=$1&op=search&q=$2 break;  
 + rewrite ^/([a-zA-Z0-9-\/]+)\/([a-zA-Z0-9-]+)$ /$1/$2/ break;  
 + rewrite ^/([a-zA-Z0-9-]+)$ /$1/ break;  
 + 
 + location ~ ^/admin/([a-z0-9]+)/(.*)$ { 
 + deny all; 
 +
 + 
 + location ~ ^/(config|includes|install|vendor|MySqlAdmin)/(.*)$ { 
 + deny all; 
 +
 + 
 + location ~ ^/data/(cache|ip|ip6|logs)/(.*)$ { 
 + deny all; 
 +
 + 
 + location ~ ^/(files|uploads|themes)/(.*).(php|ini|tpl|php3|php4|php5|phtml|shtml|inc|pl|py|jsp|sh|cgi)$ { 
 + deny all; 
 + }  
 +</code> 
 + 
 +Lưu lại và Khởi động lại PHP-FPM 
 +<code> 
 +service php-fpm restart 
 +service nginx restart 
 +</code> 
 + 
 +Sửa file data/config_global.php của nukeviet 
 + 
 +tìm đến dòng 
 +<code> 
 +$sys_info['supports_rewrite']=false; 
 +</code> 
 + 
 +Sửa thành 
 +<code> 
 +$sys_info['supports_rewrite']='rewrite_mode_apache'; 
 +</code> 
 + 
 +Đăng nhập quản trị site, vào menu Cấu hình -> Cấu hình chung lưu lại. 
 + 
 +Ra ngoài site để kiểm tra rewite. 
 + 
 +------- 
 + 
 +Bài viết có tham khảo từ: 
 + 
 +http://thachpham.com/hosting-domain/lemp-cho-vps-phan-4-cai-dat-mariadb.html 
 + 
 +http://hocvps.com/huong-dan-cai-dat-lemp-linux-nginx-mariadb-php-tren-centos/
web_server/cai-dat-lemp-cho-centos6.txt · Sửa đổi lần cuối: 2016/08/01 18:33 bởi vuthao