Normally, People Will Use SSH to Edit the Nginx Configuration Files. Here is How to Get Nginx Config Syntax Highlighting in Nano on Ubuntu. First, we are describing the method for localhost, so that one can test and edit the rc
files, in other two subheads, we will describe how to enable Nginx config Syntax Highlighting in Nano on Ubuntu Server and what are problems of Syntax Highlighting in Nano. By any means, DO NOT MAKE NANO THE DEFAULT TEXT EDITOR. Using Vi is not so difficult – open the file with command like vi /etc/nginx/nginx.conf
and press i
to edit. Edit it and press escape. Then type :w
to write out and :q
to exit.
Nginx Config Syntax Highlighting in Nano : OS X localhost
Apple keeps the Nano in 2.0.x version. Homebrew-dupes do not upgrade Nano anymore, why all do not like Nano to get upgraded will be discussed later. You can follow our guide to upgrade Nano in OS X in the guide for OS X Nano Syntax Highlighting. Only add this flag while building :
1 | --enable-nanorc |
Do not follow rest of the guide. Now, do these steps :
---
1 2 3 4 | cd ~ && git clone https://github.com/AbhishekGhosh/nano-syntax-highlighting-iNano-.git cd nano-syntax* && sudo make install-global TEXT=white vi /etc/nanorc # nano ~/.nanorc |
That /etc/nanorc
is a read only file unless you use --enable-nanorc
during building it. If you add ~/.nanorc
, it might create problem. Paste this line on either /etc/nanorc
(ideally) or in ~/.nanorc
(create it, it will not be present by default) :
1 | include "/usr/local/share/nano/ALL.nanorc" |
You will get Syntax highlighting more than default. This is my current repo on GitHub for Nanorc. Star the repo, I will update it. When I will update, you’ll also update again.
Test any file on your computer including Nginx Files.
Without the flag, adding the line on /etc/nanorc
, will not work.
Nginx Config Syntax Highlighting in Nano : Ubuntu Server
Nano is already in updated version. Be you are a user or the root, does not matter, the commands are same :
1 2 3 | cd ~ && git clone https://github.com/AbhishekGhosh/nano-syntax-highlighting-iNano-.git cd nano-syntax* && sudo make install-global TEXT=white vi ~/.nanorc |
As that /etc/nanorc
is a read only file unless we have not got the chance to build Nano with --enable-nanorc
flag, we have no other way than using ~/.nanorc
. Paste this line on ~/.nanorc
(create it, it will not be present by default) :
1 | include "/usr/local/share/nano/ALL.nanorc" |
Open any nginx file with nano like /etc/nginx/sites-available/default
or /etc/nginx/nginx.conf
. Getting color? If you do not get color, that is for so many commented out stuffs on default
, remove them, you’ll get color.
Why Syntax Highlighting in Nano is Disabled By Default?
Nano’s syntax highlighting is kept to off to avoid segmentation error
. Apple probably does not upgrade Nano out of fear. Maybe, Homebrew-dupes discontinued for the same reasons. We have some collection of nanorc files – on the Github repo, the script concatenates all the files to one; you will not need to add so much lines. We are including in this way :
include /usr/local/share/nano/ALL.nanorc
If you know more .nanorc
, you can send a pull request to add.
We use .zshrc
on all my Macs, MacBooks with export PATH=/usr/local/bin:$PATH
on both .zshrc
and .bash_profile
. As Nano is not the system default text editor, unlike vi, there is no fear, you can build the latest version.
Our .bash_profile
has that only one line. There is no .bashrc
. It is impractical to comment out so many includes
on the fly.
When nano will throw segmentation error
, then the way is to use vi to open it with sudo vi ~/.nanorc
in Terminal (not iTerm2) and commenting out that line to solve the segmentation error
.
When Nano was ported from Pico – http://www.washington.edu/pine/getpine/
, then it had another name. Again it was re-written with the Nano name. At anytime, Nano can throw segmentation error
if you are using Syntax Highlighting. Nano supports both nanorc
and .nanorc
, even nanor.c
. The files can be kept at /usr/share/nano
or at $HOME
or /etc
either as nanorc
or .nanorc
. That segmentation fault or segmentation error can happen occur under some of these circumstances:
A buggy program
Try to access an array beyond the end of an array under C programming language
Missing config file or /dev/ inside a chrooted jail in shared libs
Hardware is faulty
Memory or driver is faulty
Overheating
So much is not said, only people says – “Vi is powerful editor”. Powerful means, it will not throw abnormal errors. Chance of error increases if you use Syntax Highlighting in Nano.
Tagged With edit nginx config ubuntu , ubuntu gedit nginx config highlight mode , nginx syntax , nginx configuration edit with nano , nano segfault using nanorc , nano nginixconf sytax , nano editor nginx , nano config , how to use nano to edit nginx in linux , what to edit in the nginx config to enable usage for organizer on windows