diff --git a/sources/tech/20150108 How to Install SSL on Apache 2.4 in Ubuntu 14.0.4.md b/sources/tech/20150108 How to Install SSL on Apache 2.4 in Ubuntu 14.0.4.md new file mode 100644 index 0000000000..3cac73fc2e --- /dev/null +++ b/sources/tech/20150108 How to Install SSL on Apache 2.4 in Ubuntu 14.0.4.md @@ -0,0 +1,71 @@ +How to Install SSL on Apache 2.4 in Ubuntu 14.0.4 +================================================================================ +Today I will show you how to install a **SSL certificate** on your personal website or blog, to help secure the communications between your visitors and your website. + +Secure Sockets Layer or SSL, is the standard security technology for creating an encrypted connection between a web server and a web browser. This ensures that all data passed between the web server and the web browser remain private and secure. It is used by millions of websites in the protection of their online communications with their customers. In order to be able to generate an SSL link, a web server requires a SSL Certificate. + +You can create your own SSL Certificate, but it will not be trusted by default in web browsers, to fix this you will have to buy a digital certificate from a trusted Certification Authority (CA), we will show you below how to get the certificate and install it in apache. + +### Generating a Certificate Signing Request ### + +The Certification Authority (CA) will ask you for a Certificate Signing Request (CSR) generated on your web server. This is a simple step and only takes a minute, you will have to run the following command and input the requested information: + + # openssl req -new -newkey rsa:2048 -nodes -keyout yourdomainname.key -out yourdomainname.csr + +The output should look something like this: + +![generate csr](http://blog.linoxide.com/wp-content/uploads/2015/01/generate-csr.jpg) + +This begins the process of generating two files: the Private-Key file for the decryption of your SSL Certificate, and a certificate signing request (CSR) file (used to apply for your SSL Certificate) with apache openssl. + +Depending on the authority you apply to, you will either have to upload your csr file or paste it's content in a web form. + +### Installing the actual certificate in Apache ### + +After the generation process is finished you will receive your new digital certificate, for this article we have used [Comodo SSL][1] and received the certificate in a zip file. To use it in apache you will first have to create a bundle of the certificates you received in the zip file with the following command: + + # cat COMODORSADomainValidationSecureServerCA.crt COMODORSAAddTrustCA.crt AddTrustExternalCARoot.crt > bundle.crt + +![bundle](http://blog.linoxide.com/wp-content/uploads/2015/01/bundle.jpg) + +Now make sure that the ssl module is loaded in apache by running the following command: + + # a2enmod ssl + +If you get the message "Module ssl already enabled" you are ok, if you get the message "Enabling module ssl." you will also have to run the following command to restart apache: + + # service apache2 restart + +Finally modify your virtual host file (generally found in /etc/apache2/sites-enabled) to look something like this: + + DocumentRoot /var/www/html/ + ServerName linoxide.com + SSLEngine on + SSLCertificateFile /usr/local/ssl/crt/yourdomainname.crt + SSLCertificateKeyFile /usr/local/ssl/yourdomainname.key + SSLCACertificateFile /usr/local/ssl/bundle.crt + +You should now access your website using https://YOURDOMAIN/ (be careful to use 'https' not http) and see the SSL in progress (generally indicated by a lock in your web browser). + +**NOTE:** All the links must now point to https, if some of the content on the website (like images or css files) still point to http links you will get a warning in the browser, to fix this you have to make sure that every link points to https. + +### Redirect HTTP requests to HTTPS version of your website ### + +If you wish to redirect the normal HTTP requests to HTTPS version of your website, add the following text to either the virtual host you wish to apply it to or to the apache.conf if you wish to apply it for all websites hosted on the server: + + RewriteEngine On + RewriteCond %{HTTPS} off + RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} + +-------------------------------------------------------------------------------- + +via: http://linoxide.com/ubuntu-how-to/install-ssl-apache-2-4-in-ubuntu/ + +作者:[Adrian Dinu][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出 + +[a]:http://linoxide.com/author/adriand/ +[1]:https://ssl.comodo.com/ \ No newline at end of file diff --git a/sources/tech/20150108 How to Install Scrapy a Web Crawling Tool in Ubuntu 14.04 LTS.md b/sources/tech/20150108 How to Install Scrapy a Web Crawling Tool in Ubuntu 14.04 LTS.md new file mode 100644 index 0000000000..1f8d44f838 --- /dev/null +++ b/sources/tech/20150108 How to Install Scrapy a Web Crawling Tool in Ubuntu 14.04 LTS.md @@ -0,0 +1,129 @@ +How to Install Scrapy a Web Crawling Tool in Ubuntu 14.04 LTS +================================================================================ +It is an open source software which is used for extracting the data from websites. Scrapy framework is developed in Python and it perform the crawling job in fast, simple and extensible way. We have created a Virtual Machine (VM) in virtual box and Ubuntu 14.04 LTS is installed on it. + +### Install Scrapy ### + +Scrapy is dependent on Python, development libraries and pip software. Python latest version is pre-installed on Ubuntu. So we have to install pip and python developer libraries before installation of Scrapy. + +Pip is the replacement for easy_install for python package indexer. It is used for installation and management of Python packages. Installation of pip package is shown in Figure 1. + + sudo apt-get install python-pip + +![Fig:1 Pip installation](http://blog.linoxide.com/wp-content/uploads/2014/11/f1.png) + +Fig:1 Pip installation + +We have to install python development libraries by using following command. If this package is not installed then installation of scrapy framework generates error about python.h header file. + + sudo apt-get install python-dev + +![Fig:2 Python Developer Libraries](http://blog.linoxide.com/wp-content/uploads/2014/11/f2.png) + +Fig:2 Python Developer Libraries + +Scrapy framework can be installed either from deb package or source code. However we have installed deb package using pip (Python package manager) which is shown in Figure 3. + + sudo pip install scrapy + +![Fig:3 Scrapy Installation](http://blog.linoxide.com/wp-content/uploads/2014/11/f3.png) + +Fig:3 Scrapy Installation + +Scrapy successful installation takes some time which is shown in Figure 4. + +![Fig:4 Successful installation of Scrapy Framework](http://blog.linoxide.com/wp-content/uploads/2014/11/f4.png) + +Fig:4 Successful installation of Scrapy Framework + +### Data extraction using Scrapy framework ### + +**(Basic Tutorial)** + +We will use Scrapy for the extraction of store names (which are providing Cards) item from fatwallet.com web site. First of all, we created new scrapy project “store_name” using below given command and shown in Figure 5. + + $sudo scrapy startproject store_name + +![Fig:5 Creation of new project in Scrapy Framework](http://blog.linoxide.com/wp-content/uploads/2014/11/f5.png) + +Fig:5 Creation of new project in Scrapy Framework + +Above command creates a directory with title “store_name” at current path. This main directory of the project contains files/folders which are shown in the following Figure 6. + + $sudo ls –lR store_name + +![Fig:6 Contents of store_name project.](http://blog.linoxide.com/wp-content/uploads/2014/11/f6.png) + +Fig:6 Contents of store_name project. + +A brief description of each file/folder is given below; + +- scrapy.cfg is the project configuration file +- store_name/ is another directory inside the main directory. This directory contains python code of the project. +- store_name/items.py contains those items which will be extracted by the spider. +- store_name/pipelines.py is the pipelines file. +- Setting of store_name project is in store_name/settings.py file. +- and the store_name/spiders/ directory, contains spider for the crawling + +As we are interested to extract the store names of the Cards from fatwallet.com site, so we updated the contents of the file as shown below. + + import scrapy + + class StoreNameItem(scrapy.Item): + + name = scrapy.Field() # extract the names of Cards store + +After this, we have to write new spider under store_name/spiders/ directory of the project. Spider is python class which consist of following mandatory attributes : + +1. Name of the spider (name ) +1. Starting url of spider for crawling (start_urls) +1. And parse method which consist of regex for the extraction of desired items from the page response. Parse method is the important part of spider. + +We created spider “store_name.py” under store_name/spiders/ directory and added following python code for the extraction of store name from fatwallet.com site. The output of the spider is written in the file (**StoreName.txt**) which is shown in Figure 7. + + from scrapy.selector import Selector + from scrapy.spider import BaseSpider + from scrapy.http import Request + from scrapy.http import FormRequest + import re + class StoreNameItem(BaseSpider): + name = "storename" + allowed_domains = ["fatwallet.com"] + start_urls = ["http://fatwallet.com/cash-back-shopping/"] + + def parse(self,response): + output = open('StoreName.txt','w') + resp = Selector(response) + + tags = resp.xpath('//tr[@class="storeListRow"]|\ + //tr[@class="storeListRow even"]|\ + //tr[@class="storeListRow even last"]|\ + //tr[@class="storeListRow last"]').extract() + for i in tags: + i = i.encode('utf-8', 'ignore').strip() + store_name = '' + if re.search(r"class=\"storeListStoreName\">.*?<",i,re.I|re.S): + store_name = re.search(r"class=\"storeListStoreName\">.*?<",i,re.I|re.S).group() + store_name = re.search(r">.*?<",store_name,re.I|re.S).group() + store_name = re.sub(r'>',"",re.sub(r'<',"",store_name,re.I)) + store_name = re.sub(r'&',"&",re.sub(r'&',"&",store_name,re.I)) + #print store_name + output.write(store_name+""+"\n") + +![Fig:7 Output of the Spider code .](http://blog.linoxide.com/wp-content/uploads/2014/11/f7.png) + +Fig:7 Output of the Spider code . + +*NOTE: The purpose of this tutorial is only the understanding of Scrapy Framework* + +-------------------------------------------------------------------------------- + +via: http://linoxide.com/ubuntu-how-to/scrapy-install-ubuntu/ + +作者:[nido][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出 + +[a]:http://linoxide.com/author/naveeda/ \ No newline at end of file diff --git a/sources/tech/20150108 Interface (NICs) Bonding in Linux using nmcli.md b/sources/tech/20150108 Interface (NICs) Bonding in Linux using nmcli.md new file mode 100644 index 0000000000..fa02f19ce6 --- /dev/null +++ b/sources/tech/20150108 Interface (NICs) Bonding in Linux using nmcli.md @@ -0,0 +1,136 @@ +Interface (NICs) Bonding in Linux using nmcli +================================================================================ +Today, we'll learn how to perform Interface (NICs) bonding in our CentOS 7.x using nmcli (Network Manager Command Line Interface). + +NICs (Interfaces) bonding is a method for linking **NICs** together logically to allow fail-over or higher throughput. One of the ways to increase the network availability of a server is by using multiple network interfaces. The Linux bonding driver provides a method for aggregating multiple network interfaces into a single logical bonded interface. It is a new implementation that does not affect the older bonding driver in linux kernel; it offers an alternate implementation. + +**NIC bonding is done to provide two main benefits for us:** + +1. **High bandwidth** +1. **Redundancy/resilience** + +Now lets configure NICs bonding in CentOS 7. We'll need to decide which interfaces that we would like to configure a Team interface. + +run **ip link** command to check the available interface in the system. + + $ ip link + +![ip link](http://blog.linoxide.com/wp-content/uploads/2015/01/ip-link.png) + +Here we are using **eno16777736** and **eno33554960** NICs to create a team interface in **activebackup** mode. + +Use **nmcli** command to create a connection for the network team interface,with the following syntax. + + # nmcli con add type team con-name CNAME ifname INAME [config JSON] + +Where **CNAME** will be the name used to refer the connection ,**INAME** will be the interface name and **JSON** (JavaScript Object Notation) specifies the runner to be used.**JSON** has the following syntax: + + '{"runner":{"name":"METHOD"}}' + +where **METHOD** is one of the following: **broadcast, activebackup, roundrobin, loadbalance** or **lacp**. + +### 1. Creating Team Interface ### + +Now let us create the team interface. here is the command we used to create the team interface. + + # nmcli con add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}' + +![nmcli con create](http://blog.linoxide.com/wp-content/uploads/2015/01/nmcli-con-create.png) + +run **# nmcli con show** command to verify the team configuration. + + # nmcli con show + +![Show Teamed Interace](http://blog.linoxide.com/wp-content/uploads/2015/01/show-team-interface.png) + +### 2. Adding Slave Devices ### + +Now lets add the slave devices to the master team0. here is the syntax for adding the slave devices. + + # nmcli con add type team-slave con-name CNAME ifname INAME master TEAM + +Here we are adding **eno16777736** and **eno33554960** as slave devices for **team0** interface. + + # nmcli con add type team-slave con-name team0-port1 ifname eno16777736 master team0 + + # nmcli con add type team-slave con-name team0-port2 ifname eno33554960 master team0 + +![adding slave devices to team](http://blog.linoxide.com/wp-content/uploads/2015/01/adding-to-team.png) + +Verify the connection configuration using **#nmcli con show** again. now we could see the slave configuration. + + #nmcli con show + +![show slave config](http://blog.linoxide.com/wp-content/uploads/2015/01/show-slave-config.png) + +### 3. Assigning IP Address ### + +All the above command will create the required configuration files under **/etc/sysconfig/network-scripts/**. + +Lets assign an IP address to this team0 interface and enable the connection now. Here is the command to perform the IP assignment. + + # nmcli con mod team0 ipv4.addresses "192.168.1.24/24 192.168.1.1" + # nmcli con mod team0 ipv4.method manual + # nmcli con up team0 + +![ip assignment](http://blog.linoxide.com/wp-content/uploads/2015/01/ip-assignment.png) + +### 4. Verifying the Bonding ### + +Verify the IP address information in **#ip add show team0** command. + + #ip add show team0 + +![verfiy ip address](http://blog.linoxide.com/wp-content/uploads/2015/01/verfiy-ip-adress.png) + +Now lets check the **activebackup** configuration functionality using the **teamdctl** command. + + # teamdctl team0 state + +![teamdctl active backup check](http://blog.linoxide.com/wp-content/uploads/2015/01/teamdctl-activebackup-check.png) + +Now lets disconnect the active port and check the state again. to confirm whether the active backup configuration is working as expected. + + # nmcli dev dis eno33554960 + +![disconnect activeport](http://blog.linoxide.com/wp-content/uploads/2015/01/disconnect-activeport.png) + +disconnected the active port and now check the state again using **#teamdctl team0 state**. + + # teamdctl team0 state + +![teamdctl check activeport disconnect](http://blog.linoxide.com/wp-content/uploads/2015/01/teamdctl-check-activeport-disconnect.png) + +Yes its working cool !! we will connect the disconnected connection back to team0 using the following command. + + #nmcli dev con eno33554960 + +![nmcli dev connect disconected](http://blog.linoxide.com/wp-content/uploads/2015/01/nmcli-dev-connect-disconected.png) + +We have one more command called **teamnl** let us show some options with **teamnl** command. + +to check the ports in team0 run the following command. + + # teamnl team0 ports + +![teamnl check ports](http://blog.linoxide.com/wp-content/uploads/2015/01/teamnl-check-ports.png) + +Display currently active port of **team0**. + + # teamnl team0 getoption activeport + +![display active port team0](http://blog.linoxide.com/wp-content/uploads/2015/01/display-active-port-team0.png) + +Hurray, we have successfully configured NICs bonding :-) Please share feedback if any. + +-------------------------------------------------------------------------------- + +via: http://linoxide.com/linux-command/interface-nics-bonding-linux/ + +作者:[Arun Pyasi][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出 + +[a]:http://linoxide.com/author/arunp/ \ No newline at end of file