Configuring Apache, PHP and MySQL for Linux-VPS

We have already laid out the materials, which already demonstrably been shown installing Apache with PHP and MySQL on Windows, but the best option - it is installed with a local VPS Linux under Windows. When we installed the last time, this trio has been installed run Debian, which was described by a single line. In two cases, never considered setting the Web and SQL-Server. Especially not been considered in detail Web, and for hosting a very important - Apache.

   Installing Apache, PHP and MySQL on Debian
   Firstly, you need to install any software on your own server (virtual or real - mainly for these purposes there is no difference). As already noted much easier to carry out such work in Linux, not in Windows. Let's look at this in more detail, because we will be set on the untouched version of Apache and PHP, and together with strapping from different libraries. And also you need to install (this is the minimum) program: GD need for maintaining schedules, ImageMagick it is needed to improve the graphics work with PHP, and more Mcrypt, it is intended for encryption.
   So, start the installation: 
apt-get install apache2 php5 imagemagick libapache2-mod-php5 php5-gd php5-imagick php5-mcrypt
At this point we need to install Apache, PHP and ImageMagick (and, GD has been pumped with the database), which would dock modules with Apache with PHP and PHP with GD, ImageMagick and Mcrypt need to install as well.
   Basically, the whole idea of working with the installed packages in Debian comes to setting apt-get with the team (this is called komnda Install) and then install all the following required packages. 
Next, begin to install MySQL:
apt-get install mysql-server mysql-client php5-mysql
   Here begin immediately established three types of packages: the actual server itself MySQL, client MySQL (it provides access to the entire server center) and module support MySQL in PHP. When the installation process has already begun, then he should ask for the MySQL server you for a password, usually for root (be sure not to be confused with the system super user root!).

   You must enter the password, and then re-enter it on the other screen, and after a few minutes of work performed, installed MySQL will be completed. 
Such actions, after all these facilities, we will have everything you need for a complete web service. For added convenience, install phpmyadmin. Basically, such an easy procedure is done in Debian:
apt-get install phpmyadmin
   When you begin to install, the program will ask you for what purpose and for what service you want to configure the utility - it is necessary to point out the apache2, you need to click on it or press the spacebar.

   When you have set it, you will be prompted to configure the database for phpmyadmin. Must agree with this by selecting Yes, more will need to enter the root password for MySQL (we have already entered it when you installed the server), and will also create a password for phpmyadmin
   Next you need to run phpmyadmin, thereby seeing if it works for us. Whatever it needs to be done, start the browser (preferably Google Chrome) and in the address line of the write Ip-address of our server (for example, - but they can be, and others) and the same path to phpmyadmin, it will be the same «http : // ». Thus, after the work performed should display a page with authorization. 
    In line enter your login (root) and password prompt, enter (MySQL-root) and go. It is these actions, we have seen that Apache, PHP and MySQL start to work without interruption, since Phpmyadmin load all three components. You must specify a path on the local system in this case is not important, but you still need to change the name of the address of the script, with the standard in what may be unusual. In order that would need to be renamed in the directory / etc / phpmyadmin, more open apache.conf file and line Alias prescribes a new way (for example, mypath). 
Next, you need to restart apache:
/etc/init.d/apache2 restart
   Of course, the path to phpmyadmin change to

    Configuring Apache on Linux 
   If you have completed all the steps above, you quietly and without any problems will be taken to the configuration of Apache. Files of this Web server are located in the case with Debian / etc / apache2. The dates and the basic settings are located in mods-available and sites-available. Be aware that the configuration uses only those files, respectively, on which there is a link from a directory mods-enabled and sites-enabled. And also you can create and the files in the first place it is necessary to determine the type of file that we want to create. Because the PHP interpreter only checks the file formats listed below: .php, .pht and .phtml. What would install these files have the format .html - need to find a file mime.conf  in / etc / apache2 / mods-available and find in it the line, it must contain «php» (that would be to find a file, you simply press the F7 specify the name). If you do not find it, you need to see where the system file. Line is likely to be to start with TypesConfig. Basically, this file is located us at the root of the / etc directory and is called mime.types.

   Mark: Of course, for the case with Debian 6 will need to open /etc/mime.types, instead of looking type settings in configurations Apache). 
Next you need to open the file for editing, and find there a line application / x-httpd-php and it will be necessary to add at the end of the line html (no points).

   Then you must go to the installation directory of our site. It would be desirable to position and install it where our hosting costs. This directory will look something like this: «/ home / miya_polzovatelya / site_name". With this action we have a problem with the user, which would work with the service httpd as root is not needed. To create a user, you must enter the command useradd, in the settings you need to show him the way to the home directory and enter a name of the user. Take his name userone:

useradd -d / home / user1 -m userone
   Key -m means that necessarily using -d directory shall be installed or created automatically. Then you must set a password - it can be done with the command passwd:
   Now you are ready to create a website. Let's change the user that would re-create the new directories we need to: 
suuseronemkdir / home / user1 / site1 mkdir / home / user1 / site1 / logs mkdir / home / user1 / site1 / www exit
   Catalogues we are ready, let's go back to Apache. We need to know the virtual hosting for the site site1 (let's call it In order that would make things right is necessary: in the catalog to register / etc / apache2 / sites-available file starts to be created by setting the form site_name .conf, in this case It is necessary to register and all the necessary us konfiguratsiyu.esli you are using our example, then you should get the following: 

<VirtualHost *: "80> ServerName ServerAlias DocumentRoot / home / user1 / site1 / www <directory / home / user1 / site1 / www> AllowOverride All Order allow, deny allow from all </ directory> ErrorLog /home/user1/site1/logs/error.log LogLevel warn CustomLog /home/user1/site1/logs/access.log combined </ VirtualHost> 

   On codes can be seen that all the settings are made in a kind of tag VirtualHost, it is usually necessary to ukazatt address and port information, it will be written in this site. Nested settings resemble the following: 
ServerName - This domain name of our server
ServerAlias - Alias Server (you can specify several parameters such) 
DocumentRoot - Root directory site
ErrorLog - The path and file name for logging errors
LogLevel - Severity error, from which the information is required to get to the log CustomLog - The path and file name for logging access
   Directory structure that we have invested in the catalog we have described, it points to the home and like him (DocumentRoot). OptionsAllowOverrideAll line indicates that we consent to overwrite any settings using .htaccrss. The next two lines define the rights of access, in this case, from what we want to address. It is necessary to remember that allow, deny written without a space - this one setting.


   It should be noted that the directory can not without your knowledge or consent to an agreement, and then apply it in the configuration of Apache is not only inside the VirtualHost, it also can be used in any other place where you need to ask questions for the catalog.

   Further, when the Apache configuration file for a completely new site is ready, you need to tell the server that the file must be activated. To activate the file, you must create a symbolic link to the file in the directory / etc / apache2 / sites-enabled. Create it with the command In:

ln -s /etc/apache2/sites-available/ /etc/apache2/sites-enabled/
   When we perform this task, then we can turn off the file created from the settings, you just need to simply remove the link to the file itself sites-enabled, or creating a link again, what would it be restored. 
Let's take a first run configuration, restarting Apache:
/etc/init.d/apache2 restart
   Now it is necessary to perform the least - it is necessary to tell the browser that the domain name further need to find IP-address of our virtual machine. To do this, you need to make this entry in the hosts (standard it is usually located in c: \ windows \ system32 \ drivers \ etc \). If you have a WindowsVista / Seven, then you must run with administrative assistance. You also need to perform:

notepad.exe c: \ windows \ system32 \ drivers \ etc \ hosts
At the end you need to add:
   Next you need to save the file, then run a browser and type in the address bar then opens the standard we view the catalog page via HTTP
Index of / Name Last modified Size Description Apache / 2.2.16 (Debian) Server at Port 80
Good job, our first site under the Linux-VPS is up and running perfectly.
Installing the FTP-server in Debian
   Further, as Apache is set up, you need to install a ready-made content on our server. But that would make it necessary to establish a FTP-server. Then we return back to Debian and write: 
when you install it will ask which version of the paper, you must choose a standalone, resulting in the FTP-server is installed, it will also automatically configured and operational. To connect to it, you can use any FTP-client (Filezilla, TotalCommander, etc.), we use the already created user settings userone.
   Again, you can work on the site in the same way as on a real server. Well, in general, good luck to you in your endeavors.