星期日, 02. 九月 2018 11:58下午 – beautifulzzzz

 

Normally if you have a cable modem or DSL, you get your home PC’s IP
address dynamically assigned from your service provider. If you install
a home cable/DSL router between your modem and home network, your PC
will most likely get its IP address at boot time from the home router
instead. You can choose to disable the DHCP server feature on your home
router and set up a Linux box as the DHCP server.

Install LEMP (Linux, Nginx, MySQL and PHP) Stack on Ubuntu Linux 14.04 LTS

by
VIVEK
GITE on
DECEMBER 2, 2014

澳门金沙国际 1

I’m
a new Ubuntu Linux user. How do I install the LEMP stack on an Ubuntu
Linux 14.04 LTS server using command line options to serve dynamic web
apps?

As one of the most popular Linux distribution in the world, Ubuntu has
released the latest version on April 17, 2014. The latest version is
14.04 with code name Trusty Tahr. Ubunt 14.04 is a LTS (Long Term
Support) version. This means that Ubuntu 14.04 will be supported for the
next 5 years from the release date. In this tutorial we will cover
Nginx, MySQL and PHP installation on Ubuntu Linux v14.04.

Tutorial details
Difficulty Easy (rss)
Root privileges Yes
Requirements Ubuntu
Estimated completion time 15m

澳门金沙国际 2

1、Install gcc-arm-none-eabi

This chapter covers only the configuration of a DHCP server that
provides IP addresses. The configuration of a Linux DHCP client that
gets its IP address from a DHCP server is covered in Chapter 3, “Linux
Networking”,
on Linux Networking.

What is new in Ubuntu 14.04 (Trusty Tahr) version?

You may see it on
cyberciti.biz
or visit the Ubuntu home page at ubuntu.com.

1. Introduction

Bluez is the default Bluetooth protocol stack on Linux. It should be
present and installed on your Linux distribution. If not, building and
installing from source is not too difficult:

  • Download the latest stable source release of Bluez from here. Unzip
    the compressed file you downloaded.
  • Install the headers and libraries required for Bluez compilation:

澳门金沙国际 3

https://devzone.nordicsemi.com/tutorials/7/ This
link shows that development with GCC and Eclipse, As it say we should
download
extract and configure arm-none-eabi-gcc. But I find it's hard to download arm-none-eabi-gcc in China(You can chose XunLei to download). Besides I find a easy way to install it in Ubuntu-16.04 as following:

Download and Install the DHCP Package

Most RedHat and Fedora Linux software product packages are available in
the RPM format, whereas Debian and Ubuntu Linux use DEB format
installation files. When searching for these packages, remember that the
filename usually starts with the software package name and is followed
by a version number, as in dhcp-3.23.58-4.i386.rpm. (For help on
downloading and installing the package, see Chapter 6, “Installing
Linux
Software”.)

构建环境,卓殊解决。Nginx Installation

Nginx is one of the robust web server in Linux world. Nginx is a free,
open source, high performance HTTP server and reverse proxy, as weell as
an IMAP/POP3 proxy server. Now, we are going to install Nginx web
server.

First, make sure system is upto date:
$ sudo apt-get update $ sudo apt-get upgrade

2. Download And Install

I follow the blog (Installing Bluez 5.44 onto
Raspbian?)
to install bluez-5.50.

Download the most recent version from the official
page:.

For example, at the time of writing it was 5.50, so I used(on my pi):

wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.50.tar.xz

Then I extracted it and built it:

tar -xf bluez-5.50.tar.xz
cd bluez-5.50

Read the README! It lists the dependencies and the configure
switches:

Install the dependencies first: (glib, dbus, libdbus, udev, etc.)

sudo apt install libdbus-1-dev libudev-dev libical-dev libreadline-dev

note: If you do not install the libdbus-1-dev, you will later get
this strange error:

configure: error: D-Bus >= 1.6 is required

once you’ve installed dependencies, you can configure switches:

./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var  --enable-experimental

then do:

make
sudo make install

It takes maybe 10 minutes to compile. After installing, you should find
bluetoothd in /usr/libexec/bluetooth. You should also see bluetoothd
in /usr/lib/bluetooth.

Go to each of these directories and type

./bluetoothd --version

You’ll note that the one in libexec is new and the one in lib is old.

In order to make sure that d-bus is talking to you new BlueZ 5.50
and not your old BlueZ 5.43, you need to tell systemd to use the new
bluetooth daemon:

sudo vim /lib/systemd/system/bluetooth.service

Make sure the exec.start line points to your new daemon in
/usr/libexec/bluetooth.

For me, that wasn’t enough. No matter what, upon restart I always got
bluetoothd 5.43… So I just created a symlink from the old one to the
new.

First rename the old file:

sudo mv /usr/lib/bluetooth/bluetoothd /usr/lib/bluetooth/bluetoothd-543.orig

Create the symlink:

sudo ln -s /usr/libexec/bluetooth/bluetoothd /usr/lib/bluetooth/bluetoothd
sudo systemctl daemon-reload

That should do it.

澳门金沙国际 4

beautifulzzzz@lpc:~$ arm-none-eabi-gcc --version
The program 'arm-none-eabi-gcc' is currently not installed. You can install it by typing:
sudo apt install gcc-arm-none-eabi
beautifulzzzz@lpc:~$ sudo apt install gcc-arm-none-eabi

Managing the DHCP Server

Managing the DHCP daemon is easy to do, but the procedure differs
between Linux distributions. Here are some things to keep in mind.

  • Firstly, different Linux distributions use different daemon
    management systems. Each system has its own set of commands to do
    similar operations. The most commonly used daemon management systems
    are SysV and Systemd.
  • Secondly, the daemon name needs to be known. In this case the name
    of the daemon is dhcpd.

Armed with this information you can know how to:

  • Start your daemons automatically on booting
  • Stop, start and restart them later on during troubleshooting or when
    a configuration file change needs to be applied.

For more details on this, please take a look at the “Managing Daemons”
section of Chapter 6 “Installing Linux
Software”

Note: If you modify your daemon configuration file remember that the
changes won’t take effect till you restart the daemon.

Note: Remember to configure your daemon to start automatically upon
your next reboot.

#1 – Download and Install Nginx

The easiest way to download and install Nginx is using apt-get
command.
Here is the command:
$ sudo apt-get install nginx

澳门金沙国际 5

Fig.01: Download and Install Nginx on Ubuntu Linux

Just wait until installation is get done on the system.

3. How to use the bluez and hcitool

 

dhcpd.conf File

You can define your server configuration parameters in the dhcpd.conf
file which may be located in the /etc the /etc/dhcpd or /etc/dhcp3
directories depending on your version of Linux.

Note: The skeleton dhcp.conf file that is created when you install
the package may vary in its completeness. In Ubuntu / Debian, the
skeleton dhcpd.conf file is extensive with most of the commands
deactivated with a # sign at the beginning. In Fedora / RedHat / CentOS
an extensive sample is also created with activated commands. It is found
in the following location which you can always use as a guide.

/usr/share/doc/dhcp*/dhcpd.conf.sample

Note: The dhcpd.conf configuration file formats in Debian / Ubuntu
and Redhat / Fedora are identical.

Here is a quick explanation of the dhcpd.conf file: Most importantly,
there must be a subnet section for each interface on your Linux box.

ddns-update-style interim
ignore client-updates

subnet 192.168.1.0 netmask 255.255.255.0 {

   # The range of IP addresses the server
   # will issue to DHCP enabled PC clients
   # booting up on the network

   range 192.168.1.201 192.168.1.220;

   # Set the amount of time in seconds that
   # a client may keep the IP address

  default-lease-time 86400;
  max-lease-time 86400;

   # Set the default gateway to be used by
   # the PC clients

   option routers 192.168.1.1;
   # Don't forward DHCP requests from this
   # NIC interface to any other NIC
   # interfaces

   option ip-forwarding off;

   # Set the broadcast address and subnet mask
   # to be used by the DHCP clients

  option broadcast-address 192.168.1.255;
  option subnet-mask 255.255.255.0;

   # Set the NTP server to be used by the
   # DHCP clients

  option ntp-servers 192.168.1.100;

   # Set the DNS server to be used by the
   # DHCP clients

  option domain-name-servers 192.168.1.100;

   # If you specify a WINS server for your Windows clients,
   # you need to include the following option in the dhcpd.conf file:

  option netbios-name-servers 192.168.1.100;

   # You can also assign specific IP addresses based on the clients'
   # ethernet MAC address as follows (Host's name is "laser-printer":

  host laser-printer {
      hardware ethernet 08:00:2b:4c:59:23;
     fixed-address 192.168.1.222;
   }
}
#
# List an unused interface here
#
subnet 192.168.2.0 netmask 255.255.255.0 {
}

There are many more options statements you can use to configure DHCP.
These include telling the DHCP clients where to go for services such as
finger and IRC. Check the dhcp-options man page after you do your
install:

[root@bigboy tmp]# man dhcp-options

Note: The host statement seen in the sample dhcpd.conf file can be
very useful. Some devices such as network printers default to getting
their IP addresses using DHCP, but users need to access them by a fixed
IP address to print their documents. This statement can be used to
always provide specific IP address to DHCP queries from a predefined a
NIC MAC address. This can help to reduce systems administration
overhead.

#2 – Test Nginx

Once it get done, you can open your browser and type url
or to test it. If everything
goes normal, you will see Nginx welcome page:

澳门金沙国际 6

Fig.02: Welcome nginx page on Ubuntu Linux

3.1 setup bluetooth service

Start the bluetooth service and enable automatic startup, assuming
you’re using systemd as the init daemon:

sudo systemctl start bluetooth.service
sudo systemctl enable bluetooth.service

2、Download Nordic nRF5x SDK

DHCP Servers with Multiple NICs

DHCP servers with multiple interfaces pose two configuration challenges.
The first is setting up the correct routing and the second is making
sure only the required interfaces are listening to serve DHCP. Don’t
worry, both will be discussed next.

MySQL Installation On Ubuntu

MySQL is one of the most powerful database management system in Linux
world. Next, we are going to install it with PHP support.

3.2 hcitool scan for bluetooth devices

Before start scanning make sure that your bluetooth device is turned on
and not blocked, you can check that with the rfkill command:

sudo rfkill list

If the bluetooth device is blocked (soft or hard blocked), unblock it
with the rfkill command again:

sudo rfkill unblock bluetooth

Bring up the bluetooth device with hciconfig command and start scanning,
make sure the target device’s bluetooth is on and It’s discoverable:

sudo hciconfig hci0 up
hcitool scan

Wait few moment to complete the hcitool scan or hcitool lescan, the
results will be something like bellow:

澳门金沙国际 7

澳门金沙国际 8

Here 00:1A:7D:DA:71:0A is the bluetooth MAC address and SHEN-PC is the
name of the bluetooth device, i.e. an PC.

note: use hcitool lescan will forever scan ble devices, if use
ctrl+c stop it, it will show error(ref to LINKS
4
to solve):

hcitool lescan
Set scan parameters failed: Input/output error

Download the least nRF5x SDK
from  (the same to the
arm-none-eabi-gcc, you can chose the XunLei to download) ,and then
extract it in SDK-DIR(as you wish). The following shows the composition
of SDK:

Routing

When a DHCP configured PC boots, it requests its IP address from the
DHCP server. It does this by sending a standardized DHCP broadcast
request packet to the DHCP server with a source IP address of
255.255.255.255.

If your DHCP server has more than one interface, you have to add a route
for this 255.255.255.255 address so that it knows the interface on which
to send the reply; if not, it sends it to the default gateway. (In both
of the next two examples, we assume that DHCP requests will be coming in
on interface eth0).

Note: More information on adding Linux routes and routing may be
found in Chapter 3, “Linux
Networking”.

Note: You can’t run your DHCP sever on multiple interfaces because
you can only have one route to network 255.255.255.255. If you try to do
it, you’ll discover that DHCP serving working on only one interface.

#1 – Install MySQL and PHP support

Type the following command:
$ sudo apt-get install mysql-server php5-mysql

澳门金沙国际 9

Fig.03: Ubuntu Linux Install MySQL to Manage Site Data with PHP

During the installation, MySQL will ask you to enter MySQL root
password, other wise the installation will not continue. Type the
password you want, then press OK to continue the installation.

3.3 bluetooth service discovery

Now we have the bluetooth MAC address of the target device, use the
sdptool command to know which services (like DUN, Handsfree audio) are
available on that target device.

sdptool browse 28:ED:6A:A0:26:B7

You can also use the interactive bluetoothctl tool for this purpose.

If the target device is present, you can ping it with l2ping command,
requires root privilege:

➜  bluez-5.50  sudo l2ping 94:87:E0:B3:AC:6F
Ping: 94:87:E0:B3:AC:6F from B8:27:EB:8E:CC:51 (data size 44) ...
44 bytes from 94:87:E0:B3:AC:6F id 0 time 53.94ms
44 bytes from 94:87:E0:B3:AC:6F id 1 time 77.12ms
44 bytes from 94:87:E0:B3:AC:6F id 2 time 38.63ms
44 bytes from 94:87:E0:B3:AC:6F id 3 time 46.13ms
44 bytes from 94:87:E0:B3:AC:6F id 4 time 59.96ms
5 sent, 5 received, 0% loss

So, bluetooth service discovery is useful to determine the type of the
device, like if it’s a bluetooth mp3 player or it’s a keyboard.

澳门金沙国际 10

beautifulzzzz@lpc:~/Documents/nRF5_SDK_12.2.0_f012efa$ tree -L 2
.
├── components
│   ├── ant
│   ├── ble
│   ├── boards
│   ├── device
│   ├── drivers_ext
│   ├── drivers_nrf
│   ├── libraries
│   ├── nfc
│   ├── proprietary_rf
│   ├── sdk_validation.h
│   ├── serialization
│   ├── softdevice
│   └── toolchain
├── documentation
│   ├── index.html
│   ├── license.txt
│   ├── NordicS.jpg
│   ├── nRF5x_series_logo.png
│   └── release_notes.txt
├── examples
│   ├── ant
│   ├── ble_central
│   ├── ble_central_and_peripheral
│   ├── ble_peripheral
│   ├── crypto
│   ├── dfu
│   ├── dtm
│   ├── multiprotocol
│   ├── nfc
│   ├── peripheral
│   ├── proprietary_rf
│   └── readme.txt
├── external
│   ├── cifra_AES128-EAX
│   ├── fatfs
│   ├── freertos
│   ├── licenses_external.txt
│   ├── micro-ecc
│   ├── nano-pb
│   ├── nfc_adafruit_library
│   ├── nrf_cc310
│   ├── protothreads
│   ├── rtx
│   ├── segger_rtt
│   └── tiny-AES128
├── licenses.txt
├── nRF5x_MDK_8_11_1_IAR.msi
├── nRF5x_MDK_8_11_1_Keil4.msi
└── svd
    ├── nrf51.svd
    ├── nrf52840.svd
    └── nrf52.svd

Temporary Solution

You can temporarily add a route to 255.255.255.255 using the route add
command as seen below.

[root@bigboy tmp]# route add -host 255.255.255.255 dev eth0

If you want this routing state to be maintained after a reboot, then use
the permanent solution that’s discussed next.

#2 – Test MySQL

Once mysql installation finished, we can test it. Open your console and
type the following command:
$ mysql -u root -p

澳门金沙国际 11

Fig.04: Ubuntu test Mysql installation

If you type your password correctly, the you will see the mysql prompt.

LINKS

  • 1.Bluetooth on Modern Linux by Szymon
    Janc
  • 2.dbus-python
    tutorial
  • 3.Linux bluetooth setup with bluez and
    hcitool
  • 4.hcitool lescan shows I/O
    error

澳门金沙国际 12

@beautifulzzzz
智能硬件、物联网,热爱技术,关注产品
博客:http://blog.beautifulzzzz.com
园友交流群:414948975

 

Permanent Solution

Create a permanent route to 255.255.255.255. This will vary according to
your version of Linux

Fedora / RedHat /
CentOS:
Add the route to your
/etc/sysconfig/network-scripts/route-eth0 file if the route needs to be
added to your eth0 interface.

#
# File /etc/sysconfig/network-scripts/route-eth0
#

255.255.255.255/32 dev eth0

Ubuntu / Debian:
Add the route to your /etc/network/interfaces file. In this case the
route is added to the eth0 interface.

#
# File: /etc/network/interfaces
#

iface eth0 inet static

       up route add -host 255.255.255.255 eth0

Simple Linux routing is covered in Chapter 3, “Linux
Networking”
and will add more clarity to adding permanent static routes.

#3 – Securing access to MySQL

If we are going to use MySQL as a production database, we may want to
secure it. MySQL provides a shell script to help us securing it. Just
type the following command on your console:
$ sudo mysql_secure_installation
Here are the steps to do it.

3、Before Use Makefile To Bulid nRF51 Project

Listening

Once you have defined the interface for your DHCP routing you should
also ensure that your DHCP server only listens on that interface and no
others. This methodology to do this varies depending on your versión of
Linux.

Fedora / RedHat /
CentOS:
The /etc/sysconfig/dhcpd file must be edited and the
DHCPDARGS variable edited to include the preferred interface. In this
example interface eth0 is preferred.

# File: /etc/sysconfig/dhcpd
DHCPDARGS=eth1

Debian / Ubuntu:
The /etc/default/dhcp3-server file must be edited and the INTERFACES
variable edited to include the preferred interface. In this example
interface eth0 is preferred.

# File: /etc/default/dhcp3-server
INTERFACES="eth0"

You will be able to verify success in one of two ways. First the netstat
command using the –au options will give the list of interfaces listening
on the bootp (DHCP) UDP port.

[root@bigboy-f ~]# netstat -au  | grep bootp
udp        0     0 192.168.1.100:bootps    *:*
[root@bigboy-f ~]#

Secondly, your /var/log/messages file will also reveal the defined
interfaces used when the DHCPd daemon was restarted.

Jan  8 17:22:44 bigboy dhcpd: Listening on LPF/eth0/00:e0:18:5c:d8:41/192.168.1.0/24
Jan  8 17:22:44 bigboy dhcpd: Sending on   LPF/eth0/00:e0:18:5c:d8:41/192.168.1.0/24

Success! You can go back to lunch!

1. Enter your root password

Enter your current root password to continue to the next step.

澳门金沙国际 13

Fig.05: MySQL enter your root db password

To build an example in the SDK you first need to set the toolchain path
in makefile.windows or makefile.posix depending on platform you are
using. That is, the .posix should be edited if your are working on
either Linux or OS X. These files are located in:

Configuring Linux Clients to Use DHCP

A Linux NIC interface can be configured to obtain its IP address using
DHCP with the examples outlined in , “Chapter 3, Linux
Networking”.
Please refer to this chapter if you need a quick refresher on how to
configure a Linux DHCP client.

2.Change the root password

If you want to change it, press Y. Otherwise, press N.

澳门金沙国际 14

Fig.06: MySQL security

<SDK>/components/toolchain/gcc

Configuring Windows Clients to Use DHCP

Fortunately Windows defaults to using DHCP for all its NIC cards so you
don’t have to worry about doing any reconfiguration.

3.Remove anonymous user

It is recommended to remove anonymous user to mitigate risk who can log
in into your database.

澳门金沙国际 15

Fig.07: MySQL security

Open the file in a text editor, and make sure that the
GNU_INSTALL_ROOT variable is pointing to your Gnu tools for ARM
embedded Processors
 install directory.

Using a Single DHCP Server to Serve Multiple Networks

As stated before, DHCP clients send their requests for IP addresses to a
broadcast address which is limited to the local LAN. This would imply
that a DHCP server is required on each subnet. Not so. It is possible to
configure routers to forward DHCP requests to a DHCP server many hops
away. This is done by inserting the IP address of the router’s interface
on the DHCP client’s network into the forwarded packet. To the DHCP
server, the non-blank router IP address field takes precedence over the
broadcast address and it uses this value to provide a DHCP address that
is meaningful to the client. The DHCP server replies with a broadcast
packet, and the router, which has kept track of the initial forwarded
request, forwards it back towards the client. You can configure this
feature on Cisco devices by using the ip helper-address command on all
the interfaces on which DHCP clients reside. Here is a configuration
sample that points to a DHCP server with the IP address 192.168.36.25:

interface FastEthernet 2/1
  ip address 192.168.1.30 255.255.255.0
  ip helper-address 192.168.36.25

4.Disallow root login remotely

To make sure that no one remote your database as root from another
machines, we need to disallow root login remotely.

澳门金沙国际 16

Fig.08: MySQL security

Correct values for my current setup(my arm-none-eabi-gcc install in
/usr/bin):

Simple DHCP Troubleshooting

The most common problems with DHCP usually aren’t related to the server;
after the server is configured correctly there is no need to change any
settings and it therefore runs reliably. The problems usually occur at
the DHCP client’s end for a variety of reasons. The following sections
present simple troubleshooting steps that you can go through to ensure
that DHCP is working correctly on your network.

5.Remove test database

Sometimes some MySQL installation will create a database named ëtestí
for testing purpose. We can remove it if we donít use it.

澳门金沙国际 17

Fig.09: MySQL security

GNU_INSTALL_ROOT :=/usr
GNU_VERSION := 4.9.3
GNU_PREFIX := arm-none-eabi

DHCP Clients Obtaining 169.254.0.0 Addresses

Whenever Microsoft DHCP clients are unable to contact their DHCP server
they default to selecting their own IP address from the 169.254.0.0
network until the DHCP server becomes available again. This is
frequently referred to as Automatic Private IP Addressing (APIPA). Here
are some steps you can go through to resolve the problem:

  • Ensure that your DHCP server is configured correctly and use the
    pgrep command discussed earlier to make sure the DHCP process is
    running. Pay special attention to your 255.255.255.255 route,
    especially if your DHCP server has multiple interfaces.
  • Give your DHCP client a static IP address from the same range that
    the DHCP server is supposed to provide. See whether you can ping the
    DHCP server. If you cannot, double-check your cabling and your NIC
    cards.
  • DHCP uses the BOOTP protocol for its communication between the
    client and server. Make sure there are no firewalls blocking this
    traffic. DHCP servers expect requests on UDP port 67 and the DHCP
    clients expect responses on UDP port 68. Use tcpdump on the
    server’s NIC to verify the correct traffic flows.

6.Reload privilege tables

Then we need to reloading the privilege tables to ensure all changes
made so far will take effect immediately.

澳门金沙国际 18

Fig.10: MySQL security

 

Other DHCP Failures

If the DHCP server fails to start then use your regular troubleshooting
techniques outlined in Chapter 4, “Simple Network
Troubleshooting”,
to help rectify your problems. Most problems with an initial setup are
often due to:

  • Incorrect settings in the /etc/dhcpd.conf file such as not defining
    the networks for which the DHCP server is responsible;
  • Firewall rules that block the DHCP bootp protocol on UDP ports 67
    and 68;
  • Routers failing to forward the bootp packets to the DHCP server when
    the clients reside on a separate network.

Always check your /var/logs/messages file for dhcpd errors and remember
that mandatory keywords in your configuration file may change when you
upgrade your operating system. Always read the release notes to be sure.

7.Done

澳门金沙国际 19

Fig.11: MySQL security

4、Use Makefile To Bulid nRF51 Project

Conclusion

In most home-based networks, a DHCP server isn’t necessary because the
DSL router / firewall usually has DHCP capabilities, but it is an
interesting project to try. Just remember to make sure that the range of
IP addresses issued by all DHCP servers on a network doesn’t overlap
because it could possibly cause unexpected errors. You might want to
disable the router/firewall’s DHCP server capabilities to experiment
with your new Linux server.

A DHCP server may be invaluable in an office environment where the time
and cost of getting a network engineer to get the work done may make it
simpler for Linux systems administrators to do it by themselves.

Creating a Linux DHCP server is straightforward and touches all the
major themes in the previous chapters. Now it’s time to try something
harder, but before we do, we’ll do a quick refresher on how to create
the Linux users who’ll be using many of the applications outlined in the
rest of the book.


How to log dhcp logs 

Hello All,
How can I configure isc-dhcp-server to 
1. Not send log info to /var/log/syslog
2. Reduce the amount of info in the log file.

In /etc/dhcp/dhcpd.conf  I have 
log-facility local7;

In /etc/rsyslog.conf I have
local7.*                        /var/log/dhcpd.log

With this config  I see dhcp activity in both /var/log/syslog
and /var/log/dhcpd.log

Thanks
//Ger

Need to restart both rsyslog and dhcp server:

    sudo service rsyslog stop
    sudo service rsyslog start
    sudo /etc/init.d/isc-dhcp-server restart


How to not log logs to syslog
file?

 

Hello,

I have setup the ISC dhcp daemon (v3.0.4) on an Ubuntu Feisty server.

In my dhcpd.conf file I have setup logging to a separate file with the line:

log-facility local0;

I have setup syslog to log local0 to a file /var/log/dhcpd.

This is all working a treat – log entries are being written to /var/log/dhcpd.

The problem is that everything is *also* being logged to /var/log/syslog. I’m getting everything logged twice.

Can anyone tell me how to stop dhcpd logging to both places? I only want it to log to local0 and thus my /var/log/dhcpd file.

Thanks!

H.

 

 

07-05-2007, 11:18 AM   #2
blackhole54
Senior Member
 

Registered: Mar 2006
Posts: 1,896

Rep:
 
You need to make another change to your /etc/syslog.conf file. My edgy eft system has the line

Code:
*.*;auth,authpriv.none          -/var/log/syslog

in it. I believe changing it to

Code:
*.*;auth,authpriv.none;local0.none          -/var/log/syslog

would solve your problem. Check the syslog.conf man page for more info, or in case I screwed it up.

PHP Installation For Server Side Scripting

Since PHP is popular, a lot of websites is built using PHP language. As
of January 2013, PHP was installed on more than 240 millions websites.
Now we are going to install PHP on Ubuntu 14.04

Now you can try to build one of the example projects. Will use
the blinky example
here to keep it simple:

#1 – Download and install PHP

As usual, we can download and install PHP using apt-get command. Just
type the following command on your Ubuntu console or over the ssh based
session:
$ sudo apt-get install php5-fpm

澳门金沙国际 20

Fig.12: Install PHP for Server Side Processing on Ubuntu

And wait for the installation to complete.

Open terminal and change directory to:

Configure Nginx to work with PHP and MySQL Server on Ubuntu

Now we have all components installed. The next step is we need to
configure Nginx with PHP and MySQL. Let’s start to configure them.

<SDK>/examples/peripheral/<board name>/blank/armgcc/

#1 – Configure PHP5-FPM

PHP5-FPM configuration file is located at /etc/php5/fpm/php.ini. Open it
with your text editor
$ sudo vi /etc/php5/fpm/php.ini
Change this parameter, from:
cgi.fix_pathinfo=1
to:
cgi.fix_pathinfo=0
Save and close the file and then restart php5-fpm service, type:
$ sudo service php5-fpm restart

Type ‘make’. GNU Make should start the build using the Makefile and
output the result in the _build directory. If everything works you
should get the output shown in the screenshot below. 

#2 – Configure Nginx

Nginx configuration file is located at /etc/nginx/nginx.conf. But
basically, we don’t need to touch it. The configuration of nginx website
is located in /etc/nginx/sites-available/default file.
Open it, and uncomment lines:

 location ~ \.php$ {
         fastcgi_split_path_info ^(.+\.php)(/.+)$;
 #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
 #
 #       # With php5-cgi alone:
 #        fastcgi_pass 127.0.0.1:9000;
 #       # With php5-fpm:
         fastcgi_pass unix:/var/run/php5-fpm.sock;
         fastcgi_index index.php;
         include fastcgi_params;
 }

Then restart the services.
$ sudo service nginx restart
Please make sure, on Ubuntu 14.04, we cannot use fastcgi_pass
127.0.0.1:9000. So make sure that the line is commented. Otherwise, on
my machine, I got this error :
$ tail /var/log/nginx/error.log 2014/11/04 16:57:04 [emerg] 3216#0: "fastcgi_pass" directive is not allowed here in /etc/nginx/sites-enabled/default:59 2014/11/04 16:58:21 [emerg] 3256#0: "fastcgi_pass" directive is not allowed here in /etc/nginx/sites-enabled/default:59
On Ubuntu 14.04, I use the following line:
fastcgi_pass unix:/var/run/php5-fpm.sock
When I restart the Nginx and I still got the following error message:
2014/11/04 17:02:05 [emerg] 3295#0: "fastcgi_pass" directive is not allowed here in /etc/nginx/sites-enabled/default:61 2014/11/04 17:04:58 [emerg] 3410#0: "fastcgi_pass" directive is not allowed here in /etc/nginx/sites-enabled/default:61
Please make sure that you already uncomment this line:
location ~ \.php$ {

澳门金沙国际 21

#3 – Configure MySQL

After the configuration section is done, now we need to test them to
make sure that our configuration is working as required. On Ubuntu 14.04
the root document folder is located in /usr/share/nginx/html. So create
a file called /usr/share/nginx/html/phpinfo.php with the following code:

[php] view
plaincopy

  1. <span
    style=”margin:0px;
    padding:0px; word-wrap:break-word; color:rgb(0,0,0)”><strong><?</strong></span>
    <a target=”_blank”
    href=””
    style=”margin:0px;
    padding:0px; word-wrap:break-word; color:rgb(128,128,128);
    text-decoration:none”><span
    style=”margin:0px;
    padding:0px; word-wrap:break-word; color:rgb(0,0,102)”>phpinfo</span></a><span
    style=”margin:0px;
    padding:0px; word-wrap:break-word;
    color:rgb(102,204,102)”>(</span><span
    style=”margin:0px;
    padding:0px; word-wrap:break-word;
    color:rgb(102,204,102)”>)</span>;
    <span style=”margin:0px;
    padding:0px; word-wrap:break-word; color:rgb(0,0,0)”><strong>?></strong></span>

After restarting PHP-FPM and Nginx, open the browser and browse to the
php file, we got only a blank screen. No error message on the screen. No
error message on PHP-FPM and Nginx log file.
澳门金沙国际 22
Then we changed /usr/share/nginx/html/phpinfo.php file code on the root
document of Nginx, as follows:

[php] view
plaincopy

  1. <span
    style=”margin:0px;
    padding:0px; word-wrap:break-word; color:rgb(0,0,0)”><strong><?php</strong></span>
    <a target=”_blank”
    href=””
    style=”margin:0px;
    padding:0px; word-wrap:break-word; color:rgb(128,128,128);
    text-decoration:none”><span
    style=”margin:0px;
    padding:0px; word-wrap:break-word; color:rgb(0,0,102)”>phpinfo</span></a><span
    style=”margin:0px;
    padding:0px; word-wrap:break-word;
    color:rgb(102,204,102)”>(</span><span
    style=”margin:0px;
    padding:0px; word-wrap:break-word;
    color:rgb(102,204,102)”>)</span>;
    <span style=”margin:0px;
    padding:0px; word-wrap:break-word; color:rgb(0,0,0)”><strong>?></strong></span>

And then open the browser again and type url

澳门金沙国际 23
It seem that by default, we can not use short php-tag like this:

[php] view
plaincopy

  1. <span
    style=”margin:0px;
    padding:0px; word-wrap:break-word; color:rgb(0,0,0)”><strong><?</strong></span>
    … your code … <span style=”margin:0px;
    padding:0px; word-wrap:break-word; color:rgb(0,0,0)”><strong>?></strong></span>

To enable short php tag, we need to change the value of short_open_tag
parameter on php.ini file:
澳门金沙国际 24
Change the value from Off to On. Then restart your php5-fpm :
sudo service php5-fpm restart
Then try again to test your phpinfo file. Next, we will see if the MySQL
support is enabled or not. Scroll down the php configuration screen on
your browser, if you see MySQL block there, then MySQL support already
enabled.
澳门金沙国际 25
You are now ready to use Nginx, PHP5 and MySQL on Ubuntu server. I hope
this quick article help anyone who wish to install Linux, Nginx, PHP and
MySQL on Ubuntu 14.04.

If you instead get an error saying something like “the sysem cannot find
the files specified” it typically means that the GNU toolchain path is
set incorrectly. Verify the path in makefile.windows/posix if you get
this.

 

5、Install JLink-driver-for-linux

Refer to the blog: [那些解决]
ubuntu上安装JLink驱动境遇的坑及给后来者的提出,downloading
the corresponding version driver is ok. But I find that the older
version driver(older then 5.12) cna’t find!!!

澳门金沙国际 26

Unfortunately my JLink version is 4.80. Finally, I find
a Jlink-Linux-v480h-x64  in
CSDN:  and I also
upload it in: . This file is not
*.deb file, so we should install it as following:

beautifulzzzz@lpc:~/Downloads$ sudo cp JLink_Linux_V480h_x86_64.tgz /dev/bus
...
beautifulzzzz@lpc:/dev/bus$ sudo tar zxvf JLink_Linux_V480h_x86_64.tgz
beautifulzzzz@lpc:/dev/bus$ sudo rm JLink_Linux_V480h_x86_64.tgz 

Now plug the JLink device into the USB and then goto the
install-path(here is /dev/bus/JLink_Linux_V480h_x86_64), type
./JLinkExe command, you will see(as following screenshot) a Contex-M0
device was fond and the target interface speed is 100khz. If could not
find a device, please check whether the JLink device is inserted or the
JLink driver version is correct.

澳门金沙国际 27

 

6、Loadfile into nRf5x

Now you can use some JLink commands to erase、load、run、quit…

/* Open Jlink Commander from terminal in _build directory */ 
JLinkExe  -device <nRF51/nRF52>
> erase // Optional: erase target if not already blank
> loadfile <name>.hex // loads FW
> r // Reset and halt
> g // Run
> q //  Exit

If you get an error (Error: Programming failed @ address 0x00000000
(block verification error)) when tpye erase\澳门金沙国际 ,loadfile command, you
should write one and two to the memory at 4001E50C and 4001E504:(get
this from: Getting started with nRF51 development on Mac OS
X)

澳门金沙国际 28

Afer erase whole chip, loading the file into nRF51 is simple—— For
simplicity in this tutorial copy the softdevice (S110) .hex file to the
_build folder of the Heart Rate Monitor example. The programming is
performed from the _build folder:

_build em$ JLinkExe -device nrf51822_xxaa -if swd -speed 4000
[...]
J-Link>loadbin s110_nrf51822_7.0.0_softdevice.bin 0
J-Link>loadbin ble_app_hrs_s110_xxaa.hex 0x16000
J-Link>r
J-Link>g
J-Link>exit

Setting the correct device is crucial, and the speed setting is needed
to make the programming fast enough. The softdevice is first programmed
in the beginning (location 0) and the application is programmed
immediately after (0x16000 for S110 v7.0). After the programming a reset
is needed (‘r’ + ‘g’).

 

Next I will write use MakeFile to achieve automating tasks~

 


@beautifulzzzz
智能硬件、物联网,热爱技术,关注产品
博客:http://blog.beautifulzzzz.com
sina:http://weibo.com/beautifulzzzz?is_all=1

 

相关文章