LAMP(Linux, Apache, MySQL, PHP) is the most popular setup for web servers on the internet, powering most of the web including the biggest websites out there such as Google.
The operating system comes in many flavours, most being 100% free, as are the primary pieces of software used. These are the Apache web server, MySQL database server and the PHP programming language and platform. Other popular pieces of software are Postgres, Tomcat (Java server), Postfix email server, and literally thousands of other amazing programs.
Setting up a new server if you are new to linux can be a daunting task, so this server guide should shed some help make it easier. We'll focus on a version of linux called CentOS, which the most popular one used for hosting, but this guide will work for most versions of linux.
We're not going to go through how to install the OS, since most web hosting providers will do that for you, instead we'll focus on using the system. Below are the most commonly used commands that you'll use once the system is installed, to set up new websites.
System Users (ssh & ftp)
sudo adduser myusername
ASSIGN USER PASSWORD
sudo passwd myusername
LIST ALL USERS
HOSTING / APACHE
CREATE WEBSITE FOLDERS
mkdir -p /var/www/domain.com/httpdocs
mkdir -p /var/www/domain.com/logs
GRANT OWNERSHIP TO USER
chown -R username:username /var/www/domain.com/httpdocs
LOGIN TO MYSQL
mysql -u root -p
CREATE NEW DATBASE
CREATE DATABASE db_name;
CREATE NEW USER
CREATE USER db_user@localhost;
SET PASSWORD FOR DATABASE
SET PASSWORD FOR db_user@localhost= PASSWORD("password");
GRANT ALL PRIVILEGES ON db_name.* TO db_user@localhost IDENTIFIED BY 'password';
LIST ALL DATABSES ON SERVER
SHOW ALL USERS ON SERVER
SELECT User FROM mysql.user;