Lets assume you have a blank Ubuntu Server, this can be 22.04, or any later (TLS preferred) version.
First, lets become sudo.
sudo su
For Ubuntu 22.04 (24.04+ not needed)
add-apt-repository ppa:ondrej/php
apt update
Then we can install some tools. We have included some other convenient defaults
apt update && apt install -y nano htop wget curl dnsutils net-tools mysql-server php8.2 apache2 zip unzip php8.2-{curl,soap,xml,mysql,gd,intl,zip,mbstring}
During the installation some screens will appear in the terminal, asking for selections or services to restart. You can select defaults.
OPTIONALLY we now install PHPMyAdmin.
apt install -y phpmyadmin
(PHPMyAdmin is not adviced to be enabled in any production environment)
During installation you will get the following screens
This screen would allow some visual/interactive installation options for MySQL, however we usually select no, as not all interesting options are available through it.
Here you can select Apache2 (hit spacebar), then hit Ok
(TAB then Enter), as that is what we also selected earlier to install. This will make a conf
(/etc/apache2/conf-available) and enables it, to use /phpmyadmin
to go to that program.
For the Next up, lets initiate mysql(d)
mysqld --initialize-insecure
This will return without error if no issue. Then we can login so we can create a user for MySQL.
mysql
This will get you into MySQL, showing:
And lets create the user
CREATE USER 'my_username'@'%' IDENTIFIED BY 'MyP@ssw0rd';
You should replace my_username
with your username, the password too of course, but maybe also the %
for the host
, this can be localhost
or an ip like 127.0.0.1
or anywhere as it would be now (less secure)
And grant all the privileges
GRANT ALL PRIVILEGES ON *.* TO 'my_username'@'%' WITH GRANT OPTION;
Lets flush the privileges too
FLUSH PRIVILEGES;
Exit MySQL
\q
Now by the IP address of the host, you can login using the above created credentials into PHPMyAdmin: http://HOST_OR_IP/phpmyadmin
That’s really it, you have an Apache2 webserver and a MySQL server. One last common need would be some modules for Apache2, for when you install a real framework, think WordPress or something like Magento (2).
a2enmod ssl rewrite headers
Then as the result suggests, you can restart Apache2, either through systemctl
as the suggestion
or through the service restart command
service apache2 restart
And finally, don’t forget to drop your root access.
exit
Now you are really done. 😉
Leave a Reply