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.

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

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.


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




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.


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



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



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



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

Add this line:
application/x-httpd-php php php5
On /etc/httpd/conf/mime.types

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

Like this :


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:

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


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.


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


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.


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

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