-
Notifications
You must be signed in to change notification settings - Fork 1
/
On Centos 7
143 lines (96 loc) · 3.96 KB
/
On Centos 7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
==>> Install Nginx dan PHP-FPM
yum update
1. Remi Dependency on CentOS 7 and Red Hat (RHEL) 7
rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-1.noarch.rpm
2. CentOS 7 and Red Hat (RHEL) 7
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
Saya lebih suka menggunakan remi yang ke dua, karena PHP untuk opsi kedua sudah PHP 5.6.3 :D
Kemudian buat sebuah repo di direktori /etc/yum.repos.d/nginx.repo, dan tambahkan content ke repo file
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
Oke, kita mulai install nginx, php-fpm dan php-common
Jalankan command berikut :
yum --enablerepo=remi,remi-php56 install nginx php-fpm php-common
Install PHP Modul
yum --enablerepo=remi,remi-php56 install php-opcache php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongo php-pecl-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
stop service httpd
## Fedora 20/19 and CentOS/RHEL 7 ##
systemctl stop httpd.service
start service nginx
## Fedora 20/19 and CentOS/RHEL 7 ##
systemctl start nginx.service
start service php-fpm
## Fedora 20/19 and CentOS/RHEL 7 ##
systemctl start php-fpm.service
Autostart nginx, php-fpm
## Fedora 20/19 and CentOS/RHEL 7 ##
systemctl disable httpd.service
## Fedora 20/19 and CentOS/RHEL 7 ##
systemctl enable nginx.service
## Fedora 20/19 and CentOS/RHEL 7 ##
systemctl enable php-fpm.service
Edit host config di /etc/nginx/conf.d/default.conf
edit seperti berikut :
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
Jika proses installasi sudah selesai langkah selanjutnya restart nginx dan php-fpm
Untuk pengetesan apakah installasi php-fpm berjalan baik dan diharapkan, buat sebuah file di /usr/share/nginx/html/phpinfo.php
<?php
phpinfo();
?>
cek atau akses http://your-ip/phpinfo.php
==>> Install MariaDB
Sebelum installasi MariaDB terlebih dahulu menghapus package yang sebelumnya sudah ada
Jalankan command berikut
yum remove mysql* mysql-server mysql-devel mysql-libs
Disini saya asumsikan menggunakan MariaDB versi 10.0, buat sebuah repo vim /etc/yum.repos.d/MariaDB.repo
tambahkan content berikut
# MariaDB 10.0 CentOS repository list - created 2014-11-19 14:56 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
Kemudian jalankan command dan install MariaDB 10.0
yum install MariaDB-server MariaDB-client
Restart
/etc/init.d/mysql start
dan coba ketikkan command mysql, default MariaDB user root dan password none (kosong)
jalankan command berikut :
/usr/bin/mysql_secure_installation
dan isikan password, kemudian ada opsi dan pilih yes dan seterusnya hingga selesai
==>> Open Port untuk request
Jalankan iptables --line -vnL perhatikan line 7, lalu tambahkan dengan command berikut :
iptables -I INPUT 7 -i em4 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT 7 -i em4 -p tcp --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT
Restart service iptables restart
Tambahkan rule baru di Firewall
firewall-cmd --permanent --zone=public --add-service=http
Terima kasih semoga membantu