Cov txheej txheem:

Txhim kho LAMP (Linux, Apache, MySQL, PHP) ntawm Raspberry Pi: 7 Kauj Ruam
Txhim kho LAMP (Linux, Apache, MySQL, PHP) ntawm Raspberry Pi: 7 Kauj Ruam

Video: Txhim kho LAMP (Linux, Apache, MySQL, PHP) ntawm Raspberry Pi: 7 Kauj Ruam

Video: Txhim kho LAMP (Linux, Apache, MySQL, PHP) ntawm Raspberry Pi: 7 Kauj Ruam
Video: Tự học Docker siêu tốc trong 10 phút (Có code mẫu và ví dụ) - Code Dạo Dễ Òm 2024, Kaum ib hlis
Anonim
Txhim kho LAMP (Linux, Apache, MySQL, PHP) ntawm Raspberry Pi
Txhim kho LAMP (Linux, Apache, MySQL, PHP) ntawm Raspberry Pi

Teeb LAMP (Linux Rasbian Stretch Lite, Apache2, MySQL (MariaDB-10), PHP7) pawg nrog PHPMyAdmin thiab FTP nkag mus rau koj li Raspberry Pi thiab teeb tsa nws ua haujlwm li lub web server.

Koj yuav xav tau lub khoos phis tawj Raspberry Pi txuas nrog internet nrog 8GB (lossis ntau dua) MicroSD daim npav. Thaum xub thawj koj yuav tsum muaj peev xwm teeb tsa Raspi-teeb tsa nrog cov keyboard kom hloov pauv tus lej Raspbian tsis raug thiab pab kom SSH. Thaum Raspi-teeb tsa tau ua tiav koj yuav tsuas yog xav tau txuas ntawm SSH kev sib txuas.

Koj yuav tsum muaj peev xwm teeb tsa cov duab Rasbian rau MicroSD daim npav, koj yuav xav paub txog kev tuaj yeem SSH rau Raspberry Pi thiab tuaj yeem teeb tsa koj li SQL database siv PHPMyAdmin.

Qhov twg koj pom $, qhov no yog cov lus txib koj yuav tsum tau muab tshuaj txhuam/siv los teeb tsa thiab teeb tsa software.

Kauj Ruam 1: ## Raspbian Duab ##

Tsim Raspbian Stretch Lite duab rau MicroSD daim npav (> 8GB pom zoo)

Thaum RasPi tau pib nkag mus nrog Tus Neeg Siv Npe: pi Password: raspberry

ces

$ hostname -I

(Nco tseg IP chaw nyob, koj yuav xav tau qhov no rau SSH rau RasPi piv txwv li 192.168.0.100)

$ sudo raspi-teeb tsa

Qhov Xaiv 1 - 'Hloov Tus Neeg Siv Tus Password'> Ok> Nkag mus rau UNIX tus lej tshiab> Retype tus password tshiab> Ok

Kev Xaiv 5 - 'Kev Xaiv Ua Haujlwm'> 'P2 SSH'> Yog Tab rau 'Ua tiav'> Nkag mus

$ sudo rov pib dua

Kauj ruam 2: ## Hloov kho Raspbian ##

Tam sim no siv Putty txuas rau RPi siv tus IP chaw nyob los ntawm yav dhau los.log hauv nrog Username: pi & koj tus password

$ sudo apt hloov tshiab && sudo apt hloov tshiab -y

$ sudo rov pib dua

Kauj ruam 3: ## Nruab Apache2 ##

Ib zaug ntxiv siv Putty txuas rau RPi siv tus IP chaw nyob ua ntej.

nkag mus nrog Username: pi & koj tus password

$ sudo apt nruab apache2 -y

Thaum ua tiav txhim kho Apache2 qhib lub vev xaib ntawm tib lub Wi-nkaus network thiab sau tus IP chaw nyob ntawm RasPi. Yog Apache2 teeb tsa kom raug koj yuav pom nplooj ntawv uas hais tias 'Apache2 Debian Default Page' thiab 'Nws ua haujlwm!'.

$ sudo a2enmod rov sau dua

$ sudo systemctl rov pib dua apache2

$ sudo chown -R pi: www -data/var/www/html/

$ sudo chmod -R 770/var/www/html/

$ sudo nano /etc/apache2/apache2.conf

Nrhiav: (Koj tuaj yeem siv Ctrl & W nrhiav)

Cov npe/var/www/

Options Indexes FollowSymLinks AllowOverride Tsis muaj Yuav tsum tau txhua qhov tso cai /Cov npe

Hloov mus rau:

Cov npe/var/www/Options Indexes FollowSymLinks

AllowOverride Txhua

Yuav tsum tau txhua qhov kev tso cai

/Cov npe

Ctrl & O> Nkag mus> Ctrl & X

$ sudo kev pabcuam apache2 rov pib dua

Kauj ruam 4: ## Nruab PHP7 ##

$ sudo apt nruab php libapache2-mod-php -y

Xeem PHP

Koj yuav tsum xub tshem tawm cov ntawv "index.html" hauv cov npe "/var/www/html".

$ sudo rm /var/www/html/index.html

Tom qab ntawd tsim "index.php" cov ntaub ntawv hauv cov npe no, nrog kab lus hais kom ua no

$ echo ""> /var/www/html/index.php

Hloov kho lub vev xaib broswer ntawm tib lub Wi-nkaus network, tam sim no koj yuav tsum pom PHP cov ntaub ntawv nplooj ntawv.

Kauj ruam 5: ## Nruab MySQL ##

$ sudo apt nruab mysql-server php-mysql -y

$ sudo kev pabcuam apache2 rov pib dua

$ sudo mysql_secure_installation

Koj yuav raug nug kom nkag mus lo lus zais tam sim no rau lub hauv paus (lub neej ntawd tsis muaj dab tsi): nias Enter.

Teem tus password nkag mus, ntaus Y thiab nias Enter.

Ntaus tus password tshiab thiab nias Enter. Tseem ceeb: nco ntsoov lub hauv paus lo lus zais.

Rov nkag tus password tshiab thiab nias Enter.

Ntaus Y thiab nias Enter kom tshem tawm cov neeg siv tsis qhia npe.

Ntaus Y thiab nias Enter kom tsis pom lub hauv paus nkag mus deb.

Ntaus Y thiab nias Enter kom tshem tawm cov ntawv xeem thiab nkag mus rau nws.

Ntaus Y thiab nias Enter kom rov qab tau cov cai tshwj xeeb tam sim no.

Thaum ua tiav, koj yuav pom cov lus Tag nrho ua tiav! thiab Ua tsaug rau siv MariaDB !.

$ sudo mysql -uroot -p

Nkag mus rau lo lus zais hauv paus.

$ tsim database YOURDATABASENAME;

$ YOOJ YIM YOOJ YIM YOOJ YIM RAU KOJ DATABASENAME.* TO 'hauv paus'@'localhost' IDENTIFIED BY 'YOURROOTPASSWORD';

$ FLUSH PRIVILEGES;

Ctrl & D.

Kauj Ruam 6: ## Nruab PHPMyAdmin ##

$ sudo apt nruab phpmyadmin -y

Xaiv Apache2 nrog tus cursor thiab nias lub spacebar kom pom meej Apache2> Tab> Nkag mus.

Configure database rau phpmyadmin nrog dbconfig-ntau? Xaiv 'Tsis Yog'> Nkag mus, peb twb tau teeb tsa cov ntaub ntawv saum toj no nrog MySQL teeb tsa.

Txhawm rau nkag mus rau phpmyadmin siv tus IP chaw nyob ntawm RasPi xws li 192.168.0.100/phpmyadmin/ Username: hauv paus thiab YOURROOTPASSWORD

Kauj ruam 7: ## Teeb tsa FTP ##

$ sudo apt nruab vsftpd -y

$ sudo nano /etc/vsftpd.conf

Nrhiav: (Koj tuaj yeem siv Ctrl & W nrhiav)

local_enable = YOG

ssl_enable = NO

Hloov mus rau:

#local_enable = YOG

#ssl_enable = TSIS TAU

Ntxiv rau hauv qab ntawm cov ntawv:

# CUSTOMssl_enable = YES local_enable = YES chroot_local_user = YES local_root =/var/www user_sub_token = pi write_enable = YES local_umask = 002 allow_writeable_chroot = YES ftpd_banner = Zoo siab txais tos rau kuv qhov kev pabcuam Raspberry Pi FTP.

Ctrl & O> Nkag mus> Ctrl & X

$ sudo usermod -a -G www -data pi

$ sudo usermod -m -d /var /www pi

$ sudo chown -R www-data: www-data /var /www

$ sudo chmod -R 775 /var /www

$ sudo rov pib dua

Tam sim no cov txheej txheem tiav.

Pom zoo: