Billing and payments
Cloud server volumes
Data centers and network
Data privacy and data portability
How it works
VPN to GPN
How to install LAMP on CentOS 6
LAMP is an acronym for Linux, Apache, MySQL, and PHP. All of these components together allow obtaining a full web-server. Each of them is responsible for a certain component of web-hosting.
All server settings are to be carried out with root privileges. To do this, run the command:
In the beginning, create a user under which we will work with site files. To do this, run the command:
This command will also create a home directory in /home/username. Website catalogues of the server will be stored inside the user's home directory.
For your convenience, the root directory of each site will be called by its name. Create a root directory for our future site. After that, make our user the owner of the directory.
Next, we set up the automatic loading at startup for the Apache server using chkconfig:
At this stage, it is necessary to make some changes in the Apache configuration files.
To do this, you will need a text editor such as nano. To install it, run the command
Let's start with the main Apache configuration file:
Find the following construction and leave a comment:
Insert the following construction below:
This will allow the server to work with the catalogue /home/username/ and support .htaccess.
Adding a website
The most popular method is creating a virtual host file in the conf.d/ directory. The advantage is that the catalogue already exists, and the file httpd.conf contains the following line:
These instructions include all files with the ".conf" extension in the conf.d / directory. It means that any files in this directory that have the ".conf" extension will be treated as Apache configuration files. The files are processed in alphabetical order.
Run the command:
Example of a filled virtual host file my-first-domain.com.conf:
- Server-IP – is the IP address of your server.
- ServerName - the name of the virtual host must be set to the fully qualified domain name (FQDN), in our case my-first-domain.com determines which domain name serves this virtual host.
- ServerAdmin - contact e-mail address of the domain administrator is included in the reports on the web server errors. It is recommended to have a separate mailbox for this purpose.
- ServerAlias - alias hostname, the value www.my-first-domain.com is obligatory, so that your site would work with both www, and without.
- DocumentRoot - the root folder of the virtual host. Specify the directory of the site placement / home / username / my-first-domain.com
After connecting a website, make sure that no mistakes have been made, and configuration files do not contain errors:
After that, restart Apache to apply changes:
Put a PHP script in the root directory:
Set the correct script rights with help of chmod chown
Open your website in a browser. If your domain is not directed to the IP address of the server, you can always add a line:
- Server-IP is the IP address of your server.
To the file hosts on your computer that you use for settings. In Windows, it is usually located in C:\Windows\System32\drivers\etc\, and in nix systems it’s located in /etc/
When installing the MySQL database server, according to the specified dependencies perl-DBI, perl-DBD-MySQL, mysql, and mysql-server will be installed as well.
Set MySQL to run automatically when the system launches:
Setting up MySQL
By default, after installation, we can connect to our database server under the root without entering the password. Therefore, we assign a password and make a few more settings by running the script:
This script (if you answer yes to all the questions) will set a new root password, remove anonymous users, prohibit connection from remote machines as root, and remove the test database. Please note that the root MySQL password should be stored in a safe place.
You can connect using a MySQL client:
Installing a MySQL module for PHP:
Basic installation includes a set of standard PHP modules. To see the list of available modules, run the command:
Installing extra modules (if you need them):
Adding a remi repository
If the repositories that are specified in the system are missing some packages, add a remi repository:
Remi repository will be turned off by default, but the packages can be installed using '--enablerepo=remi' for example:
It can also be activated in the file /etc/yum.repos.d/remi.repo
Change enabled=0 to enabled=1