I want to know if I directly connect a normal computer (with RJ45 interface) to the WAN port of a normal router, Does the router allocated a IP address to this computer?
No, the router itself won't.
These routers are preconfigured to have two logical interfaces:
The "LAN" ports are bridged into one interface, with a static IPv4 address and issuing addresses to connected devices via DHCP.
The "WAN" port is a second interface, with no IP addresses and no DHCP service. Instead the WAN interface runs a DHCP client, expecting to receive an address assignment from the ISP's upstream router (or some other DHCP server).
If not what configuration should I set for both the router and computer to make it allocate
It depends – many routers meant for home use actually don't expose the settings needed. (People often end up installing an alternative OS such as OpenWRT to get the flexibility.) But if possible, you would need to do one of these:
Enable a DHCP server on the "WAN" interface, configuring it for a different subnet from the LAN. (You'll most likely also want to disable the existing NAT and firewall rules as they're not suitable for routing between two LAN subnets.)
Or, move the WAN port from a separate interface into the "LAN" bridge. The router then no longer actually routes anything, only acts as a switch (and DHCP server).
In addition if I connect a second computer to on LAN port of router, can I discover the first computer from the second computer by using ping command?
Yes (once you already have the address assignment sorted out). But note that most home routers come with predefined firewall rules which allow this in one direction only (LAN→WAN), and will block WAN→LAN traffic unless you disable them.