Selasa, 14 Juli 2015

Ubuntu 14.04 - Web Server Configuration

Tidak ada komentar:
In this article, I’m going to be outlining the steps to install and configure a complete web server on a base install of Ubuntu 14.04 LTS server edition.  Not only will you learn how to install a complete web server or “LAMP stack” from the command line, you’ll also understand a little bit more about how each service works.  Ubuntu LTS releases are proven server platforms, and 14.04 brings many needed updates to the LAMP stack, most notably Apache Server 2.4
I personally don’t prefer to install “Web server” package groups during server install time.  I like to install each necessary package one by one to ensure I only have the software that I require for my operation.  This tutorial is also useful if you’re running Ubuntu 14.04 desktop version and want to install a LAMP stack for testing or development purposes.

Requirements:

An Ubuntu 14.04 LTS install.  Each version (Desktop or Server) should work about the same, but keep in mind I wrote this tutorial using the server version.
Type ‘Y’ as appropriate.  If you have a fast network connection, this should take a matter of seconds!
Ubuntu and Debian based systems automatically assumes that you want to have apache2 (and several other services) started every time you boot your system as soon as you install them.  init scripts are included with the packages and installed to /etc/init.d/  On the server, the default run level for Ubuntu is 2.  If you ls /etc/rc2.d/ you’ll see a list of files that control the starting and stopping of services when that run level is entered.  You should see a script that beings with ‘S’ followed by a number and ends with ‘apache2′ which are links to the file in /etc/init.d/ If you want to start apache2 manually on your system, you can remove the startup scripts by running  update-rc.d -f apache2 remove
Of note:  Many system services are controlled by Ubuntu’s upstart system.  These system services can be controlled with ‘start ’, ‘stop ’, and ‘status ’.  At this time, apache2 does not seem to fall into that category.  To start, stop, or see the status of apache2, use the service command:  service apache2
To test that your installation is running and processing requests, you can use wget localhost/index.html
This should create a local file in your working directory.  cat that file and make sure there are some contents in that file.

Step 2:  Configuring Apache2

Web Root

The default public directory for apache2 is /var/www/html  .  This is where your html and php files will typically reside.
I prefer to give my web files the following permissions:
chown root:www-data /var/www/html -R
chmod g+s /var/www/html
chmod o-wrx /var/www/html -R
This changes the group ownership of all the web root and all files therein to apache2′s user, www-data.  Setting g+s tells the file system to create all new files in that directory with the same group ownership.

Config files

Most software and services in linux have associated config files.  In most major distributions, those files are located in the /etc directory tree.  apache2 is no different, many important config files are located in /etc/apache2 .  Our default config file is /etc/apache2/apache2.conf  .  This file contains import settings for apache2, such as logging and a few basic security settings.
Two subdirectories that are important are /etc/apache2/sites-available and /etc/apache2/sites-enabled
Typically, sites-available hosts config files defining VirtualHosts.  VirtualHosts allow apache2 to server multiple websites instead of just one.  For instance, you can have completely different websites for www.mydomain.com and www2.mydomain.com, or any number of different domain names.  These sites are defined in .conf files inside this directory.
sites-enabled is a directory which typically contains symlinks to files in sites-available.  Apache will load the files found in sites-enabled upon startup.  You may also elect to just put the .conf’s in this directory itself instead of symlinking, that is also very common.
We have now configured our first virtual host named www.mysite.com.  The first line of that file tells apache which IP and port to listen on for this virtual host.  In our case, *:80 means listen on any IP, port 80.  You can put in your server’s IP here if you like, but *:80 is fine.
The second line, ServerAdmin is optional, and so is the last line ErrorLog.  Whatever settings or options aren’t configured inside the tags will be inherited from apache2.conf or other config files.
The third line denotes the directory where you server’s web content will reside.  The default location for apache2 is /var/www.  I simply have chosen to create a subdirectory named mysite.com in that directory; another common location is a subdirectory in the /home directory.  This is up to you, and will vary upon your individual needs.
The fourth line is the host header apache2 will listen for, as sent by the end-user’s web browser.  As you may know, web resources can be accessed via IP address of the server, or a domain name as resolved by DNS.  On systems with more than one site, apache2 will read the domain name and present the appropriate content.
Now, let’s create our web root (aka DocumentRoot) folder and place a new index.html file into it.  mkdir /var/www/mysite.com
chown root:www-data /var/www/mysite.com -R
chmod g+s /var/www/mysite.com
Paste whatever you like into /var/www/mysite.com/index.html , obviously, a simple html web page would be fine.
Okay, now let’s cd /etc/apache2/sites-enabled and create a symlink to our new config file.  ln -s ../sites-available/mysite.com.conf
That will tell apache2 to load our newly created .conf file upon restart:  service apache2 restart
Everything should be fine, you might see a warning about “Could not reliably determine servers fqdn…”  That’s fine, it just indicates that there’s not a proper DNS entry for our server, or at the very least apache wasn’t able to determine it.  This will not affect the operation of your server for our purposes.
To test to make sure apache2 is actually serving our new page on our new virtualhost, let’s update our hosts file.  Add the following line to /etc/hosts
127.0.0.1 www.mysite.com
This will over ride www.mysite.com for your system, all of those requests will resolve to your local loopback IP, 127.0.0.1
You should now be able to run wget www.mysite.com/index.html and see the contents of your file placed in the working directory.  I recommend you cd ~ so you don’t accidentally create junk files in your config directories.
This should only take a few minutes to complete.  The default location for the config file is:
/etc/php5/apache2/php.ini
Most settings are appropriate by default.  Upon writing, the version that ships with Ubuntu 14.04 is 5.5.9.


Set password for the root user.  Make this a strong password.  I recommend a 14+ character passphrase with mixed case, numbers, and special symbols.  Make it something you can remember, or store it in a safe place that’s NOT ON THE WEBSERVER.  As with apache2 above, after installation, mysql will start automatically by default.  Next, restart apache2.
Next, we’re going to setup a new database for our web application, create a new user, and assign that user permissions only access that db.
mysql -p #enter the root password when prompted on the next line
CREATE DATABASE webdb;
CREATE USER ‘webuser’@'localhost’ IDENTIFIED BY ‘password_here’; #Be sure to replace ‘password_here’ with a strong password.
GRANT ALL PRIVILEGES ON webdb.* to webuser@’localhost’;
exit
This should complete the steps for MySQL.  Next, let’s install WordPress!


Source : http://funwithlinux.net/2014/04/ubuntu-14-04-web-server-tutorial/
Read More

Ubuntu 14.04 - DNS Server Configuration

Tidak ada komentar:

DNS server is used to resolve domain name into IP address. There are three common DNS server configurations can be done using BIND, caching nameserver, primary master and secondary master more info.
Here in this post we can see about how to install and configure DNS server in ubuntu 14.04.

 

 

 

 

 

 

Source : http://www.krizna.com/ubuntu/configure-dns-server-ubuntu-14-04/
Read More

Selasa, 14 Juli 2015

Ubuntu 14.04 - Web Server Configuration

Tidak ada komentar:
In this article, I’m going to be outlining the steps to install and configure a complete web server on a base install of Ubuntu 14.04 LTS server edition.  Not only will you learn how to install a complete web server or “LAMP stack” from the command line, you’ll also understand a little bit more about how each service works.  Ubuntu LTS releases are proven server platforms, and 14.04 brings many needed updates to the LAMP stack, most notably Apache Server 2.4
I personally don’t prefer to install “Web server” package groups during server install time.  I like to install each necessary package one by one to ensure I only have the software that I require for my operation.  This tutorial is also useful if you’re running Ubuntu 14.04 desktop version and want to install a LAMP stack for testing or development purposes.

Requirements:

An Ubuntu 14.04 LTS install.  Each version (Desktop or Server) should work about the same, but keep in mind I wrote this tutorial using the server version.
Type ‘Y’ as appropriate.  If you have a fast network connection, this should take a matter of seconds!
Ubuntu and Debian based systems automatically assumes that you want to have apache2 (and several other services) started every time you boot your system as soon as you install them.  init scripts are included with the packages and installed to /etc/init.d/  On the server, the default run level for Ubuntu is 2.  If you ls /etc/rc2.d/ you’ll see a list of files that control the starting and stopping of services when that run level is entered.  You should see a script that beings with ‘S’ followed by a number and ends with ‘apache2′ which are links to the file in /etc/init.d/ If you want to start apache2 manually on your system, you can remove the startup scripts by running  update-rc.d -f apache2 remove
Of note:  Many system services are controlled by Ubuntu’s upstart system.  These system services can be controlled with ‘start ’, ‘stop ’, and ‘status ’.  At this time, apache2 does not seem to fall into that category.  To start, stop, or see the status of apache2, use the service command:  service apache2
To test that your installation is running and processing requests, you can use wget localhost/index.html
This should create a local file in your working directory.  cat that file and make sure there are some contents in that file.

Step 2:  Configuring Apache2

Web Root

The default public directory for apache2 is /var/www/html  .  This is where your html and php files will typically reside.
I prefer to give my web files the following permissions:
chown root:www-data /var/www/html -R
chmod g+s /var/www/html
chmod o-wrx /var/www/html -R
This changes the group ownership of all the web root and all files therein to apache2′s user, www-data.  Setting g+s tells the file system to create all new files in that directory with the same group ownership.

Config files

Most software and services in linux have associated config files.  In most major distributions, those files are located in the /etc directory tree.  apache2 is no different, many important config files are located in /etc/apache2 .  Our default config file is /etc/apache2/apache2.conf  .  This file contains import settings for apache2, such as logging and a few basic security settings.
Two subdirectories that are important are /etc/apache2/sites-available and /etc/apache2/sites-enabled
Typically, sites-available hosts config files defining VirtualHosts.  VirtualHosts allow apache2 to server multiple websites instead of just one.  For instance, you can have completely different websites for www.mydomain.com and www2.mydomain.com, or any number of different domain names.  These sites are defined in .conf files inside this directory.
sites-enabled is a directory which typically contains symlinks to files in sites-available.  Apache will load the files found in sites-enabled upon startup.  You may also elect to just put the .conf’s in this directory itself instead of symlinking, that is also very common.
We have now configured our first virtual host named www.mysite.com.  The first line of that file tells apache which IP and port to listen on for this virtual host.  In our case, *:80 means listen on any IP, port 80.  You can put in your server’s IP here if you like, but *:80 is fine.
The second line, ServerAdmin is optional, and so is the last line ErrorLog.  Whatever settings or options aren’t configured inside the tags will be inherited from apache2.conf or other config files.
The third line denotes the directory where you server’s web content will reside.  The default location for apache2 is /var/www.  I simply have chosen to create a subdirectory named mysite.com in that directory; another common location is a subdirectory in the /home directory.  This is up to you, and will vary upon your individual needs.
The fourth line is the host header apache2 will listen for, as sent by the end-user’s web browser.  As you may know, web resources can be accessed via IP address of the server, or a domain name as resolved by DNS.  On systems with more than one site, apache2 will read the domain name and present the appropriate content.
Now, let’s create our web root (aka DocumentRoot) folder and place a new index.html file into it.  mkdir /var/www/mysite.com
chown root:www-data /var/www/mysite.com -R
chmod g+s /var/www/mysite.com
Paste whatever you like into /var/www/mysite.com/index.html , obviously, a simple html web page would be fine.
Okay, now let’s cd /etc/apache2/sites-enabled and create a symlink to our new config file.  ln -s ../sites-available/mysite.com.conf
That will tell apache2 to load our newly created .conf file upon restart:  service apache2 restart
Everything should be fine, you might see a warning about “Could not reliably determine servers fqdn…”  That’s fine, it just indicates that there’s not a proper DNS entry for our server, or at the very least apache wasn’t able to determine it.  This will not affect the operation of your server for our purposes.
To test to make sure apache2 is actually serving our new page on our new virtualhost, let’s update our hosts file.  Add the following line to /etc/hosts
127.0.0.1 www.mysite.com
This will over ride www.mysite.com for your system, all of those requests will resolve to your local loopback IP, 127.0.0.1
You should now be able to run wget www.mysite.com/index.html and see the contents of your file placed in the working directory.  I recommend you cd ~ so you don’t accidentally create junk files in your config directories.
This should only take a few minutes to complete.  The default location for the config file is:
/etc/php5/apache2/php.ini
Most settings are appropriate by default.  Upon writing, the version that ships with Ubuntu 14.04 is 5.5.9.


Set password for the root user.  Make this a strong password.  I recommend a 14+ character passphrase with mixed case, numbers, and special symbols.  Make it something you can remember, or store it in a safe place that’s NOT ON THE WEBSERVER.  As with apache2 above, after installation, mysql will start automatically by default.  Next, restart apache2.
Next, we’re going to setup a new database for our web application, create a new user, and assign that user permissions only access that db.
mysql -p #enter the root password when prompted on the next line
CREATE DATABASE webdb;
CREATE USER ‘webuser’@'localhost’ IDENTIFIED BY ‘password_here’; #Be sure to replace ‘password_here’ with a strong password.
GRANT ALL PRIVILEGES ON webdb.* to webuser@’localhost’;
exit
This should complete the steps for MySQL.  Next, let’s install WordPress!


Source : http://funwithlinux.net/2014/04/ubuntu-14-04-web-server-tutorial/
Read More

Ubuntu 14.04 - DNS Server Configuration

Tidak ada komentar:

DNS server is used to resolve domain name into IP address. There are three common DNS server configurations can be done using BIND, caching nameserver, primary master and secondary master more info.
Here in this post we can see about how to install and configure DNS server in ubuntu 14.04.

 

 

 

 

 

 

Source : http://www.krizna.com/ubuntu/configure-dns-server-ubuntu-14-04/
Read More

Subscribe