Last active
February 11, 2019 21:55
-
-
Save mrfolkblues/e9462d199dfd41e56b46d9b54d4444c2 to your computer and use it in GitHub Desktop.
Setup instructions for creating a LAMP server that uses MariaDB 10 and PHP 5.6. Based on an Ubuntu 16.04 system on DigitalOcean.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Initial Setup and install apache | |
apt-get update | |
apt-get -y install git curl vim | |
apt-get install -y apache2 libapache2-mod-fastcgi | |
a2enmod actions fastcgi rewrite | |
sudo service apache2 restart | |
# Edit /etc/apache2/sites-available/000-default.conf to add these lines: | |
<Directory "/var/www/html"> | |
Options FollowSymLinks | |
AllowOverride All | |
Require all granted | |
</Directory> | |
sudo service apache2 restart | |
# Install MariaDB | |
export DEBIAN_FRONTEND=noninteractive | |
debconf-set-selections <<< 'mariadb-server-10.0 mysql-server/root_password password ROOT_DB_PASSWORD' | |
debconf-set-selections <<< 'mariadb-server-10.0 mysql-server/root_password_again password ROOT_DB_PASSWORD' | |
apt-get install -y mariadb-server | |
# Set MariaDB root user password and persmissions | |
# change the password | |
mysql -u root -pROOT_DB_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'ROOT_DB_PASSWORD' WITH GRANT OPTION; FLUSH PRIVILEGES;" | |
# create a user for the web server so the application can connect | |
mysql -u root -pROOT_DB_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO 'WEB_USER_NAME'@'localhost' IDENTIFIED BY 'NEW_PASSWORD' WITH GRANT OPTION; FLUSH PRIVILEGES;" | |
# create a user with external access for connection to database | |
# you may need to connect with an SSH key | |
# change to an IP address you're connecting from (wildcards if you like) | |
mysql -u root -pROOT_DB_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO 'EXTERNAL_USER_NAME'@'IP_YOU_CONNECT_FROM' IDENTIFIED BY 'NEW_PASSWORD' WITH GRANT OPTION; FLUSH PRIVILEGES;" | |
# allowing external database connections | |
# Edit /etc/mysql/mariadb.conf.d/50-server.cnf | |
# comment out the line that says: | |
bind-address = 127.0.0.1 | |
# you may need to add a ufw rule also | |
sudo ufw allow from IP_YOU_CONNECT_FROM to any port 3306 | |
# Restart MariaDB | |
sudo service mysql restart | |
# Install PHP 5.6 | |
apt-get install python-software-properties | |
add-apt-repository ppa:ondrej/php | |
apt-get update | |
apt-get install -y php5.6 | |
apt-get install -y php5.6-gd php5.6-mysql php5.6-mbstring php5.6-cli php5.6-curl php5.6-xml php5.6-json php5.6-cgi php-imagick php5.6-bz2 php5.6-zip php5.6-soap | |
a2enmod php5.6 | |
# let the apache user own the web folders | |
sudo chown -R www-data:www-data /var/www | |
sudo service apache2 restart | |
# should all work now! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment