This document describes the entire process of installing and configuring a LAMP server. LAMP stack is a group of open source software used to get websites with databases running.
Install Linux
First get a server with already running Linux. This document is based on CentOS. The linux installation part is taken care of. Here is how to install the rest.
Login with SSH root privileges to your Linux server and follow the instructions below.
Install Apache
Apache is a free open source software which runs web servers.
|
|
|
|
|
|
Install MySQL
MySQL is a database management system.
|
|
To start MySQL |
|
|
|
|
|
|
|
Install PHP
PHP is an open source web scripting language that is widely used to build dynamic webpages.
|
|
PHP Modules
PHP also has a variety of useful libraries and modules that you can add onto your server.
|
|
|
|
|
|
You can install multiple libraries at once by separating the name of each module with a space.
PHP-info page on your Apache Server
Although LAMP is installed on your virtual server, we can still take a look and see the components online by creating a quick php info page.
|
|
|
|
|
|
|
|
|
|
To Install the LAMP stack at once
|
|
|
|
Configure iptables (firewall)
Make sure the firewall does not block access to port 80
Edit the iptables config file |
|
Allow http traffic |
|
Restart firewall |
|
Install phpmyadmin (optional)
phpMyAdmin is a powerful tool for manipulating MySQL databases.
Change directory to your documentroot |
|
Download phpMyAdmin |
|
Unzip phpMyAdmin |
|
Rename directory |
|
Remove the zip-file |
|
Now you can browse to: |
|
Add blowfish_secret for security |
|
Add virtual hosts to Apache
Virtual hosts allow multiple web sites to be served from a single Apache installation.
The virtual hosts can be added to the end of the Apache configuration file (/etc/httpd/conf/httpd.conf).
Here is an example configuration with two web hosts:
# Ensure that Apache listens on port 80 and name-based virtual hosting is enabled.
Listen 80
NameVirtualHost *:80<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.domain1.com
# Other directives here
</VirtualHost><VirtualHost *:80>
DocumentRoot /www/example2
ServerName www.domain2.org
# Other directives here
</VirtualHost>
Setting permissions for PHP sites
Secure your site by setting the correct permissions on your DocumentRoot:
Set Apache user as the owner for your DocumentRoot |
|
Modify permissions |
|
In some cases your PHP site requires write access in some folders. For example WordPress sites requires write access into the /wp-content folder to could install plugings, themes or updates.
Provide write permissions to WordPress |
|
Configure PHP (optional)
By default PHP is preconfigured, but you may customize some setttings.
Edit the PHP configuration file |
|
Increase the maximum upload file size |
|
post_max_size restriction |
|
Increase the memory limit |
|
Increase the maximum execution and input time |
|
maximum time to wait for POST and GET data |
|
Restart httpd to activate the changes |
|