Update/install fail: Server cannot access software repositories

If you are trying to install something and the server waits forever after you answer yes to the update and it accesses the software repository… something like…

apt-get update
...
details of packages
...
Need to get 83.7 MB of archives.
After this operation, 237 kB disk space will be freed.
Do you want to continue [Y/n]?
0% [Connecting to archive.ubuntu.com]

And then nothing. It fails.

Do you have UFW installed? UFW can block outgoing connections from your server, so it becomes unable to access the software repositories. Rather than make exceptions, it is easier to disable the firewall and enable again when update or install is done.
??
If you have UFW (Uncomplicated Firewall) installed, disable it and try again.

ufw disable

Now your upgrades should work. Once you are done, re-enable your firewall.

ufw enable
Enhanced by Zemanta
Posted in Snippets, Troubleshooting, Ubuntu Server Configuration | Tagged , , , , , | Leave a comment

bash: add-apt-repository: command not found

If you are trying to add a repository and get the following error

bash: add-apt-repository: command not found

You need to install python-software-properties, like so

apt-get install python-software-properties

If you have python-software-properties installed and are still getting this error, there is some problem with the package. Uninstall and reinstall it.

apt-get remove python-software-properties --purge && apt-get install python-software-properties

or

apt-get install --reinstall python-software-properties && sudo dpkg-reconfigure python-software-properties
Enhanced by Zemanta
Posted in Snippets, Ubuntu Server Configuration | Tagged , | Leave a comment

Installing UFW – Uncomplicated Firewall on Ubuntu 12.04

If you are one of those nerdy types and use iptables, ignore this. If you are like the rest of us Ubuntu users (nerdy in denial), UFW (Uncomplicated Firewall) provides a handy tool to configure your firewall.

Here’s how to install. As root, type:

apt-get install ufw

If this can’t find the package, run

apt-get update

before running the command again. You’ll get it.

Next, add your exceptions. For example, on my server, I allow ssh (Secure Shell) and http (Hypertext Transfer Protocol).

# ufw allow ssh
# ufw allow http

Then start the firewall

# ufw enable

It will ask

Command may disrupt existing ssh connections. Proceed with operation (y|n)?

Reply “y”. Simply hitting enter will abort.

This should return:

Firewall is active and enabled on system startup

If you get an error like

ERROR: problem running ufw-init

Edit the file /etc/default/ufw and change IPv6=yes to IPv6=no

Enhanced by Zemanta
Posted in Security, Ubuntu Server Configuration | Tagged , , , , , , , , | Leave a comment

How to create an admin area on fake domain

Often, you need to have areas of your site that you access through a browser, that you don’t want anyone else to access. These can be control panels or scripts with phpinfo or your apc cache monitoring script.

what I do is create a fake domain for these and give them their own site. For example a virtual host for domain “admin.area” which of course is not a real domain name or registered anywhere. Remove the index file, forbid browsing folders and place your scripts there.

Plug in your server IP address with the fake domain you created (admin.area) into the hosts file of any computer that needs access.

If you are using varnish, you can also redirect any queries to this domain to your main website for safety and access through the backend port.

You can easily disable the virtual domain altogether when done without interfering with your production sites in any way and risking accidental permission changes or other problems.

Posted in Uncategorized | Leave a comment

Phpize: Command not found?

So you are on Debian, trying perhaps to install an opcode cache or something and you use try to do it with pecl with


pecl install apc

for example.

And you can’t, because phpize is not installed. Then you try to compile it and run into the same problem.

Then you try to find out how to get it, only to need a package “php5-devel” that doesn’t seem to exist in any repository.

Fikar not. What you want is “php5-dev” – strange that this seems to not be mentioned in most instructions.

So you go.


apt-get install php5-dev

then you have phpize for whatever you were trying to do.

:)

Posted in Troubleshooting | Leave a comment

How to forward only .onion or .i2p urls selectively

If you are like me and don’t need to use TOR so much for anonymity as for accessing interesting hidden sites, the overall slow speed of TOR probably bothers you for normal browsing. The need to toggle proxies or start two separate browsers probably bugs you too.

Now I have found .i2p which is similar to TOR in the sense of being an anonymous, decentralized network, but it is not a proxy at all – which means configuring the browser to forward queries via the i2p network means that regular sites won’t work at all!

I need:

  • Normal browsing directly over the internet for regular urls
  • Routing .onion urls to TOR
  • Routing .i2p urls to I2P

I dare say this fix will also work for any other such networks I may not know of.

Before we begin, an extremely important WARNING:

If you use TOR for Anonymity, then this “how to” may compromise your anonymity for the same reasons the TORbutton was discontinued. Mixing normal browsing with TOR may result in leaks of identity or inadvertent access of normal urls which you intend to use over TOR directly – which could be disastrous, particularly if your safety depends on it. YOU ARE WARNED. This “How To” ASSUMES THAT YOU DO NOT HAVE ANONYMITY AS A PRIORITY.

There are many people who would simply like to see various sites, or have TOR sites they interact with regularly – like TORMail users, for example. Or people who have set up their own sites or are reading forums or otherwise engaged in activity that they don’t think will be legally problematic.

This guide is for them. And I hope their tribe increases.

Here’s how to see normal urls directly on the internet, while using TOR and I2P for .onion and .i2p sites respectively.

Step 1: Install Privoxy. Privoxy is a transparent proxy that does a lot of other useful things too. Visit their website, read up, and if you like (and want to continue this how to) install privoxy as per instructions for your OS. This assumes that you already have I2P and/or TOR installed – or you can go now and do it, or waste your time reading this post. I use TOR installed from the PPA and not the browser bundle – so that it can run in the background and be used as needed – or stopped independently of the browser if I’m not using TOR. This is important, as I browse all day, and having the browser shut down if I’m not using TOR would be most inconvenient. Wasting bandwidth on TOR unnecessarily is not required either.

Step 2: Configure your browser to use Privoxy – as per instructions given on their site. Basically, this means setting your network proxy to 127.0.0.1:8118 <– this is the port for Privoxy. Note DO NOT add the socks proxy for TOR here. Or the i2p settings.

Step 3: Edit your Privoxy configuration file. On Ubuntu, installing from the PPA it is found at /etc/privoxy/config – your mileage may vary depending on OS and how you installed privoxy, however, it will be found in the root of the folder for privoxy – as a rough guide.

Step 4: At the end of that file, add:

forward-socks5   .onion               127.0.0.1:9050 .
forward   .i2p               127.0.0.1:4444 .

Done.

That is it.

Now, your normal browsing will be unaffected by either TOR or I2P Network, while .onion and .i2p urls will get forwarded correctly and accessible seamlessly.

Enjoy!

NOTE: While this does nothing special to compromise your safety, it may be compromising some protective feature in case someone is trying to find out your identity or something. I have no clue what it does on the safety front, and I highly recommending assuming that this is unsafe till some superior being can verify or suggest better methods.

If, while using this method, you find that you need to use anonymous features of TOR, I highly recommend starting a “TOR Browser Bundle” browser separately. This can be configured to use different ports so as to not interfere with your already installed TOR.

NOTE1: I know I am being repetitive, but I feel I must, seeing as how a lot of people use TOR for activism or other things where getting identity compromised could land them in a lot of trouble.

Posted in Uncategorized | 1 Comment

Install APC and fix “potential cache slam” problem

APC is an Alternative PHP Cache or Opcode cache that speeds up performance dramatically by caching queries.

How to install APC?

apt-get install php5-apc

You will have to enble it in the php configuration. Add the following to your php.ini file

extension=apc.so

Alternatively, you could create a separate apc.ini file and put it in the conf.d directory.

If your error log shows a lot of messages about potential cache slam averted, it is a bug. Not much you can do about it but you can turn slam defense off so that it doesn’t spam your logs (or cause other fails)

Add after that line in your php.ini or apc.ini

apc.write_lock = 1
apc.slam_defense = 0
Posted in Uncategorized | Leave a comment

How to install APC and fix “potential cache slam” problem

APC is an Alternative PHP Cache or Opcode cache that speeds up performance dramatically by caching queries.

How to install APC?

apt-get install php5-apc

or

pecl install apc

You will have to enble it in the php configuration. Add the following to your php.ini file

extension=apc.so

Alternatively, you could create a separate apc.ini file and put it in the conf.d directory.

If your error log shows a lot of messages about potential cache slam averted, it is a bug. Not much you can do about it but you can turn slam defense off so that it doesn’t spam your logs (or cause other fails)

Add after that line in your php.ini or apc.ini

apc.write_lock = 1
apc.slam_defense = 0

Then copy the apc.php file into a folder that is served by your webserver. Accessing this script in a browser gives you information on the state of your cache. However this script also allows viewing of the files cached and may be a security concern, so it is best kept in a folder with restricted access.

Posted in Caching, Ubuntu Server Configuration | Leave a comment