Install Lamp server and setup virtualhost:
You can install and configure the LAMP server by following the below steps.
Step 1.
First you need to provision the server with a linux based OS.
Step 2.
Check if the hostname is properly set on the server, for that use the following command from the command line,
hostname
This will display the current hostname of the server. You can modify the hostname using the command,
hostname <requiredhostname>
It will set the hostname that you have provided with the hostname command as server’s hostname.
Step 3.
Install Apache webserver:
To install the current version of the Apache web server (in the 2.x series) use the following command:
yum update yum install httpd
The configuration file of apache is httpd.conf
file, which is located at:/etc/httpd/conf/httpd.conf
. It is good to make a backup of this file.
Now you need to configure virtual hosting so that we can host multiple domains (or subdomains) with the server. These websites can be controlled by different users, or by a single user, as you prefer.
There are different ways to set up virtual hosts, however we recommend the method below. By default, Apache listens on all IP addresses available to it.
Open the below file,
/etc/httpd/conf.d/vhost.conf
Now, edit the file according to the website and document root that you need to set. You can edit it by seeing an example configuration that we have pasted below,
NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin webmaster@example.com ServerName example.com ServerAlias www.example.com DocumentRoot /srv/www/example.com/public_html/ ErrorLog /srv/www/example.com/logs/error.log CustomLog /srv/www/example.com/logs/access.log combined </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@example.org ServerName example.org ServerAlias www.example.org DocumentRoot /srv/www/example.org/public_html/ ErrorLog /srv/www/example.org/logs/error.log CustomLog /srv/www/example.org/logs/access.log combined </VirtualHost>
Remember to replace the example.com and example.org with the name of the websites you have also the document root will be the location of the folder where you will upload the contents of the website. After this restart httpd service, for the use the following command,
/etc/init.d/httpd start
Also you need to make the service httpd automatically on on server reboots, for that deploy the following command,
/sbin/chkconfig --levels 235 httpd on
Step 4:
Install and configure Mysql.
The first step is to install the mysql-server package, which is accomplished by the following command,
yum install mysql-server
If you want to run MySQL by default when the system boots, which is a typical setup, execute the following command,
/sbin/chkconfig --levels 235 mysqld on
Now you need to start the mysql service, for that deploy the command,
/etc/init.d/mysqld start
Step 5.
Installing and Configuring PHP
For installing PHP issue the following command,
yum install php php-pear
Then you will need to create the log directory for PHP and give the Apache user ownership. Use the below commands for that,
mkdir /var/log/php chown apache /var/log/php
Step 6.
If you need support for MySQL in PHP, then you must install the php5-mysql package with the following command,
yum install php-mysql
Step 7.
After making all the changes in php, restart the apache and mysql services using the following commands,
/etc/init.d/httpd restart
/etc/init.d/mysqld restart
Now the Lamp server is configured with the virtualhost and ready for hosting websites.
If you need our help to fix the issue with incoming/outgoing spam from your server. Please feel free to contact us, simply email to support@iserversupport.com
Monthly server support with Unlimited tickets, 24×7 monitoring, Security Audit and lot more for just $59
Leave A Comment