LAMP stack Install [Linux Apache MariaDB PHP] Arch-Linux
Hackers or any self-respecting Linux user should have a know how to configure a web server. This is just the prerequisite for it.
First we will install and enable Apache
sudo pacman -S apache
sudo systemctl start httpd
To enable Apache automatically on boot respectively:
sudo systemctl enable --now httpd
we will edit it to enable load_module_id. I use neovim as my editor
sudo nvim /etc/httpd/conf/httpd.conf
- A . we enable the module
- B , to search in vim, press the foward slash / then enter to continue.
The module in question facilitates the generation of a unique token for each request, ensuring its uniqueness across all requests under strict conditions. It achieves this by introducing an environment variable named UNIQUE_ID
, which holds a distinctive identifier for every HTTP request managed by the Apache server. This feature is particularly beneficial for monitoring individual requests, making it an invaluable asset in logging and debugging processes sudo systemctl restart httpd.
To check if Apache is running or not use
systemctl status httpd
Installing php modules
sudo pacman -S php php-cgi php-gd php-pgsql php-apache
We comment as shown in the /etc/httpd/conf/httpd.conf, The uncommenting and commenting helps the server with child processes.
Within the same file, add at the end of the doc.
Edit php.init file in /etc/php/php.ini and uncomment in
To test if php is working correctly we need to create a php file in our server. The srv is the server dir.
sudo nvim /srv/http/info.php
add the info as shown in the image below.
sudo systemctl restart httpd
Now on your favourite browser, on the address bar type “localhost/info.php”. If you see this page that means php is working correctly.
Installing WordPress DB
sudo pacman -S mariadb libmariadbclient mariadb-clients
Setting the basic configuration for the database
sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
Enables service and starts it right away
sudo systemctl enable --now mysqld
Setting up secure installation for the database
sudo mariadb-secure-installation
press ENTER on the password prompt, since we haven't set root password yet
NOTE: say yes to all prompts except the “Change the root password”
To Install Database, press ENTER on the password prompt, since we did not set it up
sudo mariadb -u root -p
Followed by the SQL commands. The username and localhost should be in quotes, give whatever username and password and database name without the <> symbol.
CREATE DATABASE <DATABASE_NAME>;
CREATE USER '<USERNAME>'@'localhost' IDENTIFIED BY '<PASSWORD>';
GRANT ALL PRIVILEGES ON <DATABASE_NAME>.* TO '<USERNAME>'@'localhost';
FLUSH PRIVILEGES;
exit
Download WordPress
cd /srv/http
sudo wget https://wordpress.org/latest.tar.gz
sudo tar xvzf latest.tar.gz
sudo chown -R root:http /srv/http/wordpress
cd wordpress
sudo cp wp-config-sample.php wp-config.php
sudo nvim wp-config.php
In the chown user is root group is http(webserver) the directory is /srv/http/wordpress
Now in the “wp-config.php”
replace the fields above with the already set details we did in the mysql commands.
Using your favourite browser, type on the address bar
localhost/wordpress
set username and password. This is for the WordPress not SQL so you can name it whatever.
Done XD