The LAMP stack, comprising Linux, Apache, MySQL, and PHP, is a popular choice for web development. This guide will walk you through installing and configuring a LAMP stack on Arch Linux, equipping you with a robust platform for your web applications.
sudo pacman -Syu
Apache Web Server: Install the Apache web server using the pacman package manager:sudo pacman -S apache
Start and enable the Apache service for automatic startup: sudo systemctl start httpd sudo systemctl enable httpd
Verify Apache's status: sudo systemctl status httpd
PHP: Install PHP and its Apache module:sudo pacman -S php php-apache
MySQL (MariaDB): Install the MariaDB database system:sudo pacman -S mysql
Start and enable the MariaDB service: sudo systemctl start mysqld sudo systemctl enable mysqld
Verify the MariaDB service status: sudo systemctl status mysqld
sudo mysql_secure_installation
Open the Configuration File: sudo nano /etc/httpd/conf/httpd.conf
Include Virtual Host and Module Configurations: Append the following lines at the end of the httpd.conf file: IncludeOptional conf/sites-enabled/*.conf IncludeOptional conf/mods-enabled/*.conf
Create System Directories: Create the necessary system directories to organize your virtual host configurations and enabled modules: sudo mkdir /etc/httpd/conf/sites-available sudo mkdir /etc/httpd/conf/sites-enabled sudo mkdir /etc/httpd/conf/mods-enabled
Create the a2ensite script: sudo nano a2ensite
Add the following content to the a2ensite script: #!/bin/bash if test -d /etc/httpd/conf/sites-available && test -d /etc/httpd/conf/sites-enabled ; then echo "-------------------------------" else mkdir /etc/httpd/conf/sites-available mkdir /etc/httpd/conf/sites-enabled fi avail=/etc/httpd/conf/sites-available/\.conf enabled=/etc/httpd/conf/sites-enabled site=`ls /etc/httpd/conf/sites-available/` if [ "$#" != "1" ]; then echo "Use script: n2ensite virtual_site" echo -e "\nAvailable virtual hosts:\n$site" exit 0 else if test -e $avail; then sudo ln -s $avail $enabled else echo -e "$avail virtual host does not exist! Please create one!\n$site" exit 0 fi if test -e $enabled/\.conf; then echo "Success!! Now restart Apache server: sudo systemctl restart httpd" else echo -e "Virtual host $avail does not exist!\nPlease see avail virtual hosts:\n$site" exit 0 fi fi
Create the a2dissite script: sudo nano a2dissite
Add the following content to the a2dissite script: #!/bin/bash avail=/etc/httpd/conf/sites-enabled/\.conf enabled=/etc/httpd/conf/sites-enabled site=`ls /etc/httpd/conf/sites-enabled` if [ "$#" != "1" ]; then echo "Use script: n2dissite virtual_site" echo -e "\nAvailable virtual hosts: \n$site" exit 0 else if test -e $avail; then sudo rm $avail else echo -e "$avail virtual host does not exist! Exiting" exit 0 fi if test -e $enabled/\.conf; then echo "Error!! Could not remove $avail virtual host!" else echo -e "Success! $avail has been removed!\nsudo systemctl restart httpd" exit 0 fi fi
Make Scripts Executable and Accessible: sudo chmod +x a2ensite a2dissite sudo cp a2ensite a2dissite /usr/local/bin/
Run the following command to test the a2ensite script: sudo a2ensite
Create the Virtual Host Configuration File: sudo nano /etc/httpd/conf/sites-available/emka.com.conf
Add the following content to the tecmint.com.conf file: <VirtualHost *:80> ServerName emka.com ServerAlias www.emka.com DocumentRoot /srv/http/emka.com ServerAdmin [email protected] ErrorLog "/var/log/httpd/emka.com-error_log" CustomLog "/var/log/httpd/emka.com-access_log" combined <Directory "/srv/http/emka.com"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> </VirtualHost>
Create the Document Root Directory: sudo mkdir -p /srv/http/tecmint.com sudo chown -R $USER:$USER /srv/http/emka.com sudo chmod -R 755 /srv/http/emka.com
Enable the Virtual Host: sudo ln -s /etc/httpd/conf/sites-available/emka.com.conf /etc/httpd/conf/sites-enabled/
Activate and Restart Apache: sudo a2ensite emka.com sudo systemctl restart httpd
Test the Virtual Host: Create a simple index.html file in the document root directory: echo '<h1>Welcome to emka!</h1>' | sudo tee /srv/http/emka.com/index.html
0 comments:
Post a Comment