Thursday, February 7, 2013

How to Install Lamp (Linux Apache Mysql PHP) web Server on Archlinux

LAMP is Linux Apache MySQL and PHP application for web servers. To setup the web server here's my method to running up web server on Archlinux.
Mysql now replaced to mariadb

1. Installing the packages

First install the needed packages.
$sudo pacman -S apache php php-apache mysql mariadb

Done.

2. Running Apache

Run
$sudo systemctl enable httpd

Now test on browser http://localhost/
If you see like this, then the apache is running.

How to Install Lamp (Linux Apache Mysql PHP) web Server on Archlinux

If you get 403 error, comment out this line on /etc/httpd/conf/httpd.conf
Like this. See the bolded text.

How to Install Lamp (Linux Apache Mysql PHP) web Server on Archlinux


If don't get the 403 error, and you want to user directory available on the web, just skip it.

3. Set user directories.


create public_html

$mkdir ~/public_html
$chmod o+x ~/public_html
$sudo nano /etc/httpd/conf/extra/httpd-userdir.conf

For this example user of public directory.
/home/cidtuxnet/public_html

Set like this.

How to Install Lamp (Linux Apache Mysql PHP) web Server on Archlinux

Any file that you want to publish on the web, store on that public_html directories.

To see directory. http://localhost/~yourusername/, make sure you have restart the httpd service.
$sudo systemctl restart httpd

4. Configuring PHP


Configuring PHP.
$sudo nano /etc/httpd/conf/httpd.conf
Add this line after "LoadModule dir_module modules/mod_dir.so" :
LoadModule php5_module modules/libphp5.so

How to Install Lamp (Linux Apache Mysql PHP) web Server on Archlinux


Add this line on Include list (place at end) :
Include conf/extra/php5_module.conf

How to Install Lamp (Linux Apache Mysql PHP) web Server on Archlinux


Make sure uncomment this (default is uncommented)
TypesConfig conf/mime.types


How to Install Lamp (Linux Apache Mysql PHP) web Server on Archlinux

You can also uncomment : (optional)
MIMEMagicFile conf/magic

How to Install Lamp (Linux Apache Mysql PHP) web Server on Archlinux
Add this line:
application/x-httpd-php php php5
On /etc/httpd/conf/mime.types

$sudo nano /etc/httpd/conf/mime.types

Like this :

How to Install Lamp (Linux Apache Mysql PHP) web Server on Archlinux

Okay that's for php, restart the httpd
$sudo systemctl restart httpd

5. Configuring MySQL database


Makesure you have swap partition, and activate it. To avoid some "Can't connect to local MySQL server through socket" problems.

Okay run the mysqld services
$sudo systemctl enable mysqld

Then setup the mysql

$sudo mysql_secure_installation
Insert your password:
How to Install Lamp (Linux Apache Mysql PHP) web Server on Archlinux

There are some database test & anonymous user, you can delete it.

How to Install Lamp (Linux Apache Mysql PHP) web Server on Archlinux

Okay, next to create database.
$sudo mysql -u root -p
Create database, for this example "cidtux"
create database dbname; 
type it on mysql shell like this below.

How to Install Lamp (Linux Apache Mysql PHP) web Server on Archlinux

Add user to database
grant all on dbname.* to 'user' identified by 'password';
cidtux, for this example, user : root, password : root,

How to Install Lamp (Linux Apache Mysql PHP) web Server on Archlinux

Ok that's then quit by typing
quit;

Note that the semi-colons (;) at the end of the lines are crucial for ending the commands.

OK that's it. Now test on your browser. On this example, i'm running wordpress cms.

How to Install Lamp (Linux Apache Mysql PHP) web Server on Archlinux

Enjoy webserver /LAMP on Archlinux. :D
Share on Facebook
Share on Twitter
Share on Google+
Tags :