Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

CentOS 5 "cannot find a valid baseurl for repo" Error Fix


When trying to update or install packages on older CentOS 5 systems, you may run into the following error.
root@server1 [~]# yum update -y
Loaded plugins: fastestmirror
Determining fastest mirrors
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. Invalid release/
removing mirrorlist with no valid mirrors: /var/cache/yum/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base
This is commonly caused by attempting to use deprecated repositories. The update repositories were moved to the CentOS vault when the operating reached it's end-of-life.

In order to continue using the operating system packages, you will need to update your repository entries to point to the vault.

Using your favorite text editor, open /etc/yum.repos.d/CentOS-Base.repo

Look for the following:
[base]name=CentOS-$releasever - Basemirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
Comment out the mirror list, and uncomment the baseurl. So it should look like the following:
#mirrorlist=
baseurl=
Next, you will need to put in the URL for the vault repository.

for 32-bit systems, use: http://vault.centos.org/5.11/os/i386/

for 64-bit systems, use: http://vault.centos.org/5.11/os/x86_64/
For each repository, you will need to replace /os/ with what repository subdirectory you need. For example on a 64-bit system, for updates, your URL will look like http://vault.centos.org/5.11/updates/x86_64/ and for extras it will look like http://vault.centos.org/5.11/extras/x86_64/ Always check the old url first to make sure you have right path. You can also check http://vault.centos.org to see all available repositories.
Once you have added this, run the following to clean your yum cache:
yum clean all
Then update yum to start using the new repositories:
yum update

URL grabber error on yum update/install on CentOS7

URL grabber error on yum update/install on CentOS7

If you are using CentOS7, you may be already frustrated with the urlgrabber error while installing or updating the packages using yum.
[root@centos7 ~]# yum upgrade
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* epel: mirror.nus.edu.sg
* extras: centos.excellmedia.net
* updates: mirrors.vonline.vn
Traceback (most recent call last): 44% [=======================- ] 183 kB/s | 4.9 MB 00:00:33 ETA
File “/usr/libexec/urlgrabber-ext-down”, line 75, in <module>
main()
File “/usr/libexec/urlgrabber-ext-down”, line 61, in main
fo = PyCurlFileObject(opts.url, opts.filename, opts)
File “/usr/lib/python2.7/site-packages/urlgrabber/grabber.py”, line 1258, in __init__
self._do_open()
File “/usr/lib/python2.7/site-packages/urlgrabber/grabber.py”, line 1589, in _do_open
self._do_grab()
File “/usr/lib/python2.7/site-packages/urlgrabber/grabber.py”, line 1723, in _do_grab
self._do_perform()
File “/usr/lib/python2.7/site-packages/urlgrabber/grabber.py”, line 1517, in _do_perform
raise KeyboardInterrupt
KeyboardInterrupt
Exiting on user cancel

To fix this issue-

Edit the file /usr/lib/python2.7/site-packages/urlgrabber/grabber.py Change the line number 1510 as below Change “elif errcode in (42, 55, 56):” to “elif errcode == 42:"

Title : yum install exiting on user cancel | yum urlgrabber | file usr libexec urlgrabber ext down line 28 except oserror e | delta rpms disabled because /usr/bin/applydeltarpm not installed

Enable SSH root login on Ubuntu 16.04 Xenial Xerus Linux Server/Desktop

Enable SSH root login on Ubuntu 16.04 Xenial Xerus Linux Server/Desktop

The following config will guide you through the process of enabling SSH root login on Ubuntu 16.04 Xenial Xerus Linux Server or Desktop. This guide assumes that you are in possession of root password and are able to login directly on your system as root user. Use the following guide, if you do not have a root's user password.

By default the root's ssh remote shell access is denied by default. Any attempt to remote login as root will result in Permission denied message:
$ ssh root@10.1.10.1
root@
10.1.10.1's password:
Permission denied, please try again.
root@
10.1.10.1's password:

In order to enable root ssh login on Ubuntu 16.04 Xenial Xerus Linux run the following command:
$ sudo sed -i 's/prohibit-password/yes/' /etc/ssh/sshd_config
or manually open sshd configuration file /etc/ssh/sshd_config and change line:
FROM:
PermitRootLogin prohibit-password
TO:
PermitRootLogin yes
Once you have made the above configuration change restart ssh daemon:
$ sudo systemctl restart sshd
After you restart sshd daemon you will be able to remotely login as a root user:

$ ssh root@10.1.10.1
root@
10.1.10.1's password:
Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.4.0-22-generic x86_64)
 * Documentation:  https://help.ubuntu.com/
22 packages can be updated.
20 updates are security updates.

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
 
Tags :  Ubuntu 16.04 Xenial Xerus, Linux, ServerSSHD, SSH_CONFIG, PERMITROOTLOGIN

Install Django CMS on Ubuntu 12.04 with MariaDB, Gunicorn and Nginx

In this blog post we will show you how to install the Django CMS on a Ubuntu VPS with MariaDB, Nginx and Gunicorn  .

Django CMS is open source content management system based on the Web framework Django. Some of the main features include: Plugin-based, Pretty URLs, Permission management, Apps, Frontend-Editing, Analytics, Blog ..etc.

The following command will install all necessary packages
apt-get update
apt-get install -y python-software-properties python python-dev

Install the the latest version of Nginx

add-apt-repository ppa:nginx/stable
apt-get update && sudo apt-get install nginx

Install MariaDB and create a database.

apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
add-apt-repository 'deb http://ftp.osuosl.org/pub/mariadb/repo/5.5/ubuntu precise main'
apt-get update
echo -e "Package: *\nPin: origin ftp.osuosl.org\nPin-Priority: 1000" | tee /etc/apt/preferences.d/mariadb
apt-get install mariadb-server libmariadbclient-dev
mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE dcms;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON dcms.* TO 'dcmsuser'@'localhost' IDENTIFIED BY 'pa33W0rd';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q

Install pip


curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python -

Create a virtualenv using pip

sudo pip install --upgrade virtualenv
mkdir -p ~/.virtualenvs/djangocms
virtualenv ~/.virtualenvs/djangocms
source ~/.virtualenvs/djangocms/bin/activate

 Create a requirements.txt file with the following content

# Bare minimum
django-cms==2.4.1

#These dependencies are brought in by django-cms, but if you want to lock-in their version, specify them
Django==1.5.1
django-classy-tags==0.4
South==0.8.1
html5lib==1.0b1
django-mptt==0.5.2
django-sekizai==0.7
six==1.3.0
mysql-python==1.2.5

#Optional, recommended packages
Pillow==2.0.0
django-filer==0.9.4
cmsplugin-filer==0.9.5
django-reversion==1.7

Install django CMS

pip install --upgrade --download-cache=~/.pip-cache -r requirements.txt

Create your django CMS project

mkdir ~/projects
cd  ~/projects
django-admin.py startproject mynewproject
Open the file ~/projects/mynewproject/mynewproject/settings.py and add the following at the top of the file:
# -*- coding: utf-8 -*-
import os
gettext = lambda s: s
PROJECT_PATH = os.path.split(os.path.abspath(os.path.dirname(__file__)))[0]
Add your database details:
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'dcms', 
        'USER': 'dcms',
        'PASSWORD': 'pa33W0rd',
        'HOST': '',
        'PORT': '',
    }
}
Add the following apps to the INSTALLED_APPS.
'django.contrib.admin',
INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'django.contrib.admindocs',
    'cms',
    'mptt',
    'menus',
    'south',
    'sekizai'
)
Add the following lines to the MIDDLEWARE_CLASSES list.
MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    # Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'cms.middleware.page.CurrentPageMiddleware',
    'cms.middleware.user.CurrentUserMiddleware',
    'cms.middleware.toolbar.ToolbarMiddleware',
    'cms.middleware.language.LanguageCookieMiddleware',
)
Add the following at the end of the file:
TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.i18n',
    'django.core.context_processors.request',
    'django.core.context_processors.media',
    'django.core.context_processors.static',
    'cms.context_processors.media',
    'sekizai.context_processors.sekizai',
)
Change STATIC_ROOT and MEDIA_ROOT directives to:
STATIC_ROOT = os.path.join(PROJECT_PATH, "static")
STATIC_URL = "/static/"

MEDIA_ROOT = os.path.join(PROJECT_PATH, "media")
MEDIA_URL = "/media/"
Modify the TEMPLATE_DIRS directive:
TEMPLATE_DIRS = (
    # The docs say it should be absolute path: PROJECT_PATH is precisely one.
    # Life is wonderful!
    os.path.join(PROJECT_PATH, "templates"),
)
Add at least one template to CMS_TEMPLATES
CMS_TEMPLATES = (
    ('template_1.html', 'Template One'),
    ('template_2.html', 'Template Two'),
)
Limit to English
LANGUAGES = [
    ('en', 'English'),
]

Finally save the settings.py file.

Define routes for our project

Open mynewproject/mynewproject/urls.py file and replace the content with the following
from django.conf.urls.defaults import *
from django.conf.urls.i18n import i18n_patterns
from django.contrib import admin
from django.conf import settings

admin.autodiscover()

urlpatterns = patterns('',
  url(r'^admin/', include(admin.site.urls)),
  url(r'^', include('cms.urls')),
)
if settings.DEBUG:
    urlpatterns = patterns('',
    url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
    url(r'', include('django.contrib.staticfiles.urls')),
) + urlpatterns

Create templates

Create a new directory templates
mkdir ~/projects/mynewproject/templates
Open your favorite editor and create the following files:
base.html
{% load cms_tags sekizai_tags %}
<html>
  <head>
      {% render_block "css" %}
  </head>
  <body>
      {% cms_toolbar %}
      {% placeholder base_content %}
      {% block base_content %}{% endblock %}
      {% render_block "js" %}
  </body>
</html>
template_1.html
{% extends "base.html" %}
{% load cms_tags %}

{% block base_content %}
  {% placeholder template_1_content %}
{% endblock %}
template_2.html
{% extends "base.html" %}
{% load cms_tags %}

{% block base_content %}
  {% placeholder template_2_content %}
{% endblock %}

Initialize the database and create a new superuser

python manage.py syncdb --all
python manage.py migrate --fake

Check if everything is set up correctly

python manage.py cms check
If you see “Installation okay”, it means everything is set up correctly.

Collect  static files

cd ~/projects/mynewproject
./manage.py collectstatic

Install and configure gunicorn

pip install gunicorn
create a new configuration file (~/.virtualenvs/djangocms/gunicorn_config.py) as follows
command = '~/.virtualenvs/djangocms/bin/gunicorn'
pythonpath = '~/projects/mynewproject'
bind = '127.0.0.1:8011'
workers = 3
user = nobody
Start the gunicorn with the following command:
cd ~/projects/mynewproject && gunicorn -c ~/.virtualenvs/djangocms/gunicorn_config.py mynewproject.wsgi

Configure Nginx

Create a new nginx virtual host
vim /etc/nginx/sites-available/your_domain.com
server {
 listen       80;
 server_name  your_domain.com;

    location /static/ {
        alias /<your_username>/projects/mynewproject/static/;
    }

    location / {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_connect_timeout 10;
        proxy_read_timeout 10;
        proxy_pass http://localhost:8011/;
    }
 }

ln -s /etc/nginx/sites-available/your_domain.com /etc/nginx/sites-enabled/your_domain.com
/etc/init.d/nginx restart

That’s it. Now open your browser and navigate to your domain.

For more info about the Django CMS please go to: http://docs.django-cms.org/
Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install this for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Silicon Valley Network Administrator

Damn straight. This is what we do. Period. ‪#‎SysAdminDay‬ ‪#‎Funny‬‪#‎Truth‬ ‪#‎IT‬ 

Filter Negative Site by Power DNS And Unbound Ubuntu

Powerdns With Mysql
Powerdns With Mysql

Update Repository
apt-get update

Install Mysql
apt-get install mysql-server mysql-client

pastekan baris code dibawah ini :
CREATE DATABASE powerdns;
GRANT ALL ON powerdns.* TO 'power_admin'@'localhost' IDENTIFIED BY '!tuS@ja';
GRANT ALL ON powerdns.* TO 'power_admin'@'localhost.localdomain' IDENTIFIED BY '!tuS@ja';
FLUSH PRIVILEGES;
USE powerdns;
CREATE TABLE domains (
id INT auto_increment,
name VARCHAR(255) NOT NULL,
master VARCHAR(128) DEFAULT NULL,
last_check INT DEFAULT NULL,
type VARCHAR(6) NOT NULL,
notified_serial INT DEFAULT NULL,
account VARCHAR(40) DEFAULT NULL,
primary key (id)
);
CREATE UNIQUE INDEX name_index ON domains(name);
CREATE TABLE records (
id INT auto_increment,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(6) DEFAULT NULL,
content VARCHAR(255) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
primary key(id)
);
CREATE INDEX rec_name_index ON records(name);
CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);
CREATE TABLE supermasters (
ip VARCHAR(25) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) DEFAULT NULL
);
quit;

Install Unbound sebagai recursornya
apt-get install unbound
cd /etc/unbound/
wget ftp://ftp.internic.net/domain/named.cache
killall unbound
nano /etc/unbound/unbound.conf

edit config unbound dan sesuaikan agar sesuai dengan kebutuhan. jangan lupa portnya selain 53 dan ipnya ke localhost
#### START UNBOUND CONFIG
server:
verbosity: 1
statistics-interval: 120
num-threads: 4
statistics-cumulative: yes
interface: 127.0.0.1@12345
port: 12345

outgoing-range: 512
num-queries-per-thread: 1024

msg-cache-size: 128m
rrset-cache-size: 256m
so-rcvbuf: 8m

msg-cache-slabs: 8
rrset-cache-slabs: 8
infra-cache-slabs: 8
key-cache-slabs: 8

cache-min-ttl: 600
cache-max-ttl: 86400
infra-host-ttl: 60
infra-lame-ttl: 120

infra-cache-numhosts: 10000
infra-cache-lame-size: 10k

do-ip4: yes
do-ip6: no
do-udp: yes
do-tcp: yes
do-daemonize: yes

access-control: 0.0.0.0/0 allow

chroot: "/etc/unbound"
username: "unbound"
directory: "/etc/unbound"
logfile: ""
use-syslog: no
pidfile: "/etc/unbound/unbound.pid"
root-hints: "/etc/unbound/named.cache"

identity: "DNS"
version: "1.4"
hide-identity: yes
hide-version: yes
harden-glue: yes
use-caps-for-id: yes
harden-dnssec-stripped: yes
do-not-query-address: 127.0.0.1/8
do-not-query-localhost: yes
module-config: "iterator"

#zone localhost
local-zone: "localhost." static
local-data: "localhost. 10800 IN NS localhost."
local-data: "localhost. 10800 IN SOA localhost. nobody.invalid. 1 3600 1200 604800 10800"
local-data: "localhost. 10800 IN A 127.0.0.1"

local-zone: "127.in-addr.arpa." static
local-data: "127.in-addr.arpa. 10800 IN NS localhost."
local-data: "127.in-addr.arpa. 10800 IN SOA localhost. nobody.invalid. 2 3600 1200 604800 10800"
local-data: "1.0.0.127.in-addr.arpa. 10800 IN PTR localhost."

forward-zone:
name: "."
forward-addr: 8.8.8.8
forward-addr: 8.8.4.4

remote-control:
control-enable: yes
control-interface: 127.0.0.1
control-port: 953
server-key-file: "/etc/unbound/unbound_server.key"
server-cert-file: "/etc/unbound/unbound_server.pem"
control-key-file: "/etc/unbound/unbound_control.key"
control-cert-file: "/etc/unbound/unbound_control.pem"
##### END CONFIG

restart powerdns
/etc/init.d/pdns restart

check service powerdns apakah sudah berjalan
ps ax | grep pdns

Test apakah resolve
dig @192.168.0.10 detik.com

Install apache dan php module
apt-get install apache2 libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php-pear php5-imap php5-mcrypt php5-ming php5-mysql php5-xmlrpc gettext php-db php-mdb2 php-mdb2-driver-mysql
a2enmod rewrite
service apache2 restart

Install phpmyadmin
apt-get install phpmyadmin

download poweradmin untuk menambah atau membuang record dns yang akan di block
wget https://github.com/downloads/poweradmin/poweradmin/poweradmin-2.1.6.tgz
tar xzvf poweradmin-2.1.6.tgz
mv poweradmin-2.1.6 /var/www/poweradmin
touch /var/www/poweradmin/inc/config.inc.php
chown -R www-data:www-data /var/www

Lanjutkan setting poweradmin dengan merujuk ke http://192.168.0.10/poweradmin/install/index.php

isi databasenya dengan merujuk file dari https://docs.google.com/file/d/0BxUNcvINx070eHNMUkROQUFEX1U/edit?pli=1 download lalu masukkan ke mesin linux selanjutnya jalankan perintah dibawah ini
awk '{print "NULL" "\t" $1 "\t" NULL "\t" "NULL" "\t" "NATIVE" "\t" "NULL" "\t" "NULL" }' domain.txt > domains
mysql -u power_admin -p'!tuS@ja' -Dpowerdns -e "LOAD DATA INFILE 'domains' INTO TABLE domains"
mysql -u power_admin -p'!tuS@ja' -Dpowerdns -e "select id,name from domains" > forrecord
awk '{print "NULL" "\t" $1 "\t" $2 "\t" "A" "\t" "1.1.1.1" "\t" "86400" "\t" "0" "\t" "1392620361" "\n" "NULL" "\t" $1 "\t" "*."$2 "\t" "A" "\t" "1.1.1.1" "\t" "86400" "\t" "0" "\t" "1392620361" }' forrecord > records
awk '{print "NULL" "\t" $1 "\t" "1" "\t" "0" "\t" "2" }' forrecord > zones
cp records /var/lib/mysql/powerdns/
cp zones /var/lib/mysql/powerdns/
chmod 666 /var/lib/mysql/powerdns/records
chmod 666 /var/lib/mysql/powerdns/zones
mysql -upower_admin -p'!tuS@ja' -Dpowerdns -e "LOAD DATA INFILE 'records' INTO TABLE records"
mysql -upower_admin -p'!tuS@ja' -Dpowerdns -e "LOAD DATA INFILE 'zones' INTO TABLE zones"

Selesai sudah, filtering domain untuk porno, malware, spyware dan judi telah selesai, semoga bermanfaat bagi rekan rekan sekalian.

Sumber : http://jaringanku.net/2014/03/16/filter-negative-site-by-dns/

Open Filer enabling iScsi Initiator

OpenFiler is a free SAN/NAS filer. Although iSCSI target is well define within its web interface, the initiator must be invoked using CLI interface (ssh/command line access/other). Open filer uses open-iscsi implementation of iscsi initiator, which main interface is iscsiadm.

1. Enable both startup and service of iSCSI initiator in web interface
2. using SSH use the following commands:
3. Identify published LUNs via:
#iscsiadm -m discovery -t st -p <iscsi target ip>
response:  <ip>:3260,1 <iqn>
e.g. 127.0.0.1:3260,1 iqn.2006-01.com.openfiler:tsn.5d3194b5b7a5
(deleting discovery with: #iscsiadm -m discovery -p localhost --op=delete)

4. Add LUNs
#iscsiadm -m node -T <iqn> -p <target ip address> --op update -n node.startup -v automatic

5. Now you should be able to see all volumes in Block devices.

6. Notice that: if you are working with one or more iSCSI initator volumes you must update the open-iscsi module (I was using OF2.99):
#conary update gcc
#conary update patch
#conary update glib:devel
#conary update glibc:devel
#conary update openssl:devellib
#wget http://www.open-iscsi.org/bits/open-iscsi-2.0-872.tar.gz
#tar -xzvf  open-iscsi-2.0-872.tar.gz
#cd open-iscsi-2.0-872
#make
#/etc/init.d/open-iscsi stop
#make install
#/etc/init.d/open-iscsi start
#iscsiadm -V
Response: iscsiadm version 2.0-872
#reboot

More references:
Setting Up An iSCSI Environment On Linux
iscsiadm(8) - Linux man page
Open-ISCSI-865: Error iscsiadm: Could not get host for sid