Showing posts with label Web Server. Show all posts
Showing posts with label Web Server. Show all posts

[Linux] Upgrade PHP 5 to PHP 7 using Yum on Oracle RHEL 6.3 Santiago

My Apache Web Server was running PHP version 5.3. But my developer need to use PHP 7.0, because they running on Laravel Framework 5.5. So I decided to upgrade PHP 5.3 to PHP 7.0. Although this is a development web server, I don’t want to disturb the existing setup and also, I don’t want to have multiple versions on PHP installed. So it should be a pure upgrade of PHP.

My environment is :


[root@devapp etc]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.3 (Santiago)

Here's what I've done to upgrade PHP.
1. Configure REMI Repository
# wget https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh epel-release-6-8.noarch.rpm

# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# rpm -Uvh remi-release-6.rpm

2. Activate REMI Repository
# yum repolist
# yum-config-manager --enable remi-php70
3. Upgrade PHP 5.3 to PHP 7.0
# yum --showduplicates list php
# yum update php

4. Verify the PHP version
# php -v

5. Restart Web Server
# service httpd restart


[Linux] Install php-mbstring On ORHEL 6.3

I am running Oracle Red Hat Enterprise Linux Server release 6.3 (Santiago) with PHP Version 5.3.3 and Apache/2.2.15 (Oracle) installed.

Problem :
Recently, I have a new apps and got some errors:

Fatal error: Call to undefined function mb_detect_encoding()


Cause:
This error occurs because the new application requires mbstring extension.

Solution:
So here is the solution.
1. Check phpinfo();
It seem that extension does not appear in phpinfo.

2. Check Extension
[root@intranet newapps]# rpm -qa | grep php-mbstring
[root@intranet newapps]# rpm -qa | grep php
php-pear-1.9.4-4.el6.noarch
php-ldap-5.3.3-3.el6_2.8.x86_64
php-common-5.3.3-3.el6_2.8.x86_64
php-xml-5.3.3-3.el6_2.8.x86_64
php-cli-5.3.3-3.el6_2.8.x86_64
php-gd-5.3.3-3.el6_2.8.x86_64
php-pdo-5.3.3-3.el6_2.8.x86_64
php-devel-5.3.3-3.el6_2.8.x86_64
php-5.3.3-3.el6_2.8.x86_64

mbstring extension is not currently installed

3. Search On Yum
[root@intranet newapps]# yum search php-mbstring
Loaded plugins: refresh-packagekit, security
==================================== N/S Matched: php-mbstring ====================================
php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling

4. Install mbstring extension
[root@intranet newapps]# yum install php-mbstring

5. Restart apache
[root@intranet newapps]# service httpd restart

6. Check phpinfo();
mbstring already installed and appear in phpinfo();
We can edit the mbstring value in /etc/php.ini


7. Check the new apps

[Apache] Redirect HTTP To HTTPS

If we want to redirect our web site to always be sent over SSL (HTTP TO HTTPS). We can do this :

1. Using Virtual Host
Just add this into apache config

<VirtualHost *:80>
    ServerName example.com
    Redirect / https://example.com/
</VirtualHost>


<VirtualHost _default_:443>
   ServerName secure.example.com
   DocumentRoot /usr/local/apache2/htdocs
   SSLEngine On
# etc...
</VirtualHost>

 
2. Using .htaccess

Redirect permanent /login https://mysite.example.com/login


3. Using mod_rewrite
This config can be used on .htaccess or httpd.conf

RewriteEngine On
# This will enable the Rewrite capabilities

RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS

RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
# This rule will redirect users from their original location, to the same location but using HTTPS.

[Linux] Apache Web Server On Slackware

Tiba-tiba pengen maen-maen PHP di Slackware, mau gak mau akhirnya harus install Apache web server. Gimana caranya? Begini nih.....

Pertama cek dulu, apakah service-nya udah jalan atau belom. Siapa tau udah berjalan.
root@c1c4x_lab:~# nmap -sS localhost

Starting nmap 3.50 ( http://www.insecure.org/nmap/ ) at 2006-07-29 16:13 WIT
Interesting ports on localhost (127.0.0.1):
(The 1653 ports scanned but not shown below are in state: closed)
PORT     STATE SERVICE
22/tcp   open  ssh
25/tcp   open  smtp
37/tcp   open  time
113/tcp  open  auth
587/tcp  open  submission
6000/tcp open  X11

Nmap run completed -- 1 IP address (1 host up) scanned in 1.056 seconds

ow, ternyata service httpd belom berjalan. So mari kita mulai. apache terletak di direktori /etc/apache terus edit file httpd.conf

root@c1c4x_lab:~# cd /etc/apache
root@c1c4x_lab:/etc/apache# pico httpd.conf

Untuk mengaktifkan modul PHP, agar apache bisa mengeksekusi .php maka aktifkan baris Include /etc/apache/mod_php.conf dengan menghapus tanda # (pagar), biasanya terletak di bawah sendiri. Kalo pengen apache-nya mendukung SSL (Secure Socket Layer), maka aktifkan juga modul SSL-nya.

....baris atas sengaja di hapus....
# ==> mod_php configuration settings  mod_ssl configuration settings < ==
#
# PACKAGES REQUIRED:  apache (N series) and openssl (N series)
#
Include /etc/apache/mod_ssl.conf

Jalankan servicenya:
root@c1c4x_lab:/etc/apache# /etc/rc.d/rc.httpd start
-bash: /etc/rc.d/rc.httpd: Permission denied

Lho koq denied? Oh iya lupa, file permissionnya belom execute. Kalo gak percaya mari kita lihat dan buktikan :D Pergi ke drektori /etc/rc.d

root@c1c4x_lab:~# cd /etc/rc.d
root@c1c4x_lab:/etc/rc.d# ls -al rc.httpd
-rw-r--r--  1 root root 401 2003-03-06 04:28 rc.httpd

Tuh kan, permissionnya masih default yaitu 644, so perlu diganti dulu permissionnya.
root@c1c4x_lab:/etc/rc.d# chmod 755 rc.httpd
root@c1c4x_lab:/etc/rc.d# ls -al rc.httpd
-rwxr-xr-x  1 root root 401 2003-03-06 04:28 rc.httpd*

sekarang jalankan service-nya, kemudian test pake nmap.
root@c1c4x_lab:/etc/rc.d# /etc/rc.d/rc.httpd start
/usr/sbin/apachectl start: httpd started
root@c1c4x_lab:/etc/rc.d# nmap -sS localhost

Starting nmap 3.50 ( http://www.insecure.org/nmap/ ) at 2006-07-29 16:24 WIT
Interesting ports on localhost (127.0.0.1):
(The 1652 ports scanned but not shown below are in state: closed)
PORT     STATE SERVICE
22/tcp   open  ssh
25/tcp   open  smtp
37/tcp   open  time
80/tcp   open  http === service httpd telah berjalan
113/tcp  open  auth
587/tcp  open  submission
6000/tcp open  X11

Selain command /etc/rc.d/rc.httpd start, bisa juga digunakan command apachectl, seperti berikut:
root@c1c4x_lab:/etc/rc.d# apachectl stop
/usr/sbin/apachectl stop: httpd stopped
root@c1c4x_lab:/etc/rc.d# apachectl start
/usr/sbin/apachectl start: httpd started

Direktori htdocs, secara default terletak di /var/www/htdocs. Direktory bisa diubah dengan melakukan edit di httpd.conf

Sekarang kita cek di browser, apakah service telah berjalan dengan baik. Dan apakah web server telah mendukung php. Bwat file phpinfo.php, untuk menguji apakah web server bisa menjalankan .php


http://localhost == telah berjalan dengan semestinya


http://localhost/phpinfo.php == dapat berjalan berarti telah mendukung .php


Ahh...... akhirnya bisa maen-maen php di Slackware dehh. I Love Slackware :D :D