- Joined
- Aug 5, 2016
- Messages
- 241
- Points
- 18
You can find many different tutorials online on how to compile a LAMP stack, but most of them lack content, and usually only give a few commands such as installing apache and php, etc. This tutorial covers everything you can/should do from the initial login to your VPS/Dedicated Server to the point you can start developing a website / move your current website.
NOTE: This tutorial is intended for quick deployment and does NOT include extra apache security and only basic server hardening.
/*
* Initial Server Setup
*/
/*
* Install CSF (3rd Party Firewall that is commonly used in web-hosting and is very customizable)
*/
// Configure CSF
// Save and close the file, then reboot the firewall
/*
* Change OpenSSH Default Port (Keep the hackers from ever connecting to your terminal)
*/
// Find the line that reads #Port 22
// Remove the hash (comment symbol) and change the 22 to a port you want
// Remember to open the new port in the CSF firewall "TCP_INCOMING"
// Save and close the file
/*
* Install Apache
*/
/*
* Configure Apache Virtual Host (Tell the web server where the web directory is for your domain)
*/
// Replace example.com with your website's domain or any username you want
// Add the following line to the bottom of the file
// Save and close the file
// Add the following to the configuration file and replace example.com with your servers domain name and/or username
// Save and close the configuration file
/*
* Install CertBot (Uses lets-encrypt to create verified ssl certificates)
*/
// Follow the onscreen instructions to install an SSL Cert
/*
* Install PHP 5.6 (Stable, supported PHP release)
*/
/*
*Install MySQL (MariaDB is the CentOS 7 community version of MySQL)
*/
// Follow the on-screen instructions
/*
*Install phpMyAdmin (Manage your database with an easy to use GUI)
*/
// Change the 4 instances of 127.0.0.1 to your external IP address
// Alias /phpMyAdmin /usr/share/phpMyAdmin
// Alias /phpmyadmin /usr/share/phpMyAdmin
// Comment out the 2 aliases and create a new one in a unique and secure location
NOTE: This tutorial is intended for quick deployment and does NOT include extra apache security and only basic server hardening.
/*
* Initial Server Setup
*/
Code:
# yum clean all
# yum -y update
# hostname localhost
# systemctl stop firewalld
# systemctl disable firewalld
* Install CSF (3rd Party Firewall that is commonly used in web-hosting and is very customizable)
*/
Code:
# cd /usr/src
# rm -fv csf.tgz
# wget https://download.configserver.com/csf.tgz
# tar -xzf csf.tgz
# cd csf
# sh install.sh
Code:
# nano /etc/csf/csf.conf
Code:
# csf -r
* Change OpenSSH Default Port (Keep the hackers from ever connecting to your terminal)
*/
Code:
# cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
# nano /etc/ssh/sshd_config
// Remove the hash (comment symbol) and change the 22 to a port you want
// Remember to open the new port in the CSF firewall "TCP_INCOMING"
// Save and close the file
Code:
# systemctl restart sshd.service
* Install Apache
*/
Code:
# yum -y install httpd
* Configure Apache Virtual Host (Tell the web server where the web directory is for your domain)
*/
// Replace example.com with your website's domain or any username you want
Code:
# mkdir -p /var/www/example.com/public_html
# chown -R $USER:$USER /var/www/example.com/public_html
# chmod -R 755 /var/www
# mkdir /etc/httpd/sites-available
# mkdir /etc/httpd/sites-enabled
# nano /etc/httpd/conf/httpd.conf
Code:
# IncludeOptional sites-enabled/*.conf
Code:
# nano /etc/httpd/sites-available/example.com.conf
Code:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog /var/www/example.com/error.log
CustomLog /var/www/example.com/requests.log combined
</VirtualHost>
Code:
# ln -s /etc/httpd/sites-available/example.com.conf /etc/httpd/sites-enabled/example.com.conf
# apachectl restart
* Install CertBot (Uses lets-encrypt to create verified ssl certificates)
*/
Code:
# yum install epel-release
# yum install certbot
# yum install python-certbot-apache
# certbot --apache
Code:
# certbot renew --dry-run
# certbot renew --quiet
* Install PHP 5.6 (Stable, supported PHP release)
*/
Code:
# yum -y update
# yum -y install epel-release
# wget https://dl.fedoraproject.org/pub/epe...t-7.noarch.rpm
# wget https://centos7.iuscommunity.org/ius-release.rpm
# rpm -Uvh ius-release*.rpm
# yum -y update
# yum -y install php56u php56u-opcache php56u-xml php56u-mcrypt php56u-gd php56u-devel php56u-mysql php56u-intl php56u-mbstring php56u-bcmath
*Install MySQL (MariaDB is the CentOS 7 community version of MySQL)
*/
Code:
# yum -y install mariadb-server mariadb
# systemctl start mariadb
# mysql_secure_installation
/*
*Install phpMyAdmin (Manage your database with an easy to use GUI)
*/
Code:
# yum -y install phpmyadmin
# nano /etc/httpd/conf.d/phpMyAdmin.conf
// Alias /phpMyAdmin /usr/share/phpMyAdmin
// Alias /phpmyadmin /usr/share/phpMyAdmin
// Comment out the 2 aliases and create a new one in a unique and secure location
Code:
# systemctl restart httpd.service
Last edited: