20141029-2 选题

This commit is contained in:
DeadFire 2014-10-29 16:41:20 +08:00
parent ae3d7383d0
commit 0ef9cf09fa
3 changed files with 464 additions and 0 deletions

View File

@ -0,0 +1,75 @@
How to Install and Setup My Weather Indicator in Ubuntu 14.10
================================================================================
![](http://www.omgubuntu.co.uk/wp-content/uploads/2014/10/my-weather-indicator.jpg)
**Theres no drought of ways to be kept abreast of the weather on the Ubuntu desktop, with the Unity Dash and desktop apps like [Typhoon][1] all offering to help.**
But panel applets that offer quick glance condition and temperature stats, with a ream of detailed meteorological data never more than a quick click away, are by far the most popular weather utilities on Linux.
[My Weather Indicator][2] by Atareao is one of this breed, and arguably the best.
It displays current temperature and conditions on the Unity panel, and has a menu stuffed full of stats, including feels like, cloudiness and sunrise/set times. In addition, theres a desktop widget, multiple location support, a choice of backend data providers, and plenty of configuration options.
Sounds pretty comprehensive, right? Lets walk through how to install and set it up on Ubuntu.
### Install My Weather Indicator in Ubuntu ###
My Weather Indicator is not available to install from the Ubuntu Software Center directly, but both a .deb installer and an officially maintained PPA (providing packages for both Ubuntu 14.04 LTS and 14.10) are provided by the developers.
- Download My Weather Indicator (.deb)
To ensure youre always kept up-to-date with the latest release I recommend adding the [Atareao PPA][3] to your Software Sources and installing from there.
How? **Open a new Terminal** window (Unity Dash > Terminal, or press Ctrl+Alt+T) and **enter the following two commands carefully**, entering your system password when prompted:
sudo add-apt-repository ppa:atareao/atareao
sudo apt-get update && sudo apt-get install my-weather-indicator
#### Setting Up My Weather Indicator ####
Regardless of how you install the tool, once you have you can launch it from the Unity Dash by searching for “weather”.
![](http://www.omgubuntu.co.uk/wp-content/uploads/2014/10/weather-icon.jpg)
The first time you open the app the following Preferences window will open. From here you can search for a location manually or set it to auto-detect using geo-ip — the latter of which can sometimes be a little imprecise, but saves the need to faff.
![](http://www.omgubuntu.co.uk/wp-content/uploads/2014/10/Screen-Shot-2014-10-27-at-17.39.07.jpeg)
If youre travelling (or in need of some small talk fodder) **you can monitor a second locale**, too. This is set up in the same way as the first but in the Second Location tab.
Checking the **Show Widget** box in the “**Widget Options**” section adds a small forecast desklet to your desktop. There are a number of different skins included, so be sure to play around to find the one you like the most (note: widget changes are applied on clicking Ok).
![](http://www.omgubuntu.co.uk/wp-content/uploads/2014/10/widgets.jpg)
My Weather Indicator uses [Open Weather Map][4] as its forecast backend by default, but other options can be selected from the **Weather Services** pane (*require an API key to function):
- Open Weather Map
- Yahoo! Weather
- Weather Underground*
- World Weather Online*
The **Units** tab is where you can configure measurements for temperature, pressure, wind speed, etc. These are applied globally to all configured locations; you cant have one location in Celsius and the other in Fahrenheit.
![](http://www.omgubuntu.co.uk/wp-content/uploads/2014/10/Screen-Shot-2014-10-27-at-17.38.54.jpeg)
Finally, in the General Options section you can set the refresh interval, set autostart preference, and choose from one of two panel icons.
MWI not your thing? Why not try [the nerdy way to view weather forecasts on Linux][5]?
--------------------------------------------------------------------------------
via: http://www.omgubuntu.co.uk/2014/10/install-weather-indicator-ubuntu-14-10
作者:[Joey-Elijah Sneddon][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:https://plus.google.com/117485690627814051450/?rel=author
[1]:https://launchpad.net/typhoon
[2]:https://launchpad.net/my-weather-indicator
[3]:https://launchpad.net/~atareao/+archive/ubuntu/atareao
[4]:http://openweathermap.org/
[5]:http://www.omgubuntu.co.uk/2014/02/get-weather-forecast-terminal-linux

View File

@ -0,0 +1,141 @@
How to create and manage LXC containers on Ubuntu
================================================================================
While the concept of containers was introduced more than a decade ago to manage shared hosting environments securely (e.g., FreeBSD jails), Linux containers such as LXC or [Docker][1] have gone mainstream only recently with the rising need to deploy applications for the cloud. While [Docker][2] is getting all the media spotlight these days with strong backing from major cloud providers (e.g., Amazon AWS, Microsoft Azure) and distro providers (e.g., Red Hat, Ubuntu), LXC is in fact the original container technology developed for Linux platforms.
If you are an average Linux user, what good does Docker/LXC bring to you? Well, containers are actually a great means to switch between distros literally instantly. Suppose your current desktop is Debian. You want Debian's stability. At the same time, you also want to play the latest Ubuntu games. Then instead of bothering to dual boot into a Ubuntu partition, or boot up a heavyweight Ubuntu VM, simply spin off a Ubuntu container on the spot, and you are done.
Even without all the goodies of Docker, what I like about LXC containers is the fact that LXC can be managed by libvirt interface, which is not the case for Docker. If you have been using libvirt-based management tools (e.g., virt-manager or virsh), you can use those same tools to manage LXC containers.
In this tutorial, I focus on the command-line usage of standard LXC container tools, and demonstrate **how to create and manage LXC containers from the command line on Ubuntu**.
### Install LXC on Ubuntu ###
To use LXC on Ubuntu, install LXC user-space tools as follows.
$ sudo apt-get install lxc
After that, check the current Linux kernel for LXC support by running lxc-checkconifg tool. If everything is enabled, kernel's LXC support is ready.
$ lxc-checkconfig
![](https://farm4.staticflickr.com/3955/15655792445_d462957ee9_z.jpg)
After installing LXC tools, you will find that an LXC's default bridge interface (lxcbr0) is automatically created (as configured in /etc/lxc/default.conf).
![](https://farm6.staticflickr.com/5598/15035046834_a53c092230_z.jpg)
When you create an LXC container, the container's interface will automatically be attached to this bridge, so the container can communicate with the world.
### Create an LXC Container ###
To be able to create an LXC container of a particular target environment (e.g., Debian Wheezy 64bit), you need a corresponding LXC template. Fortunately, LXC user space tools on Ubuntu come with a collection of ready-made LXC templates. You can find available LXC templates in /usr/share/lxc/templates directory.
$ ls /usr/share/lxc/templates
![](https://farm4.staticflickr.com/3954/15035046824_d15d1cbf6e_z.jpg)
An LXC template is nothing more than a script which builds a container for a particular Linux environment. When you create an LXC container, you need to use one of these templates.
To create a Ubuntu container, for example, use the following command-line:
$ sudo lxc-create -n <container-name> -t ubuntu
![](https://farm8.staticflickr.com/7559/15035638763_07d63e23ef_z.jpg)
By default, it will create a minimal Ubuntu install of the same release version and architecture as the local host, in this case Saucy Salamander (13.10) 64-bit.
If you want, you can create Ubuntu containers of any arbitrary version by passing the release parameter. For example, to create a Ubuntu 14.10 container:
$ sudo lxc-create -n <container-name> -t ubuntu -- --release utopic
It will download and validate all the packages needed by a target container environment. The whole process can take a couple of minutes or more depending on the type of container. So be patient.
![](https://farm4.staticflickr.com/3933/15469152369_6a48943cf3_z.jpg)
After a series of package downloads and validation, an LXC container image are finally created, and you will see a default login credential to use. The container is stored in /var/lib/lxc/<container-name>. Its root filesystem is found in /var/lib/lxc/<container-name>/rootfs.
All the packages downloaded during LXC creation get cached in /var/cache/lxc, so that creating additional containers with the same LXC template will take no time.
Let's see a list of LXC containers on the host:
$ sudo lxc-ls --fancy
----------
NAME STATE IPV4 IPV6 AUTOSTART
------------------------------------
test-lxc STOPPED - - NO
To boot up a container, use the command below. The "-d" option launches the container as a daemon. Without this option, you will directly be attached to console right after you launch the container.
$ sudo lxc-start -n <container-name> -d
After launching the container, let's check the state of the container again:
$ sudo lxc-ls --fancy
----------
NAME STATE IPV4 IPV6 AUTOSTART
-----------------------------------------
lxc RUNNING 10.0.3.55 - NO
You will see that the container is in "RUNNING" state with an IP address assigned to it.
You can also verify that the container's interface (e.g., vethJ06SFL) is automatically attached to LXC's internal bridge (lxcbr0) as follows.
$ brctl show lxcbr0
![](https://farm4.staticflickr.com/3932/15656618342_53c4bc19ca_z.jpg)
### Manage an LXC Container ###
Now that we know how to create and start an LXC container, let's see what we can do with a running container.
First of all, we want to access the container's console. For this, type this command:
$ sudo lxc-console -n <container-name>
![](https://farm8.staticflickr.com/7538/15470225050_d093cb1028_z.jpg)
Type <Ctrl+a q> to exit the console.
To stop and destroy a container:
$ sudo lxc-stop -n <container-name>
$ sudo lxc-destroy -n <container-name>
To clone an existing container to another, use these commands:
$ sudo lxc-stop -n <container-name>
$ sudo lxc-clone -o <container-name> -n <new-container-name>
### Troubleshooting ###
For those of you who encounter errors with LXC, here are some troubleshooting tips.
1. You fail to create an LXC container with the following error.
$ sudo lxc-create -n test-lxc -t ubuntu
----------
lxc-create: symbol lookup error: /usr/lib/x86_64-linux-gnu/liblxc.so.1: undefined symbol: cgmanager_get_pid_cgroup_abs_sync
This means that you are running the latest LXC, but with an older libcgmanager. To fix this problem, you need to update libcgmanager.
$ sudo apt-get install libcgmanager0
--------------------------------------------------------------------------------
via: http://xmodulo.com/lxc-containers-ubuntu.html
作者:[Dan Nanni][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://xmodulo.com/author/nanni
[1]:http://xmodulo.com/docker-containers-centos-fedora.html
[2]:http://xmodulo.com/manage-linux-containers-docker-ubuntu.html

View File

@ -0,0 +1,248 @@
How to install LEMP stack (nginx, MariaDB/MySQL and php) on CentOS
================================================================================
The LEMP stack is an increasingly popular web service stack, powering mission-critical web services in many production environments. As the name implies, the LEMP stack is composed of Linux, nginx, MariaDB/MySQL and PHP. nginx is a high performance and lightweight replacement of slow and hard-to-scale Apache HTTP server used in the traditional LAMP stack. MariaDB is a community-driven fork of MySQL, with more features and better performance. PHP, a server-side language for generating dynamic content, is processed by PHP-FPM, an enhanced implementation of PHP FastCGI.
In this tutorial, I demonstrate **how to set up the LEMP stack on CentOS platforms**. I target both CentOS 6 and CentOS 7 platforms, and point out differences where necessary.
### Step One: Nginx ###
As the first step, let's install nginx on CentOS, and do basic configuration for nginx, such as enabling auto-start and [customizing the firewall][1].
#### Install Nginx ####
Let's install a pre-built stable version of nginx package from its official RPM source.
On CentOS 7:
$ sudo rpm --import http://nginx.org/keys/nginx_signing.key
$ sudo rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
$ sudo yum install nginx
On CentOS 6:
$ sudo rpm --import http://nginx.org/keys/nginx_signing.key
$ sudo rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
$ sudo yum install nginx
Note that if you do not import the official nginx GPG key before installing nginx RPM, you will get this warning:
warning: /var/tmp/rpm-tmp.KttVHD: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
#### Start Nginx ####
After installation, nginx does not start automatically. Let's start nginx right now, and configure it to auto-start upon boot. Also, we need to open a TCP/80 port in the firewall so that you can access nginx webserver remotely. All of these are achieved by entering the following commands.
On CentOS 7:
$ sudo systemctl start nginx
$ sudo systemctl enable nginx
$ sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
$ sudo firewall-cmd --reload
On CentOS 6:
$ sudo service nginx start
$ sudo chkconfig nginx on
$ sudo iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
$ sudo service iptables save
#### Test Nginx ####
The default document root directory of nginx is /usr/share/nginx/html. A default index.html file must be already placed in this directory. Let's check if you can access this test web page by going to http://<nginx-ip-address>/
![](https://farm4.staticflickr.com/3940/15461279287_8573948074_b.jpg)
If you see the above page, nginx must be set up correctly. Proceed to the next.
### Step Two: MariaDB/MySQL ###
The next step is to install a database component of the LEMP stack. While CentOS/RHEL 6 or earlier provides MySQL server/client packages, CentOS/RHEL 7 has adopted MariaDB as the default implementation of MySQL. As a drop-in replacement of MySQL, MariaDB ensures maximum compatibility with MySQL in terms of APIs and command-line usages. Here is how to install and configure MariaDB/MySQL on CentOS.
On CentOS 7:
Install MariaDB server/client package and start MariaDB server as follows.
$ sudo yum install mariadb-server
$ sudo systemctl start mariadb
$ sudo systemctl enable mariadb
On CentOS 6:
Install MySQL server/client package, and start MySQL server as follows.
$ sudo yum install mysql-server
$ sudo service mysqld start
$ sudo chkconfig mysqld on
After launching MariaDB/MySQL server successfully, execute the following add-on script that comes with MariaDB/MySQL server package. This one-time run conducts several security hardening steps for the database server, such as setting the (non-empty) root password, removing anonymous user, and locking down remote access.
$ sudo mysql_secure_installation
![](https://farm8.staticflickr.com/7545/15644566071_8c39875512_z.jpg)
That's it for the database setup. Now move to the next step.
### Step Three: PHP ###
PHP is an important component of the LEMP stack, which is responsible for generating dynamic content from data stored in a MariaDB/MySQL server. For the LEMP stack, you need, at a minimum, to install PHP-FPM and PHP-MySQL. PHP-FPM (FastCGI Process Manager) implements an interface between nginx and PHP applications which generate dynamic content. The PHP-MySQL module allows PHP programs to access MariaDB/MySQL.
#### Install PHP Modules ####
On CentOS 7:
$ sudo yum php php-fpm php-mysql
On CentOS 6:
First you need to install REMI repository (refer to [this guide][2]), and install the packages from the repository.
$ sudo yum --enablerepo=remi install php php-fpm php-mysql
![](https://farm4.staticflickr.com/3934/15644566121_60cbaab8b7_z.jpg)
Two observations worth noting while installing PHP:
On CentOS 6, MySQL server and client packages will automatically be upgraded as part of dependencies of the latest php-mysql in REMI.
On both CentOS 6 and 7, installing the php package will also install Apache web server (i.e., httpd) as part of its dependencies. This can cause conflicts with nginx web server. We will take care of this problem in the next section.
Depending on your use cases, you may want to install any of the following additional PHP module packages with yum command to customize your PHP engine.
- **php-cli**: command-line interface for PHP. Useful for testing PHP from the command line.
- **php-gd**: image processing support for PHP.
- **php-bcmath**: arbitrary mathematics support for PHP.
- **php-mcrypt**: encryption algorithm support for PHP (e.g., DES, Blowfish, CBC, CFB, ECB ciphers).
- **php-xml**: XML parsing and manipulation support for PHP.
- **php-dba**: database abstraction layer support for PHP.
- **php-pecl-apc**: PHP accelerator/caching support.
To see a complete list of available PHP modules to install, run:
$ sudo yum search php- (CentOS 7)
$ sudo yum --enablerepo=remi search php- (CentOS 6)
#### Start PHP-FPM ####
You will need to start PHP-FPM, and add it to auto-start list.
On CentOS 7:
$ sudo systemctl start php-fpm
$ sudo systemctl enable php-fpm
On CentOS 6:
$ sudo chkconfig php-fpm on
$ sudo service php-fpm start
### Step Four: Configure the LEMP Stack ###
The final step of the tutorial is tuning the LEMP stack configuration.
#### Disable Httpd ####
Let's first disable httpd which was installed along with the PHP package earlier.
On CentOS 7:
$ sudo systemctl disable httpd
On CentOS 6:
$ sudo chkconfig httpd off
#### Configure Nginx ####
Next, let's configure nginx virtual hosts, so that nginx can process PHP via PHP-FPM. For that, open /etc/nginx/conf.d/default.conf with a text editor, and change it to the following.
$ sudo vi /etc/nginx/conf.d/default.conf
----------
server {
listen 80;
server_name www.server_domain.com;
root /usr/share/nginx/html;
index index.php index.html index.htm;
location / {
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
# nginx passes PHP scripts to FastCGI server via a TCP/9000 socket
# this setting much be consistent with /etc/php-fpm.d/www.conf
# try_files prevents nginx from passing bad scripts to FastCGI server
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Also, let's adjust the number of nginx worker threads (specified in /etc/nginx/nginx.conf), which is set to one by default. Typically, we create as many worker threads as the number of CPU cores you have. To check how many CPU core you have, run this command:
$ grep processor /proc/cpuinfo | wc -l
If you have 4 cores, change /etc/nginx/nginx.conf as follows.
$ sudo vi /etc/nginx/nginx.conf
----------
worker_processes 4;
#### Configure PHP ####
Next, let's customize PHP configuration in /etc/php.ini file. More specifically, add the following lines in /etc/php.ini.
cgi.fix_pathinfo=0
date.timezone = "America/New York"
As a security precaution, we want the PHP interpreter to process only an exact file path, instead of guessing any non-existing file. The first line above achieves this goal.
The second line specifies the default timezone used by date/time related PHP functions. Use [this guide][3] to find out your timezone, and set the value of **date.timezone** accordingly.
#### Test PHP ####
Finally, let's check if nginx can process a PHP page. Before testing, make sure to restart nginx and PHP-FPM.
On CentOS 7:
$ sudo systemctl restart nginx
$ sudo systemctl restart php-fpm
On CentOS 6:
$ sudo service nginx restart
$ sudo service php-fpm restart
Create a PHP file named test.php with the following content, and place it in /var/www/html/
<?php phpinfo(); ?>
Open a web browser, and go to http://<nginx-ip-address>/test.php.
![](https://farm6.staticflickr.com/5608/15647258715_9d7bcd8c73_z.jpg)
If you see the above page, you are all set with the LEMP stack!
--------------------------------------------------------------------------------
via: http://xmodulo.com/install-lemp-stack-centos.html
作者:[Dan Nanni][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://xmodulo.com/author/nanni
[1]:http://ask.xmodulo.com/open-port-firewall-centos-rhel.html
[2]:http://ask.xmodulo.com/install-remi-repository-centos-rhel.html
[3]:http://ask.xmodulo.com/set-default-timezone-php.html