Blog Details

Linux 作業系統 cutexyz > Blog > Linux 服務架設 > 在 Ubuntu Server 中建立 Apache + Php + Mysql + phpMyAdmin

在 Ubuntu Server 中建立 Apache + Php + Mysql + phpMyAdmin

# update system and do the upgrade
sudo apt update && sudo apt upgrade && sudo apt dist-upgrade

# install the packages we need
sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql php-mbstring

# make sure the service is running, check the result show "running"
service apache2 status
service mysql status

# setup mysql root ID / PASSWORD
# login mysql first
sudo mysql

# execute the command, remember to replace the new_password
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new_password';
mysql> flush privileges;

# exit from mysql
mysql> exit

# initial mysql installation
sudo mysql_secure_installation

# enter "y" to these questions
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

# go the home dir of your account and download phpmyadmin
# you may check the latest file download URL by visit "https://www.phpmyadmin.net/downloads/"
cd
wget https://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-all-languages.zip

# install zip unzip packages
sudo apt install zip unzip

#extract the zip files
unzip phpMyAdmin-5.2.1-all-languages.zip

# move phpmyadmin to the website dir
sudo mv phpMyAdmin-5.2.1-all-languages /var/www/html/tool

# add new mysql accoun, wpmaster / new_password with default Authentication plugin
# And auto generate pwd
# or add manually
#Ref: CREATE USER 'wordpress'@'localhost' IDENTIFIED WITH mysql_native_password BY 'abcWE@s123';GRANT USAGE ON *.* TO 'wordpress'@'localhost';ALTER USER 'wordpress'@'localhost' REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;CREATE DATABASE IF NOT EXISTS `wordpress`;GRANT ALL PRIVILEGES ON `wordpress`.* TO 'wordpress'@'localhost';

# 查看 apache2 用什麼帳號在執行
ps aux | egrep '(apache|httpd)'

# adjust the directory permission
chown -R www-data:www-data /var/www


以上步驟需因地制宜!!

Leave A Comment

All fields marked with an asterisk (*) are required