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

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

Internet

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 tasksel
sudo 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.php
sudo 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 stop
mkdir ~/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 webmaster@example.com
 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-mate
127.0.0.2 web-site
# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Start the server
sudo apache2ctl start
echo '<?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

Print version

Add comments

  • Local comments
  • Facebook comments
  • bowtiesmilelaughingblushsmileyrelaxedsmirk
    heart_eyeskissing_heartkissing_closed_eyesflushedrelievedsatisfiedgrin
    winkstuck_out_tongue_winking_eyestuck_out_tongue_closed_eyesgrinningkissingstuck_out_tonguesleeping
    worriedfrowninganguishedopen_mouthgrimacingconfusedhushed
    expressionlessunamusedsweat_smilesweatdisappointed_relievedwearypensive
    disappointedconfoundedfearfulcold_sweatperseverecrysob
    joyastonishedscreamtired_faceangryragetriumph
    sleepyyummasksunglassesdizzy_faceimpsmiling_imp
    neutral_faceno_mouthinnocent
CrossOver Linux