This is an old revision of the document!
LAMP
LAMP is the acronym for Linux Apache Mysql Php.
For the “Linux” side of Lamp, it all depends on your hosting and your preferences. We advise beginners to take a Debian Stable distribution, which is robust, secure and not too complicated. Experts are also numerous to remain under this distribution for their servers!
A good part of this doc is based on the Ubuntu documentation concerning LAMP.
Installing basic packages:
sudo apt-get install apache2 php5 mariadb-server libapache2-mod-php5 php5-mysql apache2-utils php5-gd php5-imagick
The installation of the mysql database will ask you to create a password for “root”. Be sure to write it down!
You can install Mysql instead of Mariadb, but it's worse …
Go to the address of the server and admire the page “It works”. That means it's installed.
Apache
Apache is basically functional basic, but there are some useful little tricks for a configuration similar to Khaganat.
Enable URL rewriting
For wiki farm or pastebin(among others), it is necessary to activate the rewriting of the URLs.
Run the command:
Sudo a2enmod rewrite
Then, edit /etc/apache2/apache2.conf and add at the end(if it is not there):
<ifModule mod_rewrite.c> RewriteEngine On </ IfModule>
Then check that in the “/etc/apache2/sites-available/default” file, the “AllowOverride” option is set to “All” for the parts that are being rewritten by url (all /var/www to not complicate the task): <Code> Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow, deny Allow from all </ code>
Do not forget to restart Apache:
/etc/init.d/apache2 restart
Editing urls to go to folders (alias)
With a basic configuration, Apache indicates that you must read the directory /var/www as the base directory of the site, each folder being added to the address. For example, if your “www” folder is organized as follows:
- Www
- File1
- Page1.html
Then to access via the web to page1 it will be necessary to put in the address bar of the browser www.mon_site.net/dossier1/page1.html
We change this by making aliases in the file /etc/apache2/sites-enable/000-default.conf, in this way:
Alias /adresse /var/www/dossier1 <Directory /var/www/dossier1> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all </Directory>
Change /address to whatever you want; If it is just the bar / then it will be the root of the site (what will be seen by typing www.mon_site.net/). You can also point to addresses outside of /var/www, for example, point to home/user/monsite, which allows you to work in a directory with basic user rights.
For a site accessible to all, the options of this alias are good.
Relaunch Apache
To restart the apache server:
Logged in as root
/etc/init.d/apache restart
Rights on www
Several possibilities to allow, as user Lambda1), To modify what is in the folder /var/www. The easiest and fastest way is to assign the rights of this folder to the www-data group, and to put lambda in the www-data group.
Sudo adduser lambda www-data Chown -R www-data: www-data /var/www
Alternative method:
To add the lambda user to www-data, there is also the command:
Usermod -a -G www-data lambda
Both are similar.
Restart the session so that the rights are taken into account for the current user.
It's better to let the www-data group manage the rights, basic, because otherwise it's a nice bazaar.Adding the user “lambda” in this group makes it possible to modify everything without taking the lead.
Security would probably like that www-data does not have the rights, but it requires to understand everything, otherwise apache will just block everything. So here, make it simple.
If some cms cause problems, the following command sequence on the folder in question can reassign the rights to www-data and allow them to be resolved(to run as root):
chgrp -R www-data "folder" chown -R www-data "folder" chmod -R g+w "folder"
chgrp to reassign the owner group, chown to change the owner anyway(less important, in theory chgrp should already fix most of the worries), chmod to give the right permissions write on the folder add , w for write, so write). The -R option allows recursion(that the change applies in subfolders).
==== Proxy ====
Some services are accessible via specific ports. This is what Etherpad does for example: when installed, it is accessible at the address http://myserverur.com:9001.
To be able to access it via the web address http://monserverur.com/pad, you must put a proxy in place in Apache.
Begin by activating the proxy modules:
A2enmod proxy proxy_http
Then add this kind of information in /etc/apache2/sites-availables/000-default.conf:
<code>
<VirtualHost *:80>
ProxyVia On
ProxyRequests Off
ProxyPass /pad/ http://localhost:9001/
ProxyPassReverse /pad/ http://localhost:9001/
ProxyPreserveHost on
<Proxy *>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Proxy>
</VirtualHost></code>
Restart the apache service
Service apache2 restart
Your etherpad should be accessible at the right address!
===== Mysql =====
==== Phpmyadmin ====
=== Installation ===
Phpmyadmin is considered a potential security breach and would be better off. At the same time, going without database would be ideal …
In short, despite these considerations, phpmyadmin is a handy way to manage a database when you have little knowledge, because it helps the job well. So … we'll try to install it.
Sudo apt-get install phpmyadmin
Select “apache” in the options, then for the database, let it do it.
<code> Please enter the password for the administrative account that will be used to create the MySQL database as well as the users.
Database administrator password: </code>
This is the root password.
Choose the password of the database … and do not forget to pass it in a secured way to the other admins.
=== Web location ===
By default, phpmyadmin is accessible at site.net/phpmyadmin, which helps a malicious user find the door. It can be modified via the file /etc/apache2/conf.d/phpmyadmin.conf'', changing the default alias:
Alias/phpmyadmin/usr/share/phpmyadmin
For example:
Alias/ploufphpmyadmin/usr/share/phpmyadmin
The simple addition of the “plouf” in front should already avoid automatic attacks!
Relaunch Apache for this to take effect.
Having a login other than “root” would be as good. But can it be easily changed?
=== Importing a database === To import a database via phpmyadmin(eg forum forum, saved before), you must create the database, associate it with a user who will have access on this database only, then import the saved “.sql”. If the base is too large, there will be an error. Change /etc/php5/apache2/php.ini to increase the maximum size allowed. Phpmyadmin makes an error linking what needs to be changed. ==== Various Mysql commands ==== Creating a user and a mysql database for the different services: 1) launch mysql $ Mysql -u root -p The password will be requested. 2) Create the database: Mysql> create database MyDatabase; 3) Create a user and grant him access rights to the database without a password but only locally: Mysql> GRANT ALL ON MyDatabase. * TO User @ localhost; 3.1) Do the same thing but with a password: Mysql> GRANT ALL PRIVILEGES ON MyDatabase * TO User @ localhost IDENTIFIED BY 'Password'; 4) Do not forget to update the database: mysql> FLUSH PRIVILEGES;





