LAMP (software bundle): Difference between revisions
(27 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
==Setup== | ==Setup== | ||
===Install Ubuntu=== | ===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=== | ===Install Apache=== | ||
See [https://ubuntu.com/tutorials/install-and-configure-apache] | |||
<syntaxhighlight lang="bash"> | |||
sudo apt update | |||
sudo apt install apache2 | |||
# Enable some basic modules | |||
sudo a2enmod rewrite | |||
sudo a2enmod ssl | |||
sudo a2enmod headers | |||
sudo a2enmod proxy | |||
sudo a2enmod proxy_wstunnel | |||
sudo a2enmod deflate | |||
</syntaxhighlight> | |||
===Installing PHP=== | ===Installing PHP=== | ||
;Installing php 7.4 on 20.04 | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
sudo apt update | sudo apt update | ||
sudo apt install php7. | sudo apt install php7.4 php7.4-fpm | ||
# Install some common extensions | # Install some common extensions | ||
sudo apt install php7. | sudo apt install php7.4-{apcu,bcmath,cli,common,curl,dev,gd,gmp,imagick,imap,intl,mysql,xml,xmlrpc,mbstring,opcache,redis,soap,zip} -y | ||
# | # Setup Apache to use php7.4-fpm | ||
sudo | sudo a2enmod proxy_fcgi setenvif | ||
sudo a2enconf php7.4-fpm | |||
sudo a2dismod php7.4 | |||
sudo a2dismod mpm_prefork | |||
sudo a2enmod mpm_event | |||
sudo systemctl restart apache2 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
;Important Notes | ;Important Notes | ||
* 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 | ||
** | ** E.g. <code>php7.4-common</code> instead of <code>php-common</code> | ||
* For Ubuntu 18.04, add the following repository | |||
*:<code>sudo apt install software-properties-common && sudo add-apt-repository ppa:ondrej/php</code> | |||
===Installing MariaDB=== | ===Installing MariaDB=== | ||
Line 53: | Line 75: | ||
sudo mysql_secure_installation | sudo mysql_secure_installation | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Misc=== | |||
* Install nodejs via nvm | |||
==Firewall== | |||
{{ main |Uncomplicated 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 [https://www.digitalocean.com/community/tutorials/ufw-essentials-common-firewall-rules-and-commands Digital ocean ufw essentials] | |||
<syntaxhighlight lang="bash"> | |||
sudo ufw allow ssh/tcp | |||
sudo ufw logging on | |||
sudo ufw enable | |||
sudo ufw status | |||
</syntaxhighlight> | |||
You should get an output like: | |||
<pre> | |||
Status: active | |||
To Action From | |||
-- ------ ---- | |||
22/tcp ALLOW Anywhere | |||
22/tcp (v6) ALLOW Anywhere (v6) | |||
</pre> | |||
To enable certain ports: | |||
<pre> | |||
ufw allow 80/tcp | |||
ufw allow 443/tcp | |||
</pre> |
Latest revision as of 21:58, 8 February 2021
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
sudo a2enmod ssl
sudo a2enmod headers
sudo a2enmod proxy
sudo a2enmod proxy_wstunnel
sudo a2enmod deflate
Installing PHP
- Installing php 7.4 on 20.04
sudo apt update
sudo apt install php7.4 php7.4-fpm
# Install some common extensions
sudo apt install php7.4-{apcu,bcmath,cli,common,curl,dev,gd,gmp,imagick,imap,intl,mysql,xml,xmlrpc,mbstring,opcache,redis,soap,zip} -y
# Setup Apache to use php7.4-fpm
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.4-fpm
sudo a2dismod php7.4
sudo a2dismod mpm_prefork
sudo a2enmod mpm_event
sudo systemctl restart apache2
- Important Notes
- Always use a version when installing things if you don't want things to break when you do updates
- E.g.
php7.4-common
instead ofphp-common
- E.g.
- For Ubuntu 18.04, add the following repository
sudo apt install software-properties-common && sudo add-apt-repository ppa:ondrej/php
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