Centos linux web server

Install Apache

What is Apache? Apache serves your content to the world. And also it can give you a hand to create dynamic website with PHP which WordPress is also a PHP thing. To install Apache 1- sudo yum install httpd mod_ssl 2- sudo /usr/sbin/apachectl start If message appears: Starting httpd: httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName , edit the configuration file using vim or any editor you wish (Step 3). 3- sudo vim /etc/httpd/conf/httpd.conf and bring the following line out of comment: 4- #ServerName www.example.com:80 => ServerName MyServerName (which MyServerName is your own server name!) Allow Apache in firewall. As you know, Apache listens on port HTTP 80 by default. 5.1- sudo iptables -I INPUT -p tcp —dport 80 -j ACCEPT 5.2- sudo service iptables save Restart Apache: 6- sudo /usr/sbin/apachectl restart Test your installation: 7- curl 127.0.0.1 As you know, it’s very critical to allow Apache to access your codes! 8- sudo chcon -t httpd_sys_rw_content_t /var/www/html/mysite -R

Learn more about FirewallD

Install PHP

Install and enable EPEL repository: 1- sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm Install and enable Remi repository 2- sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm Install yum-config-manager 3- yum install yum-utils Install PHP modules which programmers use to reduce their headache 4- yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo Test the PHP’s command line interface (CLI) 5- php -v

Читайте также:  How to run python scripts in linux

Wanna create a secondary sysadmin user? (Sudoer guy)

Create a user 1- ‍‍‍ a‍dduser theusername (you say theusername) Choose a password 2- passwd theusername (you said theusername) Just like school, anyone is in a group. So you have to add new user to wheel , which is a super user level group: 3- usermod -aG wheel theusername Switch user 4- su — username

Disable a user login (EMail or FTP accounts maybe)

Learn more about configuring FTP server:

Hey server! KEEP EVERYTHING IN MIND; even «Clean your mind»

export HISTCONTROL=ignoredups:erasedups shopt -s histappend export PROMPT_COMMAND="$history -a; history -c; history -r" export HISTTIMEFORMAT='%F %T ' 

How to install MySQL

Install wget which is more handy tool than curl for heavy downloads. 1- yum install wget Download the package: 2- wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm Add the package: 3- sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm Update package manager: 4- yum update Install the package: 5- sudo yum install mysql-server Start daemon: 6- sudo systemctl start mysqld Configure installation: 7- sudo mysql_secure_installation Test installation: 8- mysql -u root -p (which root is the root username) Create a MySQL user: 9- mysql> create user ‘testuser’@’localhost’ identified by ‘mysecretpass’; (username is testuser and the password is mysecretpass) Grant permissions to user: 10- mysql> grant all on databasename.* to ‘testuser’ identified by ‘mysecretpass’; (replace databasename with the database name)

WhatIsMyIP?

Change hostname

Configuration file is located in /etc/sysconfig/network . So open it in editor and find the related line: HOSTNAME=myserver.domain.com Also you can change the host that is associated with the main IP address for your server in /etc/hosts file. Test command: hostname Carefully restart networking (You may lose your connection to remote server!): /etc/init.d/network restart

Читайте также:  Linux ext3 to ntfs

BIND DNS (Domain Name Server: The magic behind mycustomcomputername.com)

You can check each domain’s propagation using DNS checkers online. e.g-> https://dnschecker.org/
Also there is a geeky way: nslookup domain.com Install BIND 1- sudo yum install bind bind-utils -y Configure BIND (Remember that you can define your zones here, but it’s better to keep the standards. 2- sudo cat /etc/named.conf Look for included files, and edit the file as described below: 3- sudo vi /etc/named.rfc1912.zones Define your zones in file same as following lines: 4-

zone "mydomain.ir" IN < type master; file "mydomain.ir.zone"; allow-transfer < none; >; >; zone "mycustomer1domain.com" IN < type master; file "customers.zone"; allow-transfer < none; >; >; zone "mycustomer2domain.com" IN < type master; file "customers.zone"; allow-transfer < none; >; >; 

So you have to create the customers.zone and mydomain.ir.zone files you just mentioned in directory /var/named : 5.1- sudo touch /var/named/customers.zone
5.2- sudo touch /var/named/mydomain.ir.zone Then edit them as you wish: 6-

$TTL 86400 @ IN SOA ns1.mydomain.com. root.mydomain.com. ( 2013042201 ;Serial 3600 ;Refresh 1800 ;Retry 604800 ;Expire 86400 ;Minimum TTL ) ; Specify our two nameservers IN NS ns1.mydomain.ir. IN NS ns2.mydomain.ir. ; Resolve nameserver hostnames to IP, replace with your two droplet IP addresses. ns1 IN A SERVER_IP_HERE ns2 IN A SERVER_IP_HERE ; Define hostname -> IP pairs which you wish to resolve @ IN A SERVER_IP_HERE www IN A SERVER_IP_HERE 

Then any domain that is decided to be hosted on this server, must set ns1.mydomain.ir and ns2.mydomain.ir as their name server in domain control panel. If website was defined as a Virtual Host in Apache, it will be accessible.

Virtual Hosts

 DocumentRoot "/var/www/html/domainname" ServerName domainname ServerAlias www.domainname RedirectPermanent / https://domainname2 

Источник

Оцените статью
Adblock
detector