Compiling software from source on a VPS gives you control over build options, optimizations, and versions that pre-built packages may not offer. This guide walks you through the standard ./configure && make && make install workflow, covering prerequisites, step-by-step instructions, common pitfalls, and troubleshooting.
What You’ll Need
- A VPS with a Linux distribution (Ubuntu, Debian, CentOS, etc.) and sudo or root access.
- Basic command-line comfort: navigating directories, editing files, and running commands.
- Build tools:
build-essentialon Debian/Ubuntu, orgcc,make, andbinutilson RHEL/CentOS. Alsopkg-configand oftenwgetorcurl. - Internet access to download source tarballs.
Step-by-Step
- Install build dependencies. On Debian/Ubuntu:
sudo apt update && sudo apt install build-essential pkg-config wget. On RHEL/CentOS:sudo yum groupinstall "Development Tools"andsudo yum install pkgconfig wget. Some packages need extra libraries; check the project’s README or INSTALL file. - Download the source code. Get the tarball from the official site or GitHub. For example:
wget https://example.com/package-1.2.3.tar.gz. Always verify checksums if provided. - Extract the archive.
tar -xzf package-1.2.3.tar.gzthencd package-1.2.3. - Read the documentation. Open
README,INSTALL, orconfigure --helpto see available options and requirements. - Run ./configure. This checks your system for required libraries and generates a Makefile. Customize with flags:
./configure --prefix=/usr/local --with-option. The--prefixsets installation directory; default is often/usr/local. - Compile with make. Run
make(ormake -j$(nproc)to use all CPU cores for faster builds). This compiles the source into binaries. It may take minutes to hours. - Run tests (optional but recommended).
make checkormake testruns the project’s test suite. Fix any failures before installing. - Install with make install.
sudo make install. This copies files to the prefix directory. If you used a prefix under your home, you may not need sudo. - Update library cache (if needed). If you installed shared libraries to a non-standard path (e.g.,
/usr/local/lib), runsudo ldconfigto refresh the linker cache. - Verify the installation. Run
which packageorpackage --versionto confirm it works. If the binary is not in PATH, add the prefix’sbindirectory to your PATH.
Common Mistakes
- Missing dependencies: Configure fails with “No package ‘foo’ found”. Install the
-devor-develpackage. - Using sudo with wrong prefix: If you configure with
--prefix=/usrand then runmake installas root, you may overwrite system files. Use a separate prefix like/usr/localor/opt. - Not cleaning after a failed build: After fixing errors, run
make cleanbefore recompiling to avoid stale objects. - Ignoring configure warnings: Some warnings indicate missing features that will be silently disabled. Read them.
- Forgetting to run ldconfig: If the program fails to start with “cannot open shared object file”, libraries are not found.
Tips
- Use
make -j$(nproc)to speed up compilation on multi-core VPS. - Prefer
checkinstall(Debian/Ubuntu) to create a .deb package instead ofmake install, making uninstallation cleaner. - Keep the source directory after install if you plan to uninstall or modify;
make uninstallworks only if the Makefile supports it. - Consider using
stowor manually installing to/optto keep the system clean. - Always read the project’s INSTALL file—some packages have specific steps.
Troubleshooting
- Configure fails with “C compiler cannot create executables”: Install gcc and make, or check if you have enough disk space and memory.
- Make fails with “undefined reference to…”: Usually a missing library. Look at the error message for the library name, then install its dev package. For example,
libssl-devfor OpenSSL. - Make fails with “No rule to make target …”: You may be in the wrong directory, or the source is incomplete. Re-extract the tarball.
- Install fails with “Permission denied”: You need sudo, or the prefix directory is not writable. Adjust permissions or use a different prefix.
- Program not found after install: The binary is not in PATH. Add
export PATH=/usr/local/bin:$PATHto your shell profile, or reinstall with a prefix that is already in PATH. - Program runs but says “version GLIBC_2.xx not found”: The binary was compiled on a newer glibc than the system has. Recompile on the VPS itself, or use an older version.
Frequently Asked Questions
What is the difference between make and make install?
make compiles the source into binaries in the source directory. make install copies those binaries and other files to the system directories (like /usr/local/bin).
How do I uninstall a program installed from source?
If the source directory still exists, run sudo make uninstall. If not, you may have to manually delete files listed in make install output. Using checkinstall or a package manager can simplify removal.
Can I install to my home directory without root?
Yes. Use ./configure --prefix=$HOME/.local then make install. Ensure $HOME/.local/bin is in your PATH.
Why do I get “configure: error: C compiler cannot create executables”?
This usually means gcc is not installed or is misconfigured. Install build-essential on Debian/Ubuntu or gcc and make on RHEL/CentOS.
Is it safe to compile as root?
Compiling as root is not recommended because a bug in the build script could harm the system. Use a normal user and only use sudo for make install.
How do I speed up compilation?
Use make -j$(nproc) to compile with all CPU cores. Also, close other heavy processes on the VPS.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Why Your Blog Isn’t Getting Traffic: 12 Real Reasons
- ESP32-P4 Without Wi-Fi: What It Can and Can’t Do
- Spring Boot MVP 15 Checks for Reliable First Release
- Best Thunderbolt 3 Mac Uses: Top Picks & Guide
- Tailscale Alternatives: 4 Remote Access Options
- Recover Deleted Internet History on Mac