Your question:
According to the Bible how does one receive the gift of the Holy Ghost?
Does one automatically receive the Holy Ghost after they accept Christ or does it have to be received through the laying on of hands as spoken of in Acts 8?
There is some of both. The Holy Ghost is needed by all so they can know Jesus is Christ. (1 Corinthians 12:3) After one has experienced the first steps of conversion which involve the Holy Ghost, they can receive a more significant gift of the Holy Ghost after baptism (Acts 2:37-38). This is given by the laying on of hands. The laying on of hands is usually done once, but after that the Holy Ghost can be with the recipient again and again.
I'll provide scriptures to illustrate this.
The Holy Ghost acts on us before baptism.
The Holy Ghost guides people to truth. The power of the Holy Ghost can come upon a person before baptism to help them develop faith that Jesus is Christ. In a sense, you might say one can receive the Holy Ghost before baptism. However, this isn't the same as receiving the gift of the Holy Ghost after baptism. The latter is more significant and further sanctifies us.
The Spirit guides us to truth.
Howbeit when he, the Spirit of truth, is come, he will guide you into all truth: for he shall not speak of himself; but whatsoever he shall hear, that shall he speak: and he will shew you things to come.(John 16:13).
You can't have faith in Jesus without the influence of the Holy Ghost.
No man can say Jesus is the Lord, but by the Holy Ghost (1 Corinthians 12:3)
The Holy Ghost fell on gentiles that heard Peter preach before they were baptized.
44 While Peter yet spake these words, the Holy Ghost fell on all them which heard the word.
45 And they of the circumcision which believed were astonished, as many as came with Peter, because that on the Gentiles also was poured out the gift of the Holy Ghost.
46 For they heard them speak with tongues, and magnify God. Then answered Peter,
47 Can any man forbid water, that these should not be baptized, which have received the Holy Ghost as well as we?
48 And he commanded them to be baptized in the name of the Lord. Then prayed they him to tarry certain days. (Acts 10:44-48)
After hearing Peter's preaching that Jesus was the Christ, men who were previously unbelievers were pricked in their hearts.
37 Now when they heard this, they were pricked in their heart, and said unto Peter and to the rest of the apostles, Men and brethren, what shall we do?
After the power of the Holy Ghost helps people to believe, repent, and be baptized, a more significant gift of the Holy Ghost can be received. It is given by the laying on of hands by one with authority.
After being pricked in their hearts by the Spirit which helped them develop faith to want to follow, these men were told to repent and then be baptized and then receive the Holy Ghost.
Now when they heard this, they were pricked in their heart, and said unto Peter and to the rest of the apostles, Men and brethren, what shall we do?
Then Peter said unto them, Repent, and be baptized every one of you in the name of Jesus Christ for the remission of sins, and ye shall receive the gift of the Holy Ghost. (Acts 2:37-38)
After baptism, the laying on of hands leads to receiving the gift of the Holy Ghost.
15 Who, when they were come down, prayed for them, that they might receive the Holy Ghost:
16 (For as yet he was fallen upon none of them: only they were baptized in the name of the Lord Jesus.)
17 Then laid they their hands on them, and they received the Holy Ghost.(Acts 8:15-17)
Simon recognized the gift of the Holy Ghost was given by the laying on of hands by those with authority/power to do so.
18 And when Simon saw that through laying on of the apostles’ hands the Holy Ghost was given, he offered them money,
19 Saying, Give me also this power, that on whomsoever I lay hands, he may receive the Holy Ghost. (Acts 8:18-19)
The first basic truths include repentance and faith, and the doctrines of baptism and the laying on of hands.
1 Therefore leaving the principles of the doctrine of Christ, let us go on unto perfection; not laying again the foundation of repentance from dead works, and of faith toward God,
2 Of the doctrine of baptisms, and of laying on of hands, and of resurrection of the dead, and of eternal judgment.
3 And this will we do, if God permit. (Hebrews 6:1-3)
Here's another translation (New Life Version)
So let us leave the first things you need to know about Christ. Let us go on to the teaching that full-grown Christians should understand. We do not need to teach these first truths again. You already know that you must be sorry for your sins and turn from them. You know that you must have faith in God. 2 You know about being baptized and about putting hands on people. You know about being raised from the dead and about being punished forever. 3 We will go on, if God lets us. (Hebrews 6:1-3)
Other verses supporting the gift of the Holy Ghost being given by the laying on of hands include 2 Timothy 1:6, and 1 Timothy 4:14.
The scriptures teach of baptism by water followed by baptism by fire (the Holy Ghost).
I indeed baptize you with water unto repentance: but he that cometh after me is mightier than I, whose shoes I am not worthy to bear: he shall baptize you with the Holy Ghost, and with fire (Matthew 3:11)
For John truly baptized with water; but ye shall be baptized with the Holy Ghost not many days hence. (Acts 1:5)
This is consistent with this verse.
5 Jesus answered, Verily, verily, I say unto thee, Except a man be born of water and of the Spirit, he cannot enter into the kingdom of God. (John 3:5)
Paul gives people the Holy Ghost by the laying on of hands after proper authorized baptism.
2 He said unto them, Have ye received the Holy Ghost since ye believed? And they said unto him, We have not so much as heard whether there be any Holy Ghost.
3 And he said unto them, Unto what then were ye baptized? And they said, Unto John’s baptism.
4 Then said Paul, John verily baptized with the baptism of repentance, saying unto the people, that they should believe on him which should come after him, that is, on Christ Jesus.
5 When they heard this, they were baptized in the name of the Lord Jesus.
6 And when Paul had laid his hands upon them, the Holy Ghost came on them; and they spake with tongues, and prophesied. (Acts 19:2-6)
Acts 19:2-6 shows how Paul thought it was important that after baptism by water, the believers also receive the gift of Holy Ghost.
Being given the gift of the Holy Ghost by the laying on of hands after baptism is part of the baptism by fire. Like water baptism, the laying on of hands is usually performed once. However, that doesn't mean this is the only time the recipient feels or is influenced by the Holy Ghost. On the contrary. After receiving the gift of the Holy Ghost, they can continually have it.
And I will pray the Father, and he shall give you another Comforter, that he may abide with you for ever; (John 14:6)
Even after being given the gift of the Holy Ghost, it remains for us to receive it.
Being given the gift of the Holy Ghost by the laying on of hands means it is our right, or privilege to receive it. But we still need to receive it. Even after time passes, we need to be receptive to it.
Believers are told to not quench the Spirit.
19 Quench not the Spirit. (1 Thessalonians 5:19)
The Holy Ghost is received by obedience.
32 And we are his witnesses of these things; and so is also the Holy Ghost, whom God hath given to them that obey him.(Acts 5:32)
Addition to Answer:
Another point borrowed from another answer is that receiving the gift of the Holy Ghost ties one to the body of Christ. This scripture was cited:
1 Cor. 12:13 For also in one Spirit we were all baptized into one Body, whether Jews or Greeks, whether slaves or free, and were all given to drink one Spirit.