By GokiSoft.com| 17:29 30/10/2021|
SQL Server/MySQL

Toàn Tập - Hướng dẫn cài đặt LAMPP >> build apache2 + mysql + php7.2 + phpmyadmin server ubuntu BT1533

Hướng dẫn cài đặt toàn tập server web - build apache2 + mysql + php7.2 + phpmyadmin server ubuntu

Bước 1: Cập nhật ubuntu

sudo apt update


Bước 2: 

sudo apt install apache2


Bước 3: Cài đặt mysql

sudo apt install mysql-server mysql-client


Bước 4 : Cài đặt PHP 7.2

sudo add-apt-repository ppa:ondrej/php


sudo apt-get update


sudo apt-get install php7.2 libapache2-mod-php7.2 php7.2-mysql


Cài đặt các module liên quan tới PHP7.2


sudo apt install php7.2-curl php7.2-json php7.2-cgi php7.2-common php-pear php7.2-mbstring


apt install php7.2-mbstring php7.2-zip php7.2-xml


Bước 5: Cấu hình apache2 (Phần này có thể bỏ qua)

# Mở file cấu hình

sudo vi /etc/apache2/apache2.conf

# Sửa lại thông tin theo phần sau

KeepAlive On
MaxKeepAliveRequests 50
KeepAliveTimeout 5

# Tối ưu hoá xử lý đa luồng sử dụng module prefork

# Mở file cấu hình

sudo vi /etc/apache2/mods-available/mpm_prefork.conf


# Tối ưu hoá cài đặt đa luồng

StartServers            4
MinSpareServers         3
MaxSpareServers         40
MaxRequestWorkers       200
MaxConnectionsPerChild  10000

# Bật tắt module (Phần này chú ý lệnh => có thể làm hoặc không)

sudo a2dismod mpm_event
sudo a2enmod mpm_prefork

# Cấu hình apache2 sử dụng PHP7.2

sudo a2enconf php7.2-cgi

Khởi động lại Apache2

sudo systemctl restart apache2

Bước 6 : Chỉnh sửa cài đặt apache2 (Mục này quan trọng => Phần này tôi đã cấu hình và enable các mục cần cho web)

# Sửa cấu hình web

sudo vi /etc/apache2/sites-available/000-default.conf

Sửa lại thành


<VirtualHost *:80>
	# The ServerName directive sets the request scheme, hostname and port that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	# ServerName gokisoft.com

	ServerAdmin gokisoft@gmail.com
	<Directory /var/www/html/gokisoft>
    	Options Indexes FollowSymLinks MultiViews
    	AllowOverride All
   	 	Require all granted
	</Directory>
	DocumentRoot /var/www/html/gokisoft

	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Vui lòng sửa gokisoft => thành đường dẫn tương ứng trên server của bạn

Bước 7 : Cài đặt phpmyadmin

sudo apt-get install phpmyadmin php-gettext


Sau khi cài xong cần cài đặt cho phép truy cập phpmyadmin từ apache2

sudo -H vi /etc/apache2/apache2.conf

Thêm vào cuối file dòng lệnh sau

Include /etc/phpmyadmin/apache.conf

Thực hiện reset lại server

sudo systemctl restart apache2

Bây giờ bạn có thể login vào phpmyadmin trên server của bạn. 

URL hoặc địa chỉ IP/phpmyadmin

Trường hợp bạn không login vào được bằng tài khoản root. Vui lòng xem hướng dẫn sau

Hướng dẫn active tài khoản root trong phpmyadmin - ubuntu & linux

Bước 8 : Bật module rewrite URL

sudo a2enmod rewrite

Reset lại server

sudo systemctl restart apache2

Enable header

sudo a2enmod headers

Bước 9 : Hướng dẫn cấu hình phpmyadmin. Cho phép upload file có kích thước lớn + thời gian timeout trên web server

Mở file cấu hình

sudo vi /etc/php/7.2/apache2/php.ini

Tìm kiếm lần lượt các mục sau

post_max_size = 8M
upload_max_filesize = 2M
max_execution_time = 30
max_input_time = 60
memory_limit = 8M

Sửa lại thành (Bạn có thể sửa theo mục đích server của bạn)

post_max_size = 750M
upload_max_filesize = 750M
max_execution_time = 5000
max_input_time = 5000
memory_limit = 1000M


Hướng dẫn cài đặt SSL cho tên miền

Liên kết rút gọn:

https://gokisoft.com/1533

Bình luận