Halaman

Jumat, 04 Juni 2021

How to fix 404 Not Found Nginx - PHP

I'm working on moving applications from the old server to the new server and have to re-install. At this stage I configure PHP-based applications with related frameworks using Nginx as a web server. The problem that arises is the message Not Found with code 404, when the application runs the index.php file which then calls another file to run the actual process.

 

Next I created a test.php file to detect errors in the application and the tes.php file can run normally (code 200).

Information from curl shows the index.php file Found (302), but controller and action Not Found (404).



Status code HTTP/1.1 302 Found, indicates the requested resource resides temporarily under a different URI

The 404 Not Found message states that the server has not found anything matching the Request-URI.

The results of sudo tail -f /var/log/nginx/error.log and sudo tail -f /var/log/nginx/access.log don't show anything odd. The php files have been processed correctly, but the problem lies most likely in my Nginx configuration which is not suitable for processing php files.

I changed the configuration in the file /etc/nginx/sites-available/myweb.domain.com, which is from

location / {
try_files $uri $uri/ =404;
}
to 

location / {
try_files $uri $uri/ /index.php?$args;
}

Then do sudo service nginx restart and check the result:


As a result, my applications can run as they should and the status becomes HTTP/1.1 200 OK  or request has succeeded.

Jumat, 18 Oktober 2013

Oracle orasso

How to find lost ORASSO password
Login as orcladmin through Directory Manager and navigate to:
--> Entry Management
--> cn=OracleContext
--> cn=Products
--> cn=IAS
--> cn=IAS Infrastructure Databases
--> orclReferenceName=(yoursid.domain)
--> orclResourceName=ORASSO find the password in orclpasswords atribute on Properties tab.
also see --> orclResourceName=PORTAL
If you forget orcladmin, use this command from $ORACLE_HOME/bin directory
oidpasswd connect=yourDBconn unlock_su_acct=true enter new password...
OID DB user password: mynewpass

Kamis, 11 April 2013

Shrinking the SQL Server log

To backup a database, we could instruct SQL Server to truncate of the transaction log, using T-SQL command: BACKUP LOG db_name WITH TRUNCATE_ONLY. Log truncation remove transactions from the log file and the space remains allocated to the file. Sometimes as in my case below, you need to shrink the log file to reclaim the space.

In my case, I receive a backup file from SQL Server 2008, probably a full backup. After restoring the file and create a new database on my laptop, the used space is 160MB for the data and 52GB for the log file. My local disk free space 18 GB left, I need to shrinking the log file.

1. Check the database size property:
Select name, filename, convert(decimal(12,2), round(a.size/128.000,2)) as SizeMB,
convert(decimal(12,2), round(fileproperty(a.name,'SpaceUsed')/128.000,2)) as SpcUsedMB, 
convert(decimal(12,2), round((a.size-fileproperty(a.name,'SpaceUsed'))/128.000,2)) as FreeSpcMB
from dbo.sysfiles a

name        filename            SizeMB    SpcUsedMB  FreeSpcMB 
-----------------------------------------------------------------
Student     D:\DATA\STUDENT.mdf 155.69    149.50     6.19
Student_log D:\DATA\STUDENT.ldf 50861.94  362.09     50499.84

The FreeSpcMB shows 51GB and I try to reclaim the space of the log file to OS.

2. Change the database recover mode to simple
   ALTER DATABASE Student SET RECOVERY SIMPLE;
   GO

3. Do the Shrink the log file to 1 MB
   DBCC SHRINKFILE (Student_log, 1);
   GO

3. Reset the database recovery model.
   ALTER DATABASE Student SET RECOVERY FULL;
   GO
   SELECT name, recovery_model_desc FROM sys.databases;
   GO


Now, the OS has 70GB free space.

Sabtu, 23 Maret 2013

Eclipse: Cannot create a server using the selected type

I just install Tomcat version 7.0.37 to replace the old 7 version, but the new server could not be add to Eclipse with error message "Cannot create a server using the selected type".

To solve the problem, I've remove these files: org.eclipse.jst.server.tomcat.core.prefs  and org.eclipse.wst.server.core.prefs from /workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings
and delete the old server.

After restarting Eclipse, "Define a New Server", now Tomcat works.

Kamis, 21 Februari 2013

Hierarchical Data

Recursive queries are typically used to deal with hierarchical or tree-structured data, such as chart of accounts (COA). COA is a listing all the accounts in the general ledger in such a way that forms a hierarchical structure, for example the following:


acc_
acc_id parid acc_code     acc_name                    acc_level
-----------------------------------------------------------------
1           10.0000.0000 AKTIVA                         0
2 1 11.0000.0000 AKTIVA LANCAR                   1
3 2 11.1000.0000 Kas dan Setara Kas                2
4  3 11.1100.0000 Kas                            3
5  4 11.1110.0000 Kas - Program Kemitraan          4
6  4 11.1120.0000 Kas - Bina Lingkungan             4
7  3 11.1200.0000 Bank                            3
8  7 11.1210.0000 Bank - Program Kemitraan        4
....
....
116  97 22.0000.0000 KEWAJIBAN JANGKA PANJANG 1
117  116 22.2000.0000 Hutang Kepada BUMN Pembina Lain  2
119  116 22.9000.0000 Hutang Jangka Panjang Lainnya     2
122          30.0000.0000 AKTIVA BERSIH                   0
123  122 33.0000.0000 PENYISIHAN                      1



The list is generated by running the following SQL command:


WITH RECURSIVE tree AS (SELECT acc_id,acc_code, acc_parid, acc_name ,0 AS acc_level 
FROM tova.coa WHERE acc_parid IS NULL
UNION ALL
SELECT c.acc_id, c.acc_code, c.acc_parid, c.acc_name, acc_level+1 AS acc_level 
FROM tova.coa c JOIN tree t ON t.acc_id  = c.acc_parid)
SELECT acc_id, acc_parid, tova.getakunttk(acc_code), acc_name, acc_level 
FROM tree b order by 3;


I save the transaction only at the lowest level account, of course user still can see reports for each account in a hierarchy. The stored function below will display accounts hierarchy.

CREATE OR REPLACE FUNCTION tova.getcoa_allchildofparentrec(IN pacc_parid integer) 
RETURNS TABLE (acc_id integer,acc_code character varying, acc_name character varying) AS
$$
BEGIN
    RETURN QUERY WITH RECURSIVE tree AS (
            SELECT a.acc_id, a.acc_code as acc_code,a.acc_name 
               FROM tova.coa a WHERE acc_parid = $1
            UNION ALL
            SELECT a.acc_id, a.acc_code as acc_code,a.acc_name 
               FROM tova.coa a, tree t WHERE t.acc_id = a.acc_parid)
    SELECT h.acc_id,h.acc_code, h.acc_name FROM tree h;
END;
$$ LANGUAGE plpgsql;


To display the coa's tree, just call this:
select acc_code, acc_name from ferry.getcoa_allchildofparentrec(34) order by 1;


acc_code acc_name
---------------------------------------------------------------------
11.3610.0000 Piutang Pinjaman Mitra Binaan - Sektor Industri
11.3610.6108 PPMB Sektor Industri - Kab. Landak
11.3610.6103 PPMB Sektor Industri - Kab. Sanggau
11.3610.6301 PPMB Sektor Industri - Kab. Tanah Laut
11.3610.6309 PPMB Sektor Industri - Kab. Tabalong
11.3610.6105 PPMB Sektor Industri - Kab. Sintang
11.3610.6303 PPMB Sektor Industri - Kab. Banjar
11.3610.6100 PPMB Sektor Industri Prov. Kalimantan Barat
11.3610.6171 PPMB Sektor Industri - Kota Pontianak
11.3620.0000 Piutang Pinjaman Mitra Binaan - Sektor Perdagangan
11.3630.0000 Piutang Pinjaman Mitra Binaan - Sektor Pertanian
11.3640.0000 Piutang Pinjaman Mitra Binaan - Sektor Peternakan
11.3650.0000 Piutang Pinjaman Mitra Binaan - Sektor Perkebunan
11.3660.0000 Piutang Pinjaman Mitra Binaan - Sektor Perikanan
11.3670.0000 Piutang Pinjaman Mitra Binaan - Sektor Jasa
11.3680.0000 Piutang Pinjaman Mitra Binaan - Sektor Lain
11.3610.6300 Sektor Industri Prov. Kalimantan Selatan
11.3610.6310 PPMB - Sektor Industri - Kab. Tanah Bumbu
...
...
11.3670.6171 Piutang Pinjaman Mitra Binaan - Sektor Jasa - Kota Pontianak
11.3660.6171 Piutang Pinjaman Mitra Binaan - Sektor Perikanan - Kota Pontianak
11.3680.6171 Piutang Pinjaman Mitra Binaan - Sektor Lain - Kota Pontianak

Minggu, 23 September 2012

PostgreSQL: Invalid byte sequence for encoding UTF8


I have a comma delimited file (.csv) contains stock master data and wanto to import them into PostgreSQL table .During importing, I am facing Invalid byte sequence for encoding "UTF8" error message.

C:\>psql -Umyname -dmydb -p5490
--1. do import
mydb=# \copy myshema.stocks from C:\temp\inv.csv with delimiter as ';'csv
ERROR: Invalid byte sequence for encoding "UTF8": 0xa0
CONTEXT:  copy stock, line 26120

--2. check my client encoding
mydb=# show client_encoding;

client_encoding
----------------
UTF8
(1 row)

--3. modify my client encoding
mydb=# \client_encoding LATIN1

--3a. check current client encoding
mydb=# show client_encoding;

client_encoding
----------------
LATIN1
(1 row)
--4. Re do importing
mydb=# \copy myshema.stocks from C:\temp\inv.csv with delimiter as ';'csv

--5. reset client_encoding;

That is it.

Kamis, 20 September 2012

Create a Control to act like a Button

System.Windows.Forms.UserControl provides an empty control that can be used to create other controls. We might consider to inherit the class to create a control with custom appearance, feature and behaviour.
I then create a control that functionally same as standard button, but my control could not be be assign to AcceptButton and CancelButton property of a form. To allows the control to act like a button on a form, just implement the IButtonControl interface to the control.

public class FerBtn : System.Windows.Forms.UserControl, System.Windows.Forms.IButtonControl
{
}

After visit this, I copy and paste the DialogResult property, the NotifyDefault and PerformClick methods, and add a definition for IsDefault.

private bool mIsDefault;
[Browsable(false)]
public bool IsDefault 
{
  get { return this.mIsDefault; }
  set { this.mIsDefault = value; }
}

Now this control could be assign to AcceptButton and CancelButton property of a form.