VAAMP - part 2
In this three-part series, I'll walk you through setting up a cross-platform LAMP server for local development. I'll be using VirtualBox, Alpine Linux, Apache, MySQL, and PHP so I've nicknamed it VAAMP.
#########
tl;dr
If you don't want to manually perform all the steps below, you can just download the VirtualBox appliance here.
#########
- Part 1: VirtualBox and Alpine Linux setup
- Part 2: Apache, MySQL, and PHP setup
- Part 3: VirtualHost, shared folder, and DNS setup
- Bonus: Quickstart
___________________________________________________
Apache, MySQL, and PHP setup
#########
tl;dr
If you don't want to manually perform all the steps below, you can just download the VirtualBox appliance here.
#########
1. Make sure to follow Part 1 of this guide and login as root
2. Install Apache httpd, MySQL (MariaDB), and PHP-FPM by running this command:
apk add gd mysql curl apache2-proxy php-fpm php-common php-iconv php-json php-gd php-curl php-xml php-mysql php-mysqli php-pdo php-pdo_mysql php-imap php-soap php-xmlrpc php-posix php-mcrypt php-gettext php-ldap php-ctype php-dom php-pear
3. Configure Apache with these commands:
sed -i 's,\(LoadModule mpm_prefork_module modules/mod_mpm_prefork.so\),#\1,g' /etc/apache2/httpd.conf
sed -i 's,#\(LoadModule mpm_event_module modules/mod_mpm_event.so\),\1,g' /etc/apache2/httpd.conf
4. Set httpd-mpm to default values:
cp /etc/apache2/original/extra/httpd-mpm.conf /etc/apache2/conf.d/
5. Assuming you kept the hostname as localhost in Part 1, Step 24, configure PHP via these commands:
sed -i 's,\(DirectoryIndex index.html index.html.var\),#\1,g' /etc/apache2/httpd.conf
echo 'ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/localhost/htdocs/$1' >> /etc/apache2/httpd.conf
echo 'DirectoryIndex index.html index.php' >> /etc/apache2/httpd.conf
echo '<?php phpinfo(); ?>' > /var/www/localhost/htdocs/phpinfo.php
6. Initialize MariaDB:
/etc/init.d/mariadb setup
curl -sLo /var/www/localhost/htdocs/adminer.php http://tinyurl.com/adminer4
7. Add Apache, MariaDB and PHP to the OpenRC init process (so they start at boot) and then start them:
rc-update add apache2 default && rc-update add mariadb default && rc-update add php-fpm default
/etc/init.d/apache2 restart && /etc/init.d/mariadb restart && /etc/init.d/php-fpm restart
8. To test Apache, assuming you used 192.168.50.50 in Part 1, Step 24, open a browser on your host computer and go to http://192.168.50.50/
9. To test PHP, go to http://192.168.50.50/phpinfo.php
10. To test MariaDB, go to http://192.168.50.50/adminer.php and click Login
Congratulations! You've installed a LAMP server on VirtualBox. Head on over to the next post in this series: VirtualHost, shared folder, and DNS setup
_______________
References:
2. Install Apache httpd, MySQL (MariaDB), and PHP-FPM by running this command:
apk add gd mysql curl apache2-proxy php-fpm php-common php-iconv php-json php-gd php-curl php-xml php-mysql php-mysqli php-pdo php-pdo_mysql php-imap php-soap php-xmlrpc php-posix php-mcrypt php-gettext php-ldap php-ctype php-dom php-pear
3. Configure Apache with these commands:
sed -i 's,\(LoadModule mpm_prefork_module modules/mod_mpm_prefork.so\),#\1,g' /etc/apache2/httpd.conf
sed -i 's,#\(LoadModule mpm_event_module modules/mod_mpm_event.so\),\1,g' /etc/apache2/httpd.conf
cp /etc/apache2/original/extra/httpd-mpm.conf /etc/apache2/conf.d/
5. Assuming you kept the hostname as localhost in Part 1, Step 24, configure PHP via these commands:
sed -i 's,\(DirectoryIndex index.html index.html.var\),#\1,g' /etc/apache2/httpd.conf
echo 'ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/localhost/htdocs/$1' >> /etc/apache2/httpd.conf
echo 'DirectoryIndex index.html index.php' >> /etc/apache2/httpd.conf
echo '<?php phpinfo(); ?>' > /var/www/localhost/htdocs/phpinfo.php
6. Initialize MariaDB:
/etc/init.d/mariadb setup
curl -sLo /var/www/localhost/htdocs/adminer.php http://tinyurl.com/adminer4
7. Add Apache, MariaDB and PHP to the OpenRC init process (so they start at boot) and then start them:
rc-update add apache2 default && rc-update add mariadb default && rc-update add php-fpm default
/etc/init.d/apache2 restart && /etc/init.d/mariadb restart && /etc/init.d/php-fpm restart
8. To test Apache, assuming you used 192.168.50.50 in Part 1, Step 24, open a browser on your host computer and go to http://192.168.50.50/
9. To test PHP, go to http://192.168.50.50/phpinfo.php
10. To test MariaDB, go to http://192.168.50.50/adminer.php and click Login
Congratulations! You've installed a LAMP server on VirtualBox. Head on over to the next post in this series: VirtualHost, shared folder, and DNS setup
_______________
References:
Comments
Post a Comment
Keep it clean and professional...