+7 (495) 668-09-95

Knowledge base

Installing Linux, Apache, MySQL, PHP (LAMP) Manually

Before installing the software, update the information in the repositories using the following command.

root@i:~# apt-get update - for OS Debian,

root@i:~# yum makecache - for OS CentOS

After the updates are completed, continue with the installation of the needed software.

Apache

OS Debian

Install Apache Prefork using the following command:

root@i:~# apt-get install apache2

Install Apache Worker using the command

root@i:~# apt-get install apache2-mpm-worker

For Apache ITK, use the following command:

root@i:~# apt-get install apache2-mpm-itk

OS CentOS

Install Apache Prefork using the following command:

root@i:~# yum install httpd

To update the version of Apache Worker, use the following command to stop the webserver:

/etc/init.d/httpd stop

Next, open /etc/sysconfig/httpd for editing and enable the HTTPD=/usr/sbin/httpd.worker line by removing the comment mark. If the following lines are not present in the file, add them:

<IfModule worker.c>

StartServers       6

MinSpareServers    6

MaxSpareServers   15

ServerLimit      156

MaxClients       156

MaxRequestsPerChild  3000

</IfModule>

These directive values should be set as necessary.

To update the version of Apache ITK, enable the HTTPD=/usr/sbin/httpd.itk line by removing the comment mark. If the following lines are not present in the file, add them:

<IfModule itk.c>

StartServers       6

MinSpareServers    6

MaxSpareServers   15

ServerLimit      156

MaxClients       156

MaxRequestsPerChild  3000

</IfModule>

These directive values should be set as necessary.

MySQL

OS Debian

To install a MySQL database server, use the following command:

root@i:~# apt-get install mysql-server mysql-client

During installation, you must enter the access password for the root user of the MySQL server. Use complex passwords that contain upper and lower case letters, numbers and special characters.

OS CentOS

To install a MySQL database server, use the following command:

root@i:~# yum install mysql-server mysql-client

When installation is complete, start MySQL using the command:

root@i:~# /etc/init.d/mysqld start

then change the password using the command:

root@i:~# /usr/bin/mysqladmin -u root password 'mynewpassword'

PHP

The following commands install the basic PHP extensions and a module for Apache.

OS Debian

To install PHP, run the command:

root@i:~# apt-get install php5 php5-mysql

OS CentOS

To install PHP, run the command:

root@i:~# yum install php php-mysql

Site

OS Debian

For each added domain, create a separate configuration file and name it for the domain:

touch /etc/apache2/sites-enabled/mydomain.com

where “mydomain” is your domain name.

Open the configuration file to edit and add the following section:

<VirtualHost 1.0.0.1:80 >

       ServerName mydomain.com

       ServerAlias www.mydomain.com

       DocumentRoot /var/www/sites/mydomain.com

       CustomLog /var/www/httpd-logs/mydomain.com.access.log combined

       ErrorLog /var/www/httpd-logs/mydomain.com.error.log

       AddType application/x-httpd-php .php

</VirtualHost>

where 1.0.0.1 - is the server IP address and “mydomain.com” is your domain name.

If the website’s operation requires a database (MySQL in this example), connect to the server:

mysql -u root -p

and create a database:

create database db;

Create a user that will have full access rights to the database:

grant all privileges on mydb.* to 'myuser'@'localhost' identified by 'mypassword';

where “mydb” is the database name, “myuser” is the user name, and “mypassword” is the password.

Create directories for the site:

mkdir /var/www/sites/

mkdir /var/www/sites/mydomain.com

mkdir /var/www/httpd-logs

touch /var/www/httpd-logs/mydomain.com.access.log

touch /var/www/httpd-logs/mydomain.com.error.log

If necessary, install the desired CMS by going to the site directory…

cd /var/www/sites/mydomain.com

For CMS Joomla, download its installation package:

wget http://joomlacode.org/gf/download/frsrelease/19639/159961/Joomla_3.3.2-Stable-Full_Package.zip

Unpack the .zip file using the command:

unzip Joomla_3.3.2-Stable-Full_Package.zip

With the correct DNS configuration, you will be able to access your site through a browser using its domain name; otherwise, you can use the IP-address.

OS CentOS

For each added domain, create a separate configuration file and name it for the domain.

touch /etc/httpd/sites-enabled/mydomain.com.conf

where “mydomain” is your domain name.

 Open the configuration file to edit and add the following section:

<VirtualHost 1.0.0.1:80 >

       ServerName mydomain.com

       ServerAlias www.mydomain.com

       DocumentRoot /var/www/sites/mydomain.com

       CustomLog /var/www/httpd-logs/mydomain.com.access.log combined

       ErrorLog /var/www/httpd-logs/mydomain.com.error.log

       AddType application/x-httpd-php .php

</VirtualHost>

where 1.0.0.1 -

is the server IP address and “mydomain.com” is your domain name.

If the website’s operation requires a database (MySQL in this example), connect to the server:

mysql -u root -p

and create a database:

create database db;

Create a user that will have full access rights to the database:

grant all privileges on mydb.* to 'myuser'@'localhost' identified by 'mypassword';

where “mydb” is the database name, “myuser” is the user name, and “mypassword” is the password.

Create directories for the site:

mkdir /var/www/sites/

mkdir /var/www/sites/mydomain.com

mkdir /var/www/httpd-logs

touch /var/www/httpd-logs/mydomain.com.access.log

touch /var/www/httpd-logs/mydomain.com.error.log

If necessary, set the desired CMS by going to the site directory…

cd /var/www/sites/mydomain.com

For CMS Joomla, download its installation package:

wget http://joomlacode.org/gf/download/frsrelease/19639/159961/Joomla_3.3.2-Stable-Full_Package.zip

Unpack the .zip file using the command:

unzip Joomla_3.3.2-Stable-Full_Package.zip

With the correct DNS configuration, you will be able to access your site through a browser using its domain name; otherwise, you can use the IP-address.

 

Return to category