This video covers setting up a LAMP stack (Linux+Apache+MySQL(Maria)+PHP) in Alpine Linux. Alpine is a super lightweight distro popular with developers using Docker, but also a valid choice for VM work or standalone implementation.
This video walks through the process of setting up the various components of LAMP, though omits the Alpine install (it takes minutes if you know what you want and what your doing - select sys). Overall I'm quite impressed with Alpine, though there would certainly be conveniences just running Ubuntu Server, Alpine does the job with a fraction of the CPU/memory/capacity/cruft so if you can figure out how it can work for you, I think its worth a look.
Here are the steps shown in the video:
Alpine LAMP deployment
apk add apache2
apk add mariadb mariadb-client
rc-service start apache2
Check the homepage at the machine's IP, confirm you see 'It works'
Source files are located in /var/www/localhost/htdocs#
Ensure repositories are added - /etc/apk/repositories <- uncomment commmunity and edge
apk add php7 php7-mysqli phpmyadmin php7-apache2
service restart apache2
Create php test doc - nano phpinfo.php
service mariadb start
Setup Maria
Error message appears, need to first run the /etc/init.d/mariadb setup
Re-run service mariadb start
Then we change the password for mariadb root user (this gets created on the system by the mariadb-client).
Run mysql_secure_installation
Walk through the prompts to set a root user password
Setup phpmyadmin
chmod -R 777 /usr/share/webapps/phpmyadmin
chmod 755 /etc/phpmyadmin/config.inc.php
ln -s /usr/share/webapps/phpmyadmin/ /var/www/localhost/htdocs/phpmyadmin
Setup phpmyadmin user in MariaDB
mysql -u root -p
- enter password
>CREATE USER 'pmauser'@'%' IDENTIFIED BY '<password of choice>';
>GRANT ALL PRIVILEGES ON *.* TO 'pmauser'@'%' WITH GRANT OPTION;
>FLUSH PRIVILEGES;
Open page server IP/phpmyadmin.
Enter the pmauser and given password.
Now phpmyadmin can be used to manage the mariadb and create new databases
<missed this in the video>
To ensure services start on boot need to run
rc-update add <service name>
The last line are steps to ensure apache2 and mariadb are started if the system reboots, an 'auto-restart' or 'start on boot' behavior.
References I found helpful for setting this up are below:
I do understand that this stack isn't necessarily the best in terms of performance or security, its simply the 'bare-minimum' to start developing. For optimization I'd suggest reading more on general Apache or NGINX settings, as well as looking to additional 3rd party sources about the various ways to integrate PHP with a web server.
No comments:
Post a Comment