IGOS Nusantara dan nginx dan php: Perbedaan revisi
Dari IGNwiki
(→Mengaktifkan situs di home directory) |
(→Atur hak akses home directory) |
||
| (3 revisi antara oleh pengguna yang sama tidak ditampilkan) | |||
| Baris 29: | Baris 29: | ||
systemctl enable php-fpm.service | systemctl enable php-fpm.service | ||
| − | == | + | == Konfigurasi berkas default.conf == |
| + | Berkas di /etc/nginx/conf.d/'''default.conf''' | ||
| − | + | { | |
| − | + | server_name localhost; | |
| − | + | # root /var/www/html; | |
| − | + | root /usr/share/nginx/html; | |
| − | + | # autoindex on; | |
| − | + | index index.html index.htm; | |
| − | + | ||
| − | + | # Konfigurasi untuk berkas .php | |
| − | + | location ~ \.php$ | |
| + | { | ||
| + | fastcgi_pass 127.0.0.1:9000; | ||
| + | fastcgi_index index.php; | ||
| + | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
| + | include fastcgi_params; | ||
| + | } | ||
| + | } | ||
== Jalankan ulang nginx == | == Jalankan ulang nginx == | ||
| Baris 55: | Baris 63: | ||
http://localhost/info.php | http://localhost/info.php | ||
| − | == Mengaktifkan | + | == Mengaktifkan public_html di home directory == |
=== Buat berkas userdir.conf === | === Buat berkas userdir.conf === | ||
| Baris 85: | Baris 93: | ||
=== Atur hak akses home directory === | === Atur hak akses home directory === | ||
| − | Misal nama pengguna "igos" akan mengaktifkan | + | Misal nama pengguna "igos" akan mengaktifkan public_html |
Masuk sebagai root untuk mengubah hak akses menjadi 701 | Masuk sebagai root untuk mengubah hak akses menjadi 701 | ||
| Baris 104: | Baris 112: | ||
echo "<?php phpinfo(); ?>" > coba.php | echo "<?php phpinfo(); ?>" > coba.php | ||
| − | === Tes di | + | === Tes di peramban === |
Akses ke: | Akses ke: | ||
http://localhost/~igos/ | http://localhost/~igos/ | ||
Revisi terkini pada 21 Juli 2014 05.38
Panduan ini telah dicoba di IGOS Nusantara 9.2
Daftar isi
Pasang nginx dan modul-modul php
# Pasang nginx yum install nginx
# Pasang modul modul php yum install php-fpm php-common php-pecl-apcu php-cli \ php-pear php-pdo php-mysqlnd php-pgsql \ php-pecl-mongo php-pecl-memcache php-pecl-memcached \ php-gd php-mbstring php-mcrypt php-xml
# Pasang Zend OPcache yum install php-opcache
Jalankan
# systemctl start nginx.service systemctl start php-fpm.service
Tes halaman default
Silakan test dari browser:
http://localhost
Aktifkan nginx dan php-fpm
# systemctl enable nginx.service systemctl enable php-fpm.service
Konfigurasi berkas default.conf
Berkas di /etc/nginx/conf.d/default.conf
{
server_name localhost;
# root /var/www/html;
root /usr/share/nginx/html;
# autoindex on;
index index.html index.htm;
# Konfigurasi untuk berkas .php
location ~ \.php$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Jalankan ulang nginx
# systemctl reload nginx.service
<?php phpinfo(); ?>
Tes skrip info.php
Silakan test dari browser:
http://localhost/info.php
Mengaktifkan public_html di home directory
Buat berkas userdir.conf
Berkas buat di: /etc/nginx/conf.d/userdir.conf
server
{
server_name localhost;
# Userdir untuk berkas .php
location ~ ^/~([^/]+)/(.+\.php)$ {
if (!-f /home/$1/public_html/$2) {
rewrite ^ 404;
}
alias /home/$1/public_html/$2;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
# Userdir untuk berkas static
location ~ ^/~([^/]+)(/.*)?$ {
alias /home/$1/public_html$2;
autoindex on;
}
}
Atur hak akses home directory
Misal nama pengguna "igos" akan mengaktifkan public_html
Masuk sebagai root untuk mengubah hak akses menjadi 701
# chmod 701 /home/igos/
Masuk sebagai pengguna igos untuk membuat public_html
$ cd /home/igos mkdir public_html
Buat berkas coba.html dan coba.php
Berkas dibuat oleh pengguna igos di /home/igos/public_html
$ cd /home/igos/public_html echo "tes1" > coba.html echo "<?php phpinfo(); ?>" > coba.php
Tes di peramban
Akses ke:
http://localhost/~igos/