Vous êtes sur la page 1sur 4

Install VPS Server Domain Website

yum install screen -y


kemudian ketik screen
atau ketik screen -r (buat resume bila koneksi kedepan terputus)
Kemudian install command2 berikut ini :
yum update -y
yum install httpd php php-mysql perl mysql mysql-server -y
Hal pertama kita membuat daftar klien example, buat directory public_html folder, dan
berikan perintah permissions.
[root@testing www]# useradd example
[root@testing www]# passwd example
Changing password for user example.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@testing www]#
[root@testing www]# mkdir /home/example/public_html
[root@testing www]# chown example:example /home/example/public_html/
[root@testing www]# chmod 755 /home/example/public_html/
[root@testing www]# chown 711 /home/example/
[root@testing www]#
Gunakan edit dengan command nano /etc/httpd/conf/httpd.conf
[root@testing www]# vi /etc/httpd/conf/httpd.conf
Scroll down to the bottom of the file and add the following lines. Change the X.X.X.X to
your servers IP address and anywhere you see example.com to your domain name. Also
modify the home directory paths for your username instead of /home/example/. Simply add
another virtual host section if you want to host another domain.
NameVirtualHost *:80
<VirtualHost *:80>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com$1 [R=301,L]
ServerName example.com
ServerAlias www.exapmle.com
DocumentRoot /home/example/public_html
ErrorLog /var/log/example.com_error_log
CustomLog /var/log/example.com_access_log combined
DirectoryIndex index.html index.htm index.php index.php4 index.php5
SetOutputFilter DEFLATE
<Directory /home/example/public_html>
Options -Indexes +IncludesNOEXEC +SymLinksifOwnerMatch +ExecCGI
allow from all

AllowOverride All
</Directory>
</VirtualHost>
Simpan dan keluar dari file, kemudian start apache. pastikan command perintah dibawah ini
sebelum reboot.
[root@testing www]# /etc/init.d/httpd start
[root@testing www]# chkconfig httpd on
Sekarang tutorial menempatkan alokasi A record buat url dns ip address vps anda
Configure MySQL
MySQL dan password root vps pastikan berbeda
Pertama Start Mysql dan pastikan dapat start automatically pada setiap kali reboot
[root@testing www]# /etc/init.d/mysqld start
[root@testing www]# chkconfig mysqld on
Sekarang kita perlu melakukan koneksi dengan MySQL server dan setting passwordnya
sebagai berikut :
[root@testing www]# mysql -u root
mysql> UPDATE mysql.user SET Password = PASSWORD('NewPassWord')
-> WHERE User = 'root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 3 Changed: 0 Warnings: 0
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Next you should create a MySQL user and give that user access to their own database for
each site you want to create that needs a database. Again be sure to change example and
NEWPASSWORD to your username and your password. Dont forget this password. You
will need it when setting up your website.
[root@testing www]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql> create database example;
Query OK, 1 row affected (0.00 sec)
mysql> grant usage on *.* to quickvds@localhost identified by 'NEWPASSWORD';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on example.* to example@localhost ;

Query OK, 0 rows affected (0.00 sec)


mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Thats all there is to Setting up MySQL!
Configure IPTables on a VPS
As an additional security measure you should enable a firewall on your VPS. The IPTables
Firewall is available by default on all CentOS Installations, but by default it is disabled.
Before we just turn it on, you need to make sure you create some firewall rules first.
On your VPS make sure the firewall is stopped and then edit /etc/sysconfig/iptables. if you
never started IPTables before this file likely wont exist yet. Go ahead and create it and then
paste the following lines into the file and save it.
*nat
:PREROUTING ACCEPT [1:76]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
COMMIT
*mangle
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
*filter
:FORWARD ACCEPT [0:0]
:INPUT DROP [0:0]
:OUTPUT ACCEPT [0:0]
# Accept traffic from internal interfaces
-A INPUT ! -i eth0 -j ACCEPT
# Accept traffic with the ACK flag set
-A INPUT -p tcp -m tcp --tcp-flags ACK ACK -j ACCEPT
# Allow incoming data that is part of a connection we established
-A INPUT -m state --state ESTABLISHED -j ACCEPT
# Allow data that is related to existing connections
-A INPUT -m state --state RELATED -j ACCEPT
# Accept responses to DNS queries
-A INPUT -p udp -m udp --dport 1024:65535 --sport 53 -j ACCEPT
# Accept responses to our pings
-A INPUT -p icmp -m icmp --icmp-type echo-reply -j ACCEPT
# Accept notifications of unreachable hosts
-A INPUT -p icmp -m icmp --icmp-type destination-unreachable -j ACCEPT
# Accept notifications to reduce sending speed
-A INPUT -p icmp -m icmp --icmp-type source-quench -j ACCEPT

# Accept notifications of lost packets


-A INPUT -p icmp -m icmp --icmp-type time-exceeded -j ACCEPT
# Accept notifications of protocol problems
-A INPUT -p icmp -m icmp --icmp-type parameter-problem -j ACCEPT
# Allow connections to our SSH server
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
# Respond to pings
-A INPUT -p icmp -m icmp --icmp-type echo-request -j ACCEPT
# Allow connections to webserver
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
# Allow SSL connections to webserver
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
COMMIT
Now start IP Tables and set it to start on boot.
[root@testing www]# /etc/init.d/iptables start
[root@testing www]# chkconfig iptables on
To make sure your rules stuck, you can run the following command. You should see your
rules display.
[root@testing www]# /etc/init.d/iptables status

Vous aimerez peut-être aussi