LAMP is a suite of server software. Today it is the most popular open source web platform and is distributed completely free of charge. It is used for building dynamic websites and web applications.
LAMP components are found in the software repositories of most Linux distributions. In operating systems of the Microsoft Windows family, there is an analogue known as WAMP.
LAMP is an abbreviation, named after the first letters of its constituent components:
- Linux – Linux operating system;
- Apache is an HTTP server;
- MySQL – DBMS (database management system);
- PHP – programming language (Hypertext Preprocessor)
And also, in addition to PHP, languages such as Perl and Python can be implied.
Installing the LAMP package .
Launch the terminal and enter the following command:
sudo apt-get install lamp-server ^
Next, you need to confirm the installation process. Enter “y” and click on Enter.
The next step is to create a Mysql password for the “root” user.
We confirm our password, enter it again.
Next, the process of installing the necessary packages will start. We are waiting for the end of the installation.
We launch the browser and enter in the address bar localhost.
LAMP is installed, now let’s move on to other settings.
Site folders.
The default home directive for our site is /var/www/html. To create a new site, you need to create a folder in this directory. The name of the created folder will be the domain of our site.
For example , let’s create a site under the name testsite. To do this, create a folder /var/www/html/testsite. And in this folder, create an index.html file with simple markup.
< html >
< head >
< meta http-equiv = “Content-Type” content = “text / html; charset = utf-8” >
< title > Test page < / title >
< / head >
< body >
Test page
< / body >
< / html >
In the browser, enter localhost/testsite and go to the newly created site. In the same way, you can add as many sites as you like.
See also: Styling your form with CSS
There is another option for creating sites with an individual root folder.
Create a folder /home/user/www/testsite/where user is the username of Ubuntu, in the folder www we will store all our sites, testsite – the folder of our new site.
To set the folder to the www directory of all our sites, you need to change the apache configuration file. To do this, open the apache2.conf file with gedit.
sudo gedit / etc / apache2 / apache2. conf
Find the tags </Directory> and add them under the last of the tags.
< Directory / home / user / www >
AllowOverride All
Require all granted
< / Directory >
We save. Next, you need to register our site in a file hosts. We also open this file with gedit.
sudo gedit / etc / hosts
Add the name of our site to the first line.
- 0 . 0.1 localhost testsite
We need to create a configuration file for our site testsite. Let’s copy the configuration file of the base site.
sudo cp / etc / apache2 / sites-available / 000 -default. conf / etc / apache2 / sites-available / testsite. conf
Now we configure the created file for our site. Opening the file:
sudo gedit / etc / apache2 / sites-available / testsite. conf
We find the line #ServerName www.example.com. Uncomment it, delete #. And instead of www.example.com registering the name of our new site, in our case testsite. You should get:
ServerName testsite
Next, fix DocumentRootit by changing /var/www/html to /home/user/www/testsite (do not forget to put the username of Ubuntu instead of user).
Now we turn on our site. We run the command in the terminal.
sudo a2ensite testsite
On this, our new site is configured and connected, it remains to restart Apache and go to the address http://testsite.
Install phpMyAdmin.
In order to use the databases on our server, you need to install phpMyAdmin . Install:
sudo apt-get install phpmyadmin
The process of obtaining a list of packages will begin. We confirm the installation.
Next, the question of choosing a web server will follow. Select Apache, put an asterisk in front of it by pressing the space bar. We press Enter.
Confirm the configuration with dbconfig-common.
Create a password for the database user.
Enter the MySQL password created at the beginning of the LAMP installation
See also: Ubuntu Terminal Commands. Usage
We confirm our phpMyAdmin password.
Go to the address localhost/phpmyadmin.
This completes the installation of PhpMyAdmin. The username is “root”. In the login field we write “root”, in the password field we write the previously created phpMyAdmin password. After successful authorization, we get to the database control panel.
Disconnect from startup
Every time the operating system is started, LAMP will automatically start. If you want to start LAMP when you need it, you need to disable it from startup. We use the command:
sudo update-rc. d -f apache2 disable
Commands for LAMP.
We launch.
sudo service apache2 start
or
sudo / etc / init. d / apache2 start
Disable.
sudo service apache2 stop
or
sudo / etc / init. d / apache2 stop
We reboot.
sudo service apache2 reload
or
sudo / etc / init. d / apache2 restart
Removing LAMP.
Removal is performed by the commands:
sudo apt-get purge libapache2-mod-auth-mysql phpmyadmin
sudo apt-get purge mysql-server mysql-server- 5.1 mysql-server-core- 5.1
sudo apt-get purge apache2 apache2-mpm-prefork apache2-utils apache 2 . 2 -bin apache 2 . 2- common libapache2-mod-php5
sudo apt-get autoremove