Skip to content

Blog Công Nghệ

MENUMENU
  • Trang chủ
  • Giới Thiệu
  • Lập Trình
    • Lập Trình Website
      • Laravel
        • Phân Tích Dự Án
      • PHP
      • SQL
      • HTML
      • CSS
      • Javascipt
      • My Project
      • Wordpress
    • Luyện Skill
    • Lập trình winform
    • CSDL
    • Lập Trình Android
    • Trí tuệ nhân tạo
    • Khai Khoáng Dữ Liệu
    • Arduino
    • Khác
    • Đồ án
  • Phần Mềm
    • Powerpoint
    • Tool
  • Cuộc sống và Giải trí
    • Hợp âm
    • web5ngay - youtube
    • Công Giáo
    • Kỹ Năng Sống
    • Street Workout
  • Danh sách bài viết
  • Guide line
    • Guild line phỏng vấn
    • Guide lines Laravel
    • Guide line Module Frontend
  • Tóm tắt sách
  • Fanpage

Blog Công Nghệ

Nơi chia sẻ kiến thức

Kinh nghiệm VPS Linux

30 Tháng Một, 2024 by admin
Lượt xem: 38

Contents

  • 1. Cài web server
  • 2. Cài git
  • 3. Cài mysql
  • 4. Kinh nghiệm
    • 4.1 Access denied khi kết nối database bằng ứng dụng khác

1. Cài web server

Cài web server: https://vietnix.vn/cai-dat-apache-web-server-tren-centos-7/

Lưu ý ở bước bật cổng 80, 443. Trước khi bật hãy bật firewall bằng lệnh sau:

sudo systemctl enable firewalld

Các bước làm: chạy lần lượt các câu lệnh sau:

sudo yum update httpd
sudo yum install httpd
sudo systemctl enable firewalld
systemctl restart firewalld
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
sudo systemctl start httpd
sudo systemctl status httpd
  1. cập nhật httpd package index cục bộ để nhận những thay đổi mới nhất
  2. cài đặt các gói
  3. Bật firewalld
  4. Restart filewalld
  5. Bật cổng 80
  6. Bật cổng 443
  7. Reload firewall
  8. Start apache
  9. Check status apache

2. Cài git

https://www.digitalocean.com/community/tutorials/how-to-install-git-on-centos-7

Các bước thực hiện: Chạy lần lượt các câu lệnh sau:

sudo yum install git
git --version
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --list
  1. Cài đặt git
  2. Check git đã cài đặt
  3. Cấu hình user.name
  4. Cấu hình user.mail
  5. Check config

3. Cài mysql

Hướng dẫn cài đặt LEMP trên CentOS

Phần 1, 2

https://support.cloudzone.vn/knowledge-base/huong-dan-dat-lai-mat-khau-root-cua-mysql-hoac-mariadb-tren-centos-7/

Cài PhpMyAdmin https://wiki.tino.org/install-phpmyadmin-centos-7/ (Mục install PhpMyAdmin CentOS 7 – Apache)

Lưu ý: Những chữ PhpMyAdmin => phpMyAdmin (chữ đầu không viết hoa)

https://arrowtran.com/2020/01/03/sua-loi-you-dont-have-permission-to-access-phpmyadmin-on-this-server/


Các bước thực hiện:

Cài PHP

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install php70w php70w-fpm php70w-opcache
php -v
systemctl enable php-fpm

Đối với các phiên bản PHP thấp hơn muốn cấp lên PHP 7 thì cần thận trọng cân nhắc để đảm bảo việc update không ảnh hưởng tới hoạt động ổn định của hệ thống sau khi nâng cấp. Trong trường hợp bạn vẫn muốn nâng cấp,  bạn có thể thực hiện:

yum install yum-plugin-replace
yum replace php-common --replace-with=php70w-common

Tiếp tục cài MySQL:

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update -y
sudo yum install -y  mysql-server
sudo systemctl start mysqld
systemctl enable mysqld
// đổi mật khẩu mysql
mysql --version
sudo systemctl stop mysql
sudo mysqld_safe --skip-grant-tables --skip-networking &
service mysqld start
mysql -u root
FLUSH PRIVILEGES;
// Phiên bản MySQL 5.7.6 và mới hơn
	ALTER USER 'root'@'localhost' IDENTIFIED BY 'password mới';
// Với các phiên bản cũ hơn
	SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password mới');
exit
sudo kill `cat /var/run/mysqld/mysqld.pid`
sudo systemctl start mysql
mysql -u root -p

Tiếp theo cài PhpMyAdmin

sudo yum install phpMyAdmin
sudo vi /etc/httpd/conf.d/phpMyAdmin.conf
<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       #Require ip 127.0.0.1
       #Require ip ::1
       Require all granted
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1  // ========> change to ip server
     Allow from ::1
   </IfModule>
</Directory>

Change dòng 16 thành ip server

sudo systemctl restart httpd.service
sudo systemctl restart httpd

Truy cập ip/phpmyadmin để check hoạt động không?

4. Kinh nghiệm

4.1 Access denied khi kết nối database bằng ứng dụng khác

// thay username and password tương ứng
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'Password' with grant option; 

FLUSH PRIVILEGES;

Tham khảo: https://stackoverflow.com/questions/8380797/enable-remote-mysql-connection-error-1045-28000-access-denied-for-user

Cách khác vào db bằng phpmyadmin và check quyền chỗ host phải là % không? Nếu còn localhost thì ứng dụng khác không kết nối vào được.

Related posts:

  1. Kinh nghiệm Linux
  2. Kinh Nghiệm Docker
  3. Jenkins – Để làm một lập trình viên cao cấp
  4. AWS – Amazon

Post navigation

Previous Post:

Kinh nghiệm ThreeJS – WebAR

Next Post:

SMTP google và WP Mail SMTP Plugin

Trả lời Hủy

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

Ẩn sidebar

Tìm kiếm

Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages

Blog Công Nghệ

Bài viết mới

  • Master typescript
  • Sendmail trong Laravel sử dụng dịch vụ SES, SQS của Amazon
  • Install SSL in Nginx Ubuntu
  • Docker study
  • Bảo vệ: Hướng dẫn code bot Telegram easy game

Lượng truy cập

0074507
Visit Today : 103
Visit Yesterday : 178
This Month : 778
Who's Online : 5
© 2025 Blog Công Nghệ | WordPress Theme by Superbthemes