LAMP (software bundle): Difference between revisions
Line 27: | Line 27: | ||
===Installing PHP=== | ===Installing PHP=== | ||
[https://www.cloudbooklet.com/how-to-install-php-7-3-on-ubuntu-18-04/ Reference]<br> | [https://www.cloudbooklet.com/how-to-install-php-7-3-on-ubuntu-18-04/ Reference]<br> | ||
Installing PHP 7.3 on Ubuntu | Installing PHP 7.3 on Ubuntu 18.04 | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
sudo apt install software-properties-common | sudo apt install software-properties-common | ||
Line 46: | Line 46: | ||
* Always use a version when installing things if you don't want things to break when you do updates | * Always use a version when installing things if you don't want things to break when you do updates | ||
** I.e. <code>php7.3-common</code> instead of <code>php-common</code> | ** I.e. <code>php7.3-common</code> instead of <code>php-common</code> | ||
===Installing MariaDB=== | ===Installing MariaDB=== |
Revision as of 16:46, 27 November 2020
How to setup a lamp stack using Ubuntu.
Linux, Apache, MariaDB, PHP
Setup
Install Ubuntu
Download and install the latest Ubuntu LTS.
If you need VNC, I recommend downloading Ubuntu Desktop and installing x11vnc, lightdm, and cinnamon.
If you don't need a desktop or are low on storage, you can just install Ubuntu Server.
- Note
- Other popular linux distros for servers are Debian and CentOS.
- See Linux distributions for more info.
- I do not have much experience with these RHEL distros: Fedora, CentOS.
Install Apache
See [1]
sudo apt update
sudo apt install apache2
# Enable some basic modules
sudo a2enmod rewrite
Installing PHP
Reference
Installing PHP 7.3 on Ubuntu 18.04
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.3
# Install apache module for php
sudo apt install libapache2-mod-php7.3
sudo a2enmod php7.3
# Install some common extensions
sudo apt install php7.3-common php7.3-mysql php7.3-xml php7.3-xmlrpc php7.3-curl php7.3-gd php7.3-imagick php7.3-cli php7.3-dev php7.3-imap php7.3-mbstring php7.3-opcache php7.3-soap php7.3-zip php7.3-intl -y
# Restart apache2
sudo service apache2 restart
- Important Notes
- Always use a version when installing things if you don't want things to break when you do updates
- I.e.
php7.3-common
instead ofphp-common
- I.e.
Installing MariaDB
See https://downloads.mariadb.org/mariadb/repositories/
sudo apt-get install software-properties-common
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.4/ubuntu bionic main'
sudo apt update
sudo apt install mariadb-server
Securing for Production
MariaDB and MySQL provide a bash command mysql_secure_installation
.
This command does the following:
- Sets a root password
- Remove anonymous users
- Disallow root login remotely
- Removes test databases
sudo mysql_secure_installation
Misc
- Install nodejs via nvm
Firewall
If you're using a VPS or computer connected directly to the internet, you will want to install a firewall.
See UbuntuWiki: UncomplicatedFirewall
See Digital ocean ufw essentials
sudo ufw allow ssh/tcp
sudo ufw logging on
sudo ufw enable
sudo ufw status
You should get an output like:
Status: active To Action From -- ------ ---- 22/tcp ALLOW Anywhere 22/tcp (v6) ALLOW Anywhere (v6)
To enable certain ports:
ufw allow 80/tcp ufw allow 443/tcp