Installing software on server machine - the install process wants to modify root folders which I cannot access - linux

I'm configuring software on my first web server, so I am not totally familiar with how everything works, but here is the basic problem:
I have purchased hosting on a web server that runs on CentOS. I have been able to install postgreSQL via an install process that the hoster provides, so that my database will be local only to my home folder. That is working fine.
However, I am trying to install a postgreSQL extension called PostGIS. I have tried to compile it from source on my web server, but it now requires an additional library called GEOS. I downloaded the library from http://download/osgeo.org/geos/geos-3.6.2.tar.bz2, extracted it, and used make install to run it.
Now the problem is that it fails due to this error:
/bin/mkdir: cannot create directory /usr/local/include/geos: Permission Denied
It's not really a surprise, because it is trying to make a new directory in the system root folders, rather than within my personal home folder, which is the only one I have access to. I can't think of any other way around this. Am I just unable to install this library? Or can I "trick" it somehow into installing in in my home directory, where I have full admin rights?

I think You need to execute a command with root user privileges.
Because, make install command need root user privileges.
Like,
sudo make install
or with root user. Like,
sudo su
make install

Related

What is the proper way of using npm in root environment?

I'm currently setting up a Parse Server with AWS EC2 instance, where I've been using Nginx and Elastic IP to manage SSL certificates.
Through different guides I've reached the solution of put the node app at /var/www/parse-server, but they say I should do 'npm init' in this directory, which is obviously owned by root (and fails because of permissions, of course).
My question is about the proper way of manipulate the app files in this root path, specially because 'sudo npm init' has conflicts with packages when the project keep moving on.
Should I use 'sudo su' and proceed with the install? I tried to do that, but npm init isn't recognized as a command. I haven't tried with --prefix yet, because I wanted to make sure before do that.
Should I use another directory to keep my application working? I've though that, but what about Nginx and all the related config?
Should I chown -R the folder to gain ownership of the /var/www/parse-server folder? If I do that, what about permissions later on?
I found two workarounds for this:
chown -R to change the directory owner to my own user. This works but i think is not the proper way.
Proxy reverse to the specific folder (i'm using nginx, so whoever is watching this thread should be fine with nginx docs)
Thanks to Davi Macedo for solution 1.

Error when running emacs make install on remote machine

I am trying to install emacs on a machine that I'm accessing through ssh.
I downloaded the emacs-24.5.tar.gz which I transferred to the root directory of my remote machine.
I ran the ./configure command and then navigated to the emacs-24.5 folder and ran the make install command
I unfortunately ran into this error
/bin/mkdir: cannot create directory `/usr/local/share/icons': Permission denied
/usr/bin/install: cannot create regular file `/usr/local/share/icons/hicolor/128x128/apps/emacs.png': No such file or directory
make: *** [install-etc] Error 1
How do I get emacs working on the remote machine now?
Your description of what steps you took make it a little difficult to know if you missed anything. For example, I'm assuming you ran tar on the tarball before you ran configure or make? Also, little concerned when you say you ran configure and THEN navigated to the 24.5 directory? You should be running make install from the same directory/folder where you ran configure. You also didn't indicate you had run make bootstrap.
The steps should be
scp emacs-24.5.tar.gz user#remote-host:~
ssh user#remote-host
tar xzf emacs-24.5.tar.gz
cd emacs-24.5
./configure
make bootstrap
sudo make install
Notice in the output from the make install there are directions on an additional command you need to run to set movemail permissions. This command also needs to be run under sudo
I'm assuming your not ssh'ing intot the remote host as root as this would be a bad practice. This means that when you do the make install, you need to run the process with root privileges, so you need to use sudo.
You should also check the output from configure and make sure there are no errors. Configure will also list emacs features which are turned on/off depending on whether you have various supporting libraries installed. If you scroll the terminal output from configure up a couple of pages, you will see the printout. If there are features listed with a 'no' which you want/expect, you will need to go through the documentation and work out which additional supporting libraries you need. However, most of the time, with modern linux distros setup for desktop use, everything will likely already be there. Might be different on a server and I can't speak about Windows and what it might require.

Best Approach to installing Node.js/npm without sudo

I've been looking around for the best/most appropriate way to install node.js/npm in such a way that using commands like npm install -g bower does not require sudo, as using sudo for such a command can cause issues later on. Initially I followed this answer: Installing with nvm but this installs it into the users home directory which I read may not be a good a idea in production to have node installed in your home directory so I followed an expansion on above tutorial with this: Installing with NVM (digital ocean) however this left me still requiring sudo.
On a side note - on my macbook I installed node with homebrew, is this a good idea or is there a more standard approach.
Thanks for all your help, feel free to ask for clarifications.
I forgot to say, the machine I am planning on installing this on is running XUbuntu 14.04. (also I have my macbook running mavericks - but this is just an addition)
Sudo gives you permissions to change/add/remove files not owned by your user. Those files are as a rule everything except /home/YOU (in MacOS: /Users/YOU)
Your desire is to have Node installed as appropriate (system wide, rather than your home directory), that is good. And as you guessed you need sudo to initially install it on a system path.
But then you wish to have modules installed without sudo, meaning you want modules to be located in a directory, where your user has write access to. That would be available by default if Node was installed in your home.
To enforce your wish on a system path, you will need to give write permission to the folder where modules are located, that is change write permissions or ownership of:
/usr/local/share/npm/lib/node_modules, so that modules can be saved on your disk.
/usr/local/share/npm/bin, to allow modules executables be reachable.
You might have to alter few other folders as well.
That answers your question, but I strongly recommend you not doing so. Instead I suggest you stick to default methodologies. Everyone here without doubt will say it is absolutely safe approach to use sudo when you are installing modules globally, it is even safer to not have write permissions to global infrastructure of your install without super privileges.

XAMPP or any other service tool in /opt? Security

I am developing with Xampp for Linux and Tomcat (similar to Xampp on Windows). Many programs like /IDEA, Tomcat and Xampp are recommended to be installed under /opt Now I have heard that it is not recommended to run services as root, but on Ubuntu (I am using this) unpacking any directory to /opt implies that it belongs to root owner and root group. This may be specific to Xampp as per the instructions on their Linux page:
Step 2: Installation After downloading simply type in the following commands:
Go to a Linux shell and login as the system administrator root:
su
Extract the downloaded archive file to /opt:
tar xvfz xampp-linux-1.8.1.tar.gz -C /opt
Warning: Please use only this command to install XAMPP. DON'T use any Microsoft Windows tools to extract the archive, it won't work.
Warning 2: already installed XAMPP versions get overwritten by this command.
That's all. XAMPP is now installed below the /opt/lampp directory.
* Step 3: Start To start XAMPP simply call this command:
/opt/lampp/lampp start
Placing it here implies that Apache must be run as root as one is only able to run it with sudo on Ubuntu.
This may be an issue specific to Ubuntu. Is it? Because Xampp is a development tool I posted this here as I am more likely to find an appropriate answer here from developers who use it on Ubuntu (and other Linux systems). I would appreciate any information on if the same problem occurs on other systems, I notice my production environment has Tomcat installed in /opt too, but belongs to tomcat: tomcat
The question here is how to get around this for all tools under /opt, because even though Xampp may not be the tool for my needs, I still want to place Tomcat under /opt to replicate my production environment and the same thing will surely happen unless this is just a Ubuntu issue?
Ubuntu and some other distributions differ to the general Linux principle where the account that you create upon install of the OS is added to specific groups that can be viewed with the following command:
groups username
You will notice that root is not amongst these. It is also not possible to log in or su to the root account. sudo is most likey a command that has been granted permission to be used from other accounts so I imagine the 'sudo' command has a file permission of 775 for user: root:root
Thus launching services from /opt' does not run them asroot`

Can't run demos of Qt

I just installed Qt. I tried to run some demos but I cannot run any, this is the message:
Cannot create file /opt/QtSDK/Demos/4.7/chip/chip.pro.user: Permission
denied
To avoid this in the future, how can I set permissions to any program I install?
I'm new to using linux, I'm using Ubuntu 12.04.
Either don't install the SDK in a root-access directory, or run the program (qtcreator, etc...)with root privileges. I would choose the former solution. I generally use a folder in my home directory.
Qt SDK is standalone, so you can copy or move the whole folder to a new location which doesn't requires root privileges.

Resources