Install lamp with PHP7 on Arch Linux


Arch Linux is a simple, fast, powerfull distrobution and it always provides the last version of kernel and softwares so if you wanna have the latest version of PHP, Apache, MySQL and etc it’s really good and recommanded for web developing.

In this tutorial we ganna install Lamp on Arch Linux with the latest version of PHP (PHP7) from AUR, but you should know that installing Lamp with PHP7 may makes some problems because it’s in unofficial repositories, so you should take the risk by yourself !

1- Installation and runing services

First install PHP7 and it’s needs from AUR by the following command :

yaourt -S php7 php7-apache php7-mcrypt

Now install Apache and Mysql (mariaDB) :

sudo pacman -S apache mysql php-apache mariadb

Enable and start Apache service by this command :

sudeo systemctl enable httpd
sudo systemctl start httpd

See the status and make sure it’s okay :

systemctl status httpd

The last line output should be like this :

Started Apache Web Server


Start and enable MySQL now by this commands :

sudo systemctl enable mysqld
sudo systemctl start mysqld

Check the status :

systemctl status mysqld

If you get the following sentence in output your service is okay :

Started MariaDB database server.


If your status shows MySQL is not okay use following command and try again :

sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

2-MySQL Configuration

You should secure MySQL so use this command to start :

sudo mysql_secure_installation

Look at the following picture :

After the sentence ” Enter current password for root (enter for none): ” give your root password the then it will asks you few questions answer them all with yes.if you wanna use Jommla or WordPress as localhost on your Arch Linux you need to know how to create or remove database in MySQL but first you should enter to MySQL by this command :

mysql -u root -p

After you enterd, make a user in MySQL by following commands :

CREATE USER 'hossein'@'localhost' IDENTIFIED BY 'your_pass';
GRANT ALL PRIVILEGES ON mydb.* TO 'hossein'@'localhost';

Don’t forget to put your own information in creating user commands. After you creat a user you can manage your databases for example for creating a database you can use this command :


If you want to see your databes use following command :


Or for removing a database you can “DROP” like this :

DROP DATABASE database_name;

For getting out of MySQL use this command :


For more information about MySQL command see here.

3- Apache Configuration

Here we config Apache so enter following command :

sudo nano /etc/httpd/conf/httpd.conf

Now that text file is open add the following lines to bottom of it :

<IfModule dir_module>
	<IfModule php7_module>
		DirectoryIndex index.php index.html
		<FilesMatch "\.php$">
			SetHandler application/x-httpd-php
		<FilesMatch "\.phps$">
			SetHandler application/x-httpd-php-source

Restart Apache service :

sudo systemctl restart httpd

Apache is successfully configured now :))


For getting your php information first you should make a text file so do like following command :

sudo nano /srv/http/info.php

Add this lines to the file :


Save the file with ctrl + o and close it with ctrl +x then enter this command :

cd /srv/http

Let info.php to have excute permission :

sudo chmod u+x info.php

Run the file :

php info.php

If php7 were okay first of the output should be like this with other informations :

[[email protected] http]$ php info.php
PHP Version => 7.0.0

If it is, Lamp is ready !!
( Thanks to my friend Saeed for contribute )



  • Daniel Pickering

    I can’t seem to get past configuring the php7

    DirectoryIndex index.php index.html SetHandler application/x-httpd-php SetHandler application/x-httpd-php-source </IfModule

    take one arguement base it says any advance ?


  • Soufiane Bk

    Can you update your tutorial “yaourt -S php7 php7-apache php7-mcrypt” no longer available, put “php” instead of “php7”, thanks