LAMP server on Linux Mint – a web site on the local machine

LAMP serverLAMP server

Many web designers, web masters to create and debug web sites are hosted on a local server (on your computer). When I first installed LAMP server on your Linux mint, I was faced with the inconvenience of the location of the directory sites, by default, all files under the ROOT. Below will tell you how to install a LAMP server and work with your test sites under your username and home directory.

Open a Terminal (console) and type in there:

sudo apt-get install taskselsudo tasksel install lamp-server
do not leave the password blank and will remember!!!
To switch on the OK button press TAB

LAMP server on Linux Mint - a web site on the local machine

LAMP server on Linux Mint - a web site on the local machine

Next 
echo ‘<?php phpinfo(); ?>’ | sudo tee -a /var/www/html/test.phpsudo gedit /etc/apache2/apache2.conf
In the end of the file add the following line
ServerName localhost
Then restart Apache
sudo apache2ctl restart
will check the performance of your creations writing in the browser: http://127.0.0.1/test.php
LAMP server on Linux Mint - a web site on the local machine
Now install phpmyadmin
sudo apt-get install phpmyadmin
To select apache2 press SPACE, then TAB
Will check the work phpmyadmin http://localhost/phpmyadmin/

LAMP server on Linux Mint - a web site on the local machine

LAMP server on Linux Mint - a web site on the local machine

Commands management server:
sudo apache2ctl status – the status of the server
sudo apache2ctl stop – stop
sudo apache2ctl start – run
sudo apache2ctl restart – restart
Hosting is ready to work all your files should be placed at /var/www. As you can see, the standard installation, does not take much time.
Now create your host with an arbitrary name, let it be web-site
First, stop the Apache server, and create the root directory for your host. I created the folder web-site in their home directory. (This folder you can create and elsewhere.)
sudo apache2ctl stopmkdir ~/web-site
Configuration files hosts are stored in the folder /etc/apache2/sites-available. Initially there is file 000-default.conf, this configuration file on localhost. Take it as a basis and copy it to a file named web-site.conf:
cd /etc/apache2/sites-available sudo cp 000-default.conf web-site.conf
Now open the newly created (copied) the file web-site.conf for editing:
sudo gedit web-site.conf
Replaced the original text file with the following: 
<VirtualHost *:80> ServerAdmin [email protected] ServerName web-site ServerAlias web-site  # Indexes + Directory Root. DocumentRoot /home/username/web-site <Directory /home/username/web-site/>  DirectoryIndex index.php Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>  # Logfiles ErrorLog /var/log/apache2/mysite-error.log CustomLog /var/log/apache2/mysite-access.log common</VirtualHost>
Instead of the path home/username/web-site will replace username on your user name. If you created a folder for a host not in your home folder, simply enter the full path to this folder. 
Activate the created host command:
sudo a2ensite web-site
It remains to specify matching the IP address of the host name in the file /etc/hosts:
sudo gedit /etc/hosts
Add the line:
127.0.0.2 web-site

An example of my file

127.0.0.1 localhost127.0.1.1 l4l-mate127.0.0.2 web-site# The following lines are desirable for IPv6 capable hosts::1     ip6-localhost ip6-loopbackfe00::0 ip6-localnetff00::0 ip6-mcastprefixff02::1 ip6-allnodesff02::2 ip6-allrouters
Start the server
sudo apache2ctl startecho ‘<?php print_r (phpinfo()); ?>’ | tee -a /home/USERNAME/web-site/index.php
replace username on your user name and check the operability of the new host is added into the address bar of the browser: http://web-site/ 

LAMP server on Linux Mint - a web site on the local machine

Thus you can create a number of hosts with different names. On one IP you can create multiple hosts with different names, for example:
127.0.0.3 web site2
127.0.0.4 web site3
127.0.0.5 web-site4
and so on.
I will be glad if this article helped You.
Good Luck!!!
Basic information with some changes taken from here
Share to friends
Shekin
Rate author
( No ratings yet )
MintGuide.Org
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments